[Scummvm-git-logs] scummvm master -> 8a48bdbf0aedfadd487a09d7b0bfa82966c876a3
athrxx
noreply at scummvm.org
Fri Jul 12 21:53:34 UTC 2024
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
c5bfd8cfb5 SCI: move x-alignment into gfx drivers
7ada2f4017 COMMON: mark vga grey scale rendermode as translateable
8a48bdbf0a SCI: slight performance upgrade for custom palette rendering
Commit: c5bfd8cfb55f130cf2b162ad2d3693787d3310f7
https://github.com/scummvm/scummvm/commit/c5bfd8cfb55f130cf2b162ad2d3693787d3310f7
Author: athrxx (athrxx at scummvm.org)
Date: 2024-07-12T23:51:47+02:00
Commit Message:
SCI: move x-alignment into gfx drivers
The alignment can be done inside the drivers. We need it for CGA and early
version CGA b/w only, since we don't have the same (hardware based
requirements) as the original drivers. So we can really clean up the code
here.
Changed paths:
engines/sci/graphics/gfxdrivers.cpp
engines/sci/graphics/gfxdrivers.h
engines/sci/graphics/screen.cpp
diff --git a/engines/sci/graphics/gfxdrivers.cpp b/engines/sci/graphics/gfxdrivers.cpp
index f5ca40adbc2..e9cc18497c9 100644
--- a/engines/sci/graphics/gfxdrivers.cpp
+++ b/engines/sci/graphics/gfxdrivers.cpp
@@ -36,8 +36,6 @@ namespace Sci {
#define GFXDRV_ASSERT_READY \
if (!_ready) \
error("%s: initScreen() must be called before using this method", __FUNCTION__)
-#define GFXDRV_ASSERT_ALIGNED \
- assert(!(w & _hAlign) && !(x & _hAlign))
Common::Point GfxDriver::getMousePos() const {
return g_system->getEventManager()->getMousePos();
@@ -68,7 +66,7 @@ bool GfxDriver::checkDriver(const char *const *driverNames, int listSize) {
return false;
}
-GfxDefaultDriver::GfxDefaultDriver(uint16 screenWidth, uint16 screenHeight, bool rgbRendering) : GfxDriver(screenWidth, screenHeight, 0, 1),
+GfxDefaultDriver::GfxDefaultDriver(uint16 screenWidth, uint16 screenHeight, bool rgbRendering) : GfxDriver(screenWidth, screenHeight, 0),
_srcPixelSize(1), _requestRGBMode(rgbRendering), _compositeBuffer(nullptr), _currentBitmap(nullptr), _internalPalette(nullptr), _currentPalette(nullptr) {
switch (g_sci->getResMan()->getViewType()) {
case kViewEga:
@@ -145,7 +143,7 @@ void GfxDefaultDriver::setPalette(const byte *colors, uint start, uint num, bool
if (_pixelSize > 1) {
updatePalette(colors, start, num, (_srcPixelSize == _pixelSize) || (palMods != nullptr && palModMapping != nullptr));
if (update)
- copyRectToScreen(_currentBitmap, _screenW, 0, 0, _screenW, _screenH, palMods, palModMapping);
+ copyRectToScreen(_currentBitmap, 0, 0, _screenW, 0, 0, _screenW, _screenH, palMods, palModMapping);
CursorMan.replaceCursorPalette(_currentPalette, 0, 256);
} else {
g_system->getPaletteManager()->setPalette(colors, start, num);
@@ -170,20 +168,21 @@ void updateBitmapBuffer(byte *dst, int dstPitch, const byte *src, int srcPitch,
}
}
-void GfxDefaultDriver::copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h, const PaletteMod *palMods, const byte *palModMapping) {
+void GfxDefaultDriver::copyRectToScreen(const byte *src, int srcX, int srcY, int pitch, int destX, int destY, int w, int h, const PaletteMod *palMods, const byte *palModMapping) {
GFXDRV_ASSERT_READY;
- GFXDRV_ASSERT_ALIGNED; // We can't fix the boundaries here, it has to happen before this call
+
+ src += (srcY * pitch + srcX);
if (src != _currentBitmap)
- updateBitmapBuffer(_currentBitmap, _screenW * _srcPixelSize, src, pitch, x * _srcPixelSize, y, w * _srcPixelSize, h);
+ updateBitmapBuffer(_currentBitmap, _screenW * _srcPixelSize, src, pitch, destX * _srcPixelSize, destY, w * _srcPixelSize, h);
if (_pixelSize != _srcPixelSize) {
- generateOutput(_compositeBuffer, src, pitch, w, h, palMods, palModMapping + y * pitch + x);
+ generateOutput(_compositeBuffer, src, pitch, w, h, palMods, palModMapping + destY * pitch + destX);
src = _compositeBuffer;
pitch = w * _pixelSize;
}
- g_system->copyRectToScreen(src, pitch, x, y, w, h);
+ g_system->copyRectToScreen(src, pitch, destX, destY, w, h);
}
void GfxDefaultDriver::replaceCursor(const void *cursor, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor) {
@@ -298,8 +297,8 @@ void GfxDefaultDriver::generateOutput(byte *dst, const byte *src, int pitch, int
}
}
-SCI0_DOSPreVGADriver::SCI0_DOSPreVGADriver(int numColors, int screenW, int screenH, int horizontalAlignment, bool rgbRendering) :
- GfxDriver(screenW, screenH, numColors, horizontalAlignment), _requestRGBMode(rgbRendering), _colors(nullptr), _compositeBuffer(nullptr), _internalPalette(nullptr) {
+SCI0_DOSPreVGADriver::SCI0_DOSPreVGADriver(int numColors, int screenW, int screenH, bool rgbRendering) :
+ GfxDriver(screenW, screenH, numColors), _requestRGBMode(rgbRendering), _colors(nullptr), _compositeBuffer(nullptr), _internalPalette(nullptr) {
}
SCI0_DOSPreVGADriver::~SCI0_DOSPreVGADriver() {
@@ -367,7 +366,7 @@ void SCI0_DOSPreVGADriver::copyCurrentPalette(byte *dest, int start, int num) co
memcpy(dest + start * 3, _colors + start * 3, MIN<int>(num, _numColors) * 3);
}
-SCI0_CGADriver::SCI0_CGADriver(bool emulateCGAModeOnEGACard, bool rgbRendering) : SCI0_DOSPreVGADriver(4, 320, 200, 1, rgbRendering), _cgaPatterns(nullptr), _disableMode5(emulateCGAModeOnEGACard) {
+SCI0_CGADriver::SCI0_CGADriver(bool emulateCGAModeOnEGACard, bool rgbRendering) : SCI0_DOSPreVGADriver(4, 320, 200, rgbRendering), _cgaPatterns(nullptr), _disableMode5(emulateCGAModeOnEGACard) {
static const byte cgaColors[48] = {
/*
// Canonical CGA palette
@@ -466,19 +465,24 @@ SCI0_CGADriver::~SCI0_CGADriver() {
delete[] _cgaPatterns;
}
-void SCI0_CGADriver::copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h, const PaletteMod*, const byte*) {
+void SCI0_CGADriver::copyRectToScreen(const byte *src, int srcX, int srcY, int pitch, int destX, int destY, int w, int h, const PaletteMod*, const byte*) {
GFXDRV_ASSERT_READY;
- GFXDRV_ASSERT_ALIGNED; // We can't fix the boundaries here, it has to happen before this call
+
+ srcX &= ~1;
+ destX &= ~1;
+ w = (w + 1) & ~1;
+
+ src += (srcY * pitch + srcX);
byte *dst = _compositeBuffer;
- int ty = y;
+ int ty = destY;
for (int i = 0; i < h; ++i) {
- _renderLine(dst, src, w, x & 3, ++ty, _cgaPatterns, _internalPalette);
+ _renderLine(dst, src, w, destX & 3, ++ty, _cgaPatterns, _internalPalette);
src += pitch;
}
- g_system->copyRectToScreen(_compositeBuffer, w * _pixelSize, x, y, w, h);
+ g_system->copyRectToScreen(_compositeBuffer, w * _pixelSize, destX, destY, w, h);
}
void SCI0_CGADriver::replaceCursor(const void *cursor, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor) {
@@ -576,7 +580,7 @@ const byte *monochrInit(const char *drvFile, bool &earlyVersion) {
return result;
}
-SCI0_CGABWDriver::SCI0_CGABWDriver(uint32 monochromeColor, bool rgbRendering) : SCI0_DOSPreVGADriver(2, 640, 400, 1, rgbRendering), _monochromePatterns(nullptr), _earlyVersion(false) {
+SCI0_CGABWDriver::SCI0_CGABWDriver(uint32 monochromeColor, bool rgbRendering) : SCI0_DOSPreVGADriver(2, 640, 400, rgbRendering), _monochromePatterns(nullptr), _earlyVersion(false) {
_monochromePalette[0] = _monochromePalette[1] = _monochromePalette[2] = 0;
_monochromePalette[3] = (monochromeColor >> 16) & 0xff;
_monochromePalette[4] = (monochromeColor >> 8) & 0xff;
@@ -591,22 +595,28 @@ SCI0_CGABWDriver::~SCI0_CGABWDriver() {
delete[] _monochromePatterns;
}
-void SCI0_CGABWDriver::copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h, const PaletteMod*, const byte*) {
+void SCI0_CGABWDriver::copyRectToScreen(const byte *src, int srcX, int srcY, int pitch, int destX, int destY, int w, int h, const PaletteMod*, const byte*) {
GFXDRV_ASSERT_READY;
- GFXDRV_ASSERT_ALIGNED; // We can't fix the boundaries here, it has to happen before this call
byte *dst = _compositeBuffer;
- int ty = y & 7;
- if (_earlyVersion)
+ int ty = destY & 7;
+
+ if (_earlyVersion) {
++ty;
+ srcX &= ~1;
+ destX &= ~1;
+ w = (w + 1) & ~1;
+ }
+
+ src += (srcY * pitch + srcX);
for (int i = 0; i < h; ++i) {
- _renderLine(dst, src, w, x & 3, ty, _monochromePatterns, _internalPalette);
+ _renderLine(dst, src, w, destX & 3, ty, _monochromePatterns, _internalPalette);
ty = (ty + 1) & 7;
src += pitch;
}
- g_system->copyRectToScreen(_compositeBuffer, (w << 1) * _pixelSize, x << 1, y << 1, w << 1, h << 1);
+ g_system->copyRectToScreen(_compositeBuffer, (w << 1) * _pixelSize, destX << 1, destY << 1, w << 1, h << 1);
}
void SCI0_CGABWDriver::replaceCursor(const void *cursor, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor) {
@@ -715,7 +725,7 @@ void SCI0_CGABWDriver::setupRenderProc() {
const char *SCI0_CGABWDriver::_driverFiles[2] = { "CGA320BW.DRV", "CGA320M.DRV" };
-SCI0_HerculesDriver::SCI0_HerculesDriver(uint32 monochromeColor, bool rgbRendering, bool cropImage) : SCI0_DOSPreVGADriver(2, cropImage ? 640 : 720, cropImage ? 300 : 350, 0, rgbRendering),
+SCI0_HerculesDriver::SCI0_HerculesDriver(uint32 monochromeColor, bool rgbRendering, bool cropImage) : SCI0_DOSPreVGADriver(2, cropImage ? 640 : 720, cropImage ? 300 : 350, rgbRendering),
_centerX(cropImage ? 0 : 40), _centerY(cropImage ? 0 : 25), _monochromePatterns(nullptr) {
_monochromePalette[0] = _monochromePalette[1] = _monochromePalette[2] = 0;
_monochromePalette[3] = (monochromeColor >> 16) & 0xff;
@@ -732,19 +742,19 @@ SCI0_HerculesDriver::~SCI0_HerculesDriver() {
delete[] _monochromePatterns;
}
-void SCI0_HerculesDriver::copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h, const PaletteMod*, const byte*) {
+void SCI0_HerculesDriver::copyRectToScreen(const byte *src, int srcX, int srcY, int pitch, int destX, int destY, int w, int h, const PaletteMod*, const byte*) {
GFXDRV_ASSERT_READY;
- GFXDRV_ASSERT_ALIGNED; // We can't fix the boundaries here, it has to happen before this call
byte *dst = _compositeBuffer;
- byte sw = y & 1;
- y = (y & ~1) * 3 / 2 + (y & 1);
- int ty = y & 7;
+ byte sw = destY & 1;
+ src += (srcY * pitch + srcX);
+ destY = (destY & ~1) * 3 / 2 + (destY & 1);
+ int ty = destY & 7;
int rh = 0;
for (int i = 0; i < h; ++i) {
const byte *src2 = src;
- _renderLine(dst, src2, w, x & 3, ty, _monochromePatterns, _internalPalette);
+ _renderLine(dst, src2, w, destX & 3, ty, _monochromePatterns, _internalPalette);
ty = (ty + 1) & 7;
++rh;
@@ -759,7 +769,7 @@ void SCI0_HerculesDriver::copyRectToScreen(const byte *src, int pitch, int x, in
}
}
- g_system->copyRectToScreen(_compositeBuffer, (w << 1) * _pixelSize, (x << 1) + _centerX, y + _centerY, w << 1, rh);
+ g_system->copyRectToScreen(_compositeBuffer, (w << 1) * _pixelSize, (destX << 1) + _centerX, destY + _centerY, w << 1, rh);
}
void SCI0_HerculesDriver::replaceCursor(const void *cursor, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor) {
@@ -859,7 +869,7 @@ void SCI1_VGAGreyScaleDriver::setPalette(const byte *colors, uint start, uint nu
const char *SCI1_VGAGreyScaleDriver::_driverFile = "VGA320BW.DRV";
-SCI1_EGADriver::SCI1_EGADriver(bool rgbRendering) : GfxDriver(320, 200, 256, 1), _requestRGBMode(rgbRendering), _egaColorPatterns(nullptr), _egaMatchTable(nullptr),
+SCI1_EGADriver::SCI1_EGADriver(bool rgbRendering) : GfxDriver(320, 200, 256), _requestRGBMode(rgbRendering), _egaColorPatterns(nullptr), _egaMatchTable(nullptr),
_currentBitmap(nullptr), _compositeBuffer(nullptr), _currentPalette(nullptr), _internalPalette(nullptr), _colAdjust(0), _ready(false) {
Common::File drv;
if (!drv.open(_driverFile))
@@ -1017,15 +1027,16 @@ void SCI1_EGADriver::setPalette(const byte *colors, uint start, uint num, bool u
colors += 3;
}
if (update)
- copyRectToScreen(_currentBitmap, _screenW, 0, 0, _screenW, _screenH, nullptr, nullptr);
+ copyRectToScreen(_currentBitmap, 0, 0, _screenW, 0, 0, _screenW, _screenH, nullptr, nullptr);
}
-void SCI1_EGADriver::copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h, const PaletteMod*, const byte*) {
+void SCI1_EGADriver::copyRectToScreen(const byte *src, int srcX, int srcY, int pitch, int destX, int destY, int w, int h, const PaletteMod*, const byte*) {
GFXDRV_ASSERT_READY;
- GFXDRV_ASSERT_ALIGNED; // We can't fix the boundaries here, it has to happen before this call
+
+ src += (srcY * pitch + srcX);
if (src != _currentBitmap)
- updateBitmapBuffer(_currentBitmap, _screenW, src, pitch, x, y, w, h);
+ updateBitmapBuffer(_currentBitmap, _screenW, src, pitch, destX, destY, w, h);
byte *dst = _compositeBuffer;
for (int i = 0; i < h; ++i) {
@@ -1033,7 +1044,7 @@ void SCI1_EGADriver::copyRectToScreen(const byte *src, int pitch, int x, int y,
src += pitch;
}
- g_system->copyRectToScreen(_compositeBuffer, (w << 1) * _pixelSize, x << 1, y << 1, w << 1, h << 1);
+ g_system->copyRectToScreen(_compositeBuffer, (w << 1) * _pixelSize, destX << 1, destY << 1, w << 1, h << 1);
}
void SCI1_EGADriver::replaceCursor(const void *cursor, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor) {
diff --git a/engines/sci/graphics/gfxdrivers.h b/engines/sci/graphics/gfxdrivers.h
index 4bb5ba10bfd..5f4c05936e0 100644
--- a/engines/sci/graphics/gfxdrivers.h
+++ b/engines/sci/graphics/gfxdrivers.h
@@ -31,11 +31,11 @@ struct PaletteMod;
class GfxDriver {
public:
- GfxDriver(uint16 screenWidth, uint16 screenHeight, int numColors, int horizontalAlignment) : _screenW(screenWidth), _screenH(screenHeight), _numColors(numColors), _hAlign(horizontalAlignment), _ready(false), _pixelSize(1) {}
+ GfxDriver(uint16 screenWidth, uint16 screenHeight, int numColors) : _screenW(screenWidth), _screenH(screenHeight), _numColors(numColors), _ready(false), _pixelSize(1) {}
virtual ~GfxDriver() {}
virtual void initScreen(const Graphics::PixelFormat *srcRGBFormat = nullptr) = 0; // srcRGBFormat: expect incoming data to have the specified rgb pixel format (used for Mac hicolor videos)
virtual void setPalette(const byte *colors, uint start, uint num, bool update, const PaletteMod *palMods, const byte *palModMapping) = 0;
- virtual void copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h, const PaletteMod *palMods, const byte *palModMapping) = 0;
+ virtual void copyRectToScreen(const byte *src, int srcX, int srcY, int pitch, int destX, int destY, int w, int h, const PaletteMod *palMods, const byte *palModMapping) = 0;
virtual void replaceCursor(const void *cursor, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor) = 0;
virtual Common::Point getMousePos() const;
virtual void clearRect(const Common::Rect &r) const;
@@ -43,7 +43,6 @@ public:
virtual void copyCurrentPalette(byte *dest, int start, int num) const;
virtual bool supportsPalIntensity() const = 0;
uint16 numColors() const { return _numColors; }
- byte hAlignment() const { return _hAlign; }
byte pixelSize() const { return _pixelSize; }
protected:
bool _ready;
@@ -52,7 +51,6 @@ protected:
const uint16 _screenH;
uint16 _numColors;
byte _pixelSize;
- const byte _hAlign;
};
class GfxDefaultDriver : public GfxDriver {
@@ -61,7 +59,7 @@ public:
~GfxDefaultDriver() override;
void initScreen(const Graphics::PixelFormat *srcRGBFormat) override; // srcRGBFormat: expect incoming data to have the specified rgb pixel format (used for Mac hicolor videos)
void setPalette(const byte *colors, uint start, uint num, bool update, const PaletteMod *palMods, const byte *palModMapping) override;
- void copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h, const PaletteMod *palMods, const byte *palModMapping) override;
+ void copyRectToScreen(const byte *src, int srcX, int srcY, int pitch, int destX, int destY, int w, int h, const PaletteMod *palMods, const byte *palModMapping) override;
void replaceCursor(const void *cursor, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor) override;
void copyCurrentBitmap(byte *dest, uint32 size) const override;
void copyCurrentPalette(byte *dest, int start, int num) const override;
@@ -81,7 +79,7 @@ private:
class SCI0_DOSPreVGADriver : public GfxDriver {
public:
- SCI0_DOSPreVGADriver(int numColors, int screenW, int screenH, int horizontalAlignment, bool rgbRendering);
+ SCI0_DOSPreVGADriver(int numColors, int screenW, int screenH, bool rgbRendering);
~SCI0_DOSPreVGADriver() override;
void initScreen(const Graphics::PixelFormat*) override;
void setPalette(const byte*, uint, uint, bool, const PaletteMod*, const byte*) {}
@@ -102,7 +100,7 @@ class SCI0_CGADriver final : public SCI0_DOSPreVGADriver {
public:
SCI0_CGADriver(bool emulateCGAModeOnEGACard, bool rgbRendering);
~SCI0_CGADriver() override;
- void copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h, const PaletteMod*, const byte*) override;
+ void copyRectToScreen(const byte *src, int srcX, int srcY, int pitch, int destX, int destY, int w, int h, const PaletteMod*, const byte*) override;
void replaceCursor(const void *cursor, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor) override;
static bool validateMode() { return checkDriver(&_driverFile, 1); }
private:
@@ -119,7 +117,7 @@ class SCI0_CGABWDriver final : public SCI0_DOSPreVGADriver {
public:
SCI0_CGABWDriver(uint32 monochromeColor, bool rgbRendering);
~SCI0_CGABWDriver() override;
- void copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h, const PaletteMod*, const byte*) override;
+ void copyRectToScreen(const byte *src, int srcX, int srcY, int pitch, int destX, int destY, int w, int h, const PaletteMod*, const byte*) override;
void replaceCursor(const void *cursor, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor) override;
Common::Point getMousePos() const override;
void clearRect(const Common::Rect &r) const override;
@@ -138,7 +136,7 @@ class SCI0_HerculesDriver final : public SCI0_DOSPreVGADriver {
public:
SCI0_HerculesDriver(uint32 monochromeColor, bool rgbRendering, bool cropImage);
~SCI0_HerculesDriver() override;
- void copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h, const PaletteMod*, const byte*) override;
+ void copyRectToScreen(const byte *src, int srcX, int srcY, int pitch, int destX, int destY, int w, int h, const PaletteMod*, const byte*) override;
void replaceCursor(const void *cursor, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor) override;
Common::Point getMousePos() const override;
void clearRect(const Common::Rect &r) const override;
@@ -171,7 +169,7 @@ public:
~SCI1_EGADriver() override;
void initScreen(const Graphics::PixelFormat*) override;
void setPalette(const byte *colors, uint start, uint num, bool update, const PaletteMod*, const byte*) override;
- void copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h, const PaletteMod*, const byte*) override;
+ void copyRectToScreen(const byte *src, int srcX, int srcY, int pitch, int destX, int destY, int w, int h, const PaletteMod*, const byte*) override;
void replaceCursor(const void *cursor, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor) override;
void copyCurrentBitmap(byte *dest, uint32 size) const override;
void copyCurrentPalette(byte *dest, int start, int num) const override;
diff --git a/engines/sci/graphics/screen.cpp b/engines/sci/graphics/screen.cpp
index 3683cd49f23..42e79c24664 100644
--- a/engines/sci/graphics/screen.cpp
+++ b/engines/sci/graphics/screen.cpp
@@ -271,7 +271,7 @@ GfxScreen::~GfxScreen() {
void GfxScreen::displayRect(const Common::Rect &rect, int x, int y) {
// Display rect from _activeScreen to screen location x, y.
// Clipping is assumed to be done already.
- _gfxDrv->copyRectToScreen(_activeScreen + rect.top * _displayWidth + rect.left,
+ _gfxDrv->copyRectToScreen(_activeScreen, rect.left, rect.top,
_displayWidth, x, y, rect.width(), rect.height(), _paletteModsEnabled ? _paletteMods : nullptr, _paletteMapScreen);
}
@@ -294,9 +294,7 @@ void GfxScreen::copyToScreen() {
}
void GfxScreen::copyVideoFrameToScreen(const byte *buffer, int pitch, const Common::Rect &rect) {
- uint8 align = _gfxDrv->hAlignment();
- Common::Rect r(rect.left & ~align, rect.top, (rect.right + align) & ~align, rect.bottom);
- _gfxDrv->copyRectToScreen(buffer, pitch, r.left, r.top, r.width(), r.height(), _paletteModsEnabled ? _paletteMods : nullptr, _paletteMapScreen);
+ _gfxDrv->copyRectToScreen(buffer, rect.left, rect.top, pitch, rect.left, rect.top, rect.width(), rect.height(), _paletteModsEnabled ? _paletteMods : nullptr, _paletteMapScreen);
}
void GfxScreen::kernelSyncWithFramebuffer() {
@@ -305,9 +303,7 @@ void GfxScreen::kernelSyncWithFramebuffer() {
void GfxScreen::copyRectToScreen(const Common::Rect &rect) {
if (!_upscaledHires) {
- uint8 align = _gfxDrv->hAlignment();
- Common::Rect r(rect.left & ~align, rect.top, (rect.right + align) & ~align, rect.bottom);
- displayRect(r, r.left, r.top);
+ displayRect(rect, rect.left, rect.top);
} else {
int rectHeight = _upscaledHeightMapping[rect.bottom] - _upscaledHeightMapping[rect.top];
int rectWidth = _upscaledWidthMapping[rect.right] - _upscaledWidthMapping[rect.left];
@@ -334,9 +330,7 @@ void GfxScreen::copyDisplayRectToScreen(const Common::Rect &rect) {
void GfxScreen::copyRectToScreen(const Common::Rect &rect, int16 x, int16 y) {
if (!_upscaledHires) {
- uint8 align = _gfxDrv->hAlignment();
- Common::Rect r(rect.left & ~align, rect.top, (rect.right + align) & ~align, rect.bottom);
- displayRect(r, x & ~align, y);
+ displayRect(rect, x, y);
} else {
int rectHeight = _upscaledHeightMapping[rect.bottom] - _upscaledHeightMapping[rect.top];
int rectWidth = _upscaledWidthMapping[rect.right] - _upscaledWidthMapping[rect.left];
@@ -954,9 +948,7 @@ void GfxScreen::bakDiscard() {
void GfxScreen::bakCopyRectToScreen(const Common::Rect &rect, int16 x, int16 y) {
assert(_backupScreen);
- uint8 align = _gfxDrv->hAlignment();
- Common::Rect r(rect.left & ~align, rect.top, (rect.right + align) & ~align, rect.bottom);
- _gfxDrv->copyRectToScreen(_backupScreen + r.left + r.top * _displayWidth, _displayWidth, x & ~align, y, r.width(), r.height(), _paletteModsEnabled ? _paletteMods : nullptr, _paletteMapScreen);
+ _gfxDrv->copyRectToScreen(_backupScreen, rect.left, rect.top, _displayWidth, x, y, rect.width(), rect.height(), _paletteModsEnabled ? _paletteMods : nullptr, _paletteMapScreen);
}
void GfxScreen::setPaletteMods(const PaletteMod *mods, unsigned int count) {
Commit: 7ada2f40178d97d83d55acfe0f3fe8383a420cee
https://github.com/scummvm/scummvm/commit/7ada2f40178d97d83d55acfe0f3fe8383a420cee
Author: athrxx (athrxx at scummvm.org)
Date: 2024-07-12T23:51:52+02:00
Commit Message:
COMMON: mark vga grey scale rendermode as translateable
Changed paths:
common/rendermode.cpp
diff --git a/common/rendermode.cpp b/common/rendermode.cpp
index 8710fd8be99..69ec47c8863 100644
--- a/common/rendermode.cpp
+++ b/common/rendermode.cpp
@@ -53,7 +53,7 @@ const RenderModeDescription g_renderModes[] = {
{ "cpc", "Amstrad CPC", kRenderCPC },
{ "zx", "ZX Spectrum", kRenderZX },
{ "c64", "Commodore 64", kRenderC64 },
- { "vgaGrey", "VGA Grey Scale", kRenderVGAGrey },
+ { "vgaGrey", _s("VGA Grey Scale"), kRenderVGAGrey },
{nullptr, nullptr, kRenderDefault}
};
Commit: 8a48bdbf0aedfadd487a09d7b0bfa82966c876a3
https://github.com/scummvm/scummvm/commit/8a48bdbf0aedfadd487a09d7b0bfa82966c876a3
Author: athrxx (athrxx at scummvm.org)
Date: 2024-07-12T23:51:55+02:00
Commit Message:
SCI: slight performance upgrade for custom palette rendering
(suggested by ccawley2011 in the PR discussion)
Changed paths:
engines/sci/graphics/gfxdrivers.cpp
engines/sci/graphics/gfxdrivers.h
diff --git a/engines/sci/graphics/gfxdrivers.cpp b/engines/sci/graphics/gfxdrivers.cpp
index e9cc18497c9..6c2a2e3bf19 100644
--- a/engines/sci/graphics/gfxdrivers.cpp
+++ b/engines/sci/graphics/gfxdrivers.cpp
@@ -141,7 +141,7 @@ void GfxDefaultDriver::initScreen(const Graphics::PixelFormat *srcRGBFormat) {
void GfxDefaultDriver::setPalette(const byte *colors, uint start, uint num, bool update, const PaletteMod *palMods, const byte *palModMapping) {
GFXDRV_ASSERT_READY;
if (_pixelSize > 1) {
- updatePalette(colors, start, num, (_srcPixelSize == _pixelSize) || (palMods != nullptr && palModMapping != nullptr));
+ updatePalette(colors, start, num);
if (update)
copyRectToScreen(_currentBitmap, 0, 0, _screenW, 0, 0, _screenW, _screenH, palMods, palModMapping);
CursorMan.replaceCursorPalette(_currentPalette, 0, 256);
@@ -172,7 +172,6 @@ void GfxDefaultDriver::copyRectToScreen(const byte *src, int srcX, int srcY, int
GFXDRV_ASSERT_READY;
src += (srcY * pitch + srcX);
-
if (src != _currentBitmap)
updateBitmapBuffer(_currentBitmap, _screenW * _srcPixelSize, src, pitch, destX * _srcPixelSize, destY, w * _srcPixelSize, h);
@@ -230,12 +229,8 @@ template <typename T> void updateRGBPalette(byte *dest, const byte *src, uint st
}
}
-void GfxDefaultDriver::updatePalette(const byte *colors, uint start, uint num, bool skipRGBPalette) {
+void GfxDefaultDriver::updatePalette(const byte *colors, uint start, uint num) {
memcpy(_currentPalette + start * 3, colors, num * 3);
- // If palette mods are on we don't need to update the internal palette,
- // since the colors have to be generated on the fly anyway.
- if (skipRGBPalette)
- return;
if (_pixelSize == 4)
updateRGBPalette<uint32>(_internalPalette, colors, start, num, _format);
else if (_pixelSize == 2)
@@ -258,20 +253,22 @@ template <typename T> void render(byte *dst, const byte *src, int pitch, int w,
}
#define applyMod(a, b) MIN<uint>(a * (128 + b) / 128, 255)
-template <typename T> void renderMod(byte *dst, const byte *src, int pitch, int w, int h, const byte *pal, Graphics::PixelFormat &f, const PaletteMod *mods, const byte *modMapping) {
+template <typename T> void renderMod(byte *dst, const byte *src, int pitch, int w, int h, const byte *srcPal, const byte *internalPal, Graphics::PixelFormat &f, const PaletteMod *mods, const byte *modMapping) {
T *d = reinterpret_cast<T*>(dst);
+ const T *p = reinterpret_cast<const T*>(internalPal);
const byte *s1 = src;
const byte *s2 = modMapping;
pitch -= w;
while (h--) {
for (int i = 0; i < w; ++i) {
- const byte *col = &pal[*s1++ * 3];
byte m = *s2++;
- if (m)
+ if (m) {
+ const byte *col = &srcPal[*s1++ * 3];
*d++ = f.RGBToColor(applyMod(col[0], mods[m].r), applyMod(col[1], mods[m].g), applyMod(col[2], mods[m].b));
- else
- *d++ = f.RGBToColor(col[0], col[1], col[2]);
+ } else {
+ *d++ = p[*s1++];
+ }
}
s1 += pitch;
s2 += pitch;
@@ -282,9 +279,9 @@ template <typename T> void renderMod(byte *dst, const byte *src, int pitch, int
void GfxDefaultDriver::generateOutput(byte *dst, const byte *src, int pitch, int w, int h, const PaletteMod *palMods, const byte *palModMapping) {
if (palMods && palModMapping) {
if (_pixelSize == 2)
- renderMod<uint16>(dst, src, pitch, w, h, _currentPalette, _format, palMods, palModMapping);
+ renderMod<uint16>(dst, src, pitch, w, h, _currentPalette, _internalPalette, _format, palMods, palModMapping);
else if (_pixelSize == 4)
- renderMod<uint32>(dst, src, pitch, w, h, _currentPalette, _format, palMods, palModMapping);
+ renderMod<uint32>(dst, src, pitch, w, h, _currentPalette, _internalPalette, _format, palMods, palModMapping);
else
error("GfxDefaultDriver::generateOutput(): Unsupported pixel size %d", _pixelSize);
} else {
diff --git a/engines/sci/graphics/gfxdrivers.h b/engines/sci/graphics/gfxdrivers.h
index 5f4c05936e0..f40a1af317a 100644
--- a/engines/sci/graphics/gfxdrivers.h
+++ b/engines/sci/graphics/gfxdrivers.h
@@ -23,7 +23,7 @@
#define SCI_GRAPHICS_GFXDRIVERS_H
#include "common/rect.h"
-#include "graphics//pixelformat.h"
+#include "graphics/pixelformat.h"
namespace Sci {
@@ -65,7 +65,7 @@ public:
void copyCurrentPalette(byte *dest, int start, int num) const override;
bool supportsPalIntensity() const override { return true; }
protected:
- void updatePalette(const byte *colors, uint start, uint num, bool skipRGBPalette);
+ void updatePalette(const byte *colors, uint start, uint num);
byte *_compositeBuffer;
byte *_currentBitmap;
byte *_currentPalette;
More information about the Scummvm-git-logs
mailing list