[Scummvm-git-logs] scummvm master -> caaddab19b596ea8ef8be06a9c09c280b4b88802
lephilousophe
noreply at scummvm.org
Sat Nov 21 16:51:25 UTC 2026
This automated email contains information about 6 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
d3d183c586 SURFACESDL: Fix mouse rendering and dirty rect management
6a5510247b SURFACESDL: Remove useless parameter to addDirtyRect
689e964939 SURFACESDL: Remove unused attributes
3d799b503d TESTBED: Setup proper cursor for testing mouse movement
fda126421f GRAPHICS: Remove unused argument in Scaler::setSource
caaddab19b SURFACESDL: Disable source image use in scaler while clearing overlay
Commit: d3d183c5867e058adfb9ae12348e9ee940d1cb47
https://github.com/scummvm/scummvm/commit/d3d183c5867e058adfb9ae12348e9ee940d1cb47
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2026-11-21T17:51:01+01:00
Commit Message:
SURFACESDL: Fix mouse rendering and dirty rect management
The dirty rect coordinates depend on whther the overlay is shown or not.
Do the appropriate scaling based on that.
When mouse is actually drawn, take into account that the rect was
already scaled or not.
Changed paths:
backends/graphics/surfacesdl/surfacesdl-graphics.cpp
backends/graphics/surfacesdl/surfacesdl-graphics.h
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index ad7bc1a82fd..939ce9dcb1b 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -190,7 +190,7 @@ SurfaceSdlGraphicsManager::SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSou
#endif
_transactionMode(kTransactionNone),
_scalerPlugins(ScalerMan.getPlugins()), _scalerPlugin(nullptr), _scaler(nullptr),
- _needRestoreAfterOverlay(false), _isInOverlayPalette(false), _isDoubleBuf(false), _prevForceRedraw(false), _numPrevDirtyRects(0),
+ _prevOverlayVisible(false), _isInOverlayPalette(false), _isDoubleBuf(false), _prevForceRedraw(false), _numPrevDirtyRects(0),
_prevCursorNeedsRedraw(false),
_mouseKeyColor(0), _disableMouseKeyColor(false) {
@@ -1291,7 +1291,7 @@ void SurfaceSdlGraphicsManager::internUpdateScreen() {
int oldScaleFactor;
if (!_overlayVisible) {
- if (_needRestoreAfterOverlay) {
+ if (_prevOverlayVisible && _useOldSrc) {
// This is needed for the Edge scaler which seems to be the only scaler to use the "_useOldSrc" feature.
// Otherwise the screen will not be properly restored after removing the overlay. We need to trigger a
// regeneration of SourceScaler::_bufferedOutput. The call to _scaler->setFactor() down below could
@@ -1306,7 +1306,6 @@ void SurfaceSdlGraphicsManager::internUpdateScreen() {
width = _videoMode.screenWidth;
height = _videoMode.screenHeight;
oldScaleFactor = scale1 = _videoMode.scaleFactor;
- _needRestoreAfterOverlay = false;
} else {
origSurf = _overlayscreen;
srcSurf = _tmpscreen2;
@@ -1314,9 +1313,16 @@ void SurfaceSdlGraphicsManager::internUpdateScreen() {
height = _videoMode.overlayHeight;
scale1 = 1;
oldScaleFactor = _scaler->setFactor(1);
- _needRestoreAfterOverlay = _useOldSrc;
}
+ if (_prevOverlayVisible != _overlayVisible) {
+ // Overlay state change must trigger an undrawMouse call
+ // to update mouse rect coordinates
+ _cursorNeedsRedraw = true;
+ }
+
+ _prevOverlayVisible = _overlayVisible;
+
// Add the area covered by the mouse cursor to the list of dirty rects if
// we have to redraw the mouse, or if the cursor is alpha-blended since
// alpha-blended cursors will happily blend into themselves if the surface
@@ -2527,18 +2533,26 @@ void SurfaceSdlGraphicsManager::undrawMouse() {
_mouseNextRect.x = virtualCursor.x + _gameScreenShakeXOffset;
_mouseNextRect.y = virtualCursor.y + _gameScreenShakeYOffset;
- if (!_overlayInGUI) {
- // The game cursor rect is kept in virtual coordinates: drawMouse()
- // scales and aspect-corrects it, so subtract the virtual hotspot here
- _mouseNextRect.w = _mouseCurState.vW;
- _mouseNextRect.h = _mouseCurState.vH;
- _mouseNextRect.x -= _mouseCurState.vHotX;
- _mouseNextRect.y -= _mouseCurState.vHotY;
- } else {
+ // Apply the hotspot
+ _mouseNextRect.x -= _mouseCurState.hotX;
+ _mouseNextRect.y -= _mouseCurState.hotY;
+
+ if (_overlayVisible) {
_mouseNextRect.w = _mouseCurState.rW;
_mouseNextRect.h = _mouseCurState.rH;
- _mouseNextRect.x -= _mouseCurState.rHotX;
- _mouseNextRect.y -= _mouseCurState.rHotY;
+
+ if (!_overlayInGUI) {
+ _mouseNextRect.x *= _videoMode.scaleFactor;
+ _mouseNextRect.y *= _videoMode.scaleFactor;
+ if (_videoMode.aspectRatioCorrection)
+ _mouseNextRect.y = real2Aspect(_mouseNextRect.y);
+ }
+ } else {
+ // When overlay is not shown, the scaling of dirty rect
+ // is done in internUpdateScreen
+ // Hence, we also do it in drawMouse
+ _mouseNextRect.w = _mouseCurState.w * _cursorScaleX;
+ _mouseNextRect.h = _mouseCurState.h * _cursorScaleY;
}
if (!_cursorVisible || !_mouseSurface) {
@@ -2550,14 +2564,14 @@ void SurfaceSdlGraphicsManager::undrawMouse() {
// alpha-blended cursors will happily blend into themselves if the surface
// under the cursor is not reset first
//
- // The mouse is undrawn using virtual coordinates, i.e. they may be
- // scaled and aspect-ratio corrected.
+ // The mouse is undrawn using coordinates in use depending on the
+ // overlay status
if (_mouseLastRect.w != 0 && _mouseLastRect.h != 0)
- addDirtyRect(_mouseLastRect.x, _mouseLastRect.y, _mouseLastRect.w, _mouseLastRect.h, _overlayInGUI);
+ addDirtyRect(_mouseLastRect.x, _mouseLastRect.y, _mouseLastRect.w, _mouseLastRect.h, _overlayVisible);
if (_mouseNextRect.w != 0 && _mouseNextRect.h != 0)
- addDirtyRect(_mouseNextRect.x, _mouseNextRect.y, _mouseNextRect.w, _mouseNextRect.h, _overlayInGUI);
+ addDirtyRect(_mouseNextRect.x, _mouseNextRect.y, _mouseNextRect.w, _mouseNextRect.h, _overlayVisible);
}
void SurfaceSdlGraphicsManager::drawMouse() {
@@ -2568,22 +2582,25 @@ void SurfaceSdlGraphicsManager::drawMouse() {
SDL_Rect dst;
// We draw the pre-scaled cursor image, so now we need to adjust for
- // scaling, shake position and aspect ratio correction manually.
+ // scaling, shake position and aspect ratio correction manually depending
+ // on the overlay status
dst.x = _mouseNextRect.x;
dst.y = _mouseNextRect.y;
- dst.w = _mouseNextRect.w;
- dst.h = _mouseNextRect.h;
- if (_videoMode.aspectRatioCorrection && !_overlayInGUI)
- dst.y = real2Aspect(dst.y);
+ if (_overlayVisible) {
+ dst.w = _mouseNextRect.w;
+ dst.h = _mouseNextRect.h;
+ } else {
+ dst.w = _mouseCurState.rW;
+ dst.h = _mouseCurState.rH;
- if (!_overlayInGUI) {
dst.x *= _videoMode.scaleFactor;
dst.y *= _videoMode.scaleFactor;
+ if (_videoMode.aspectRatioCorrection) {
+ dst.y = real2Aspect(dst.y);
+ }
}
- dst.w = _mouseCurState.rW;
- dst.h = _mouseCurState.rH;
// Note that SDL_BlitSurface() and addDirtyRect() will both perform any
// clipping necessary
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.h b/backends/graphics/surfacesdl/surfacesdl-graphics.h
index c1f66d14a96..2cd1e04e96b 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.h
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.h
@@ -469,13 +469,7 @@ private:
y * getOverlayHeight() / getHeight());
}
- /**
- * Special case for scalers that use the useOldSrc feature (currently
- * only the Edge scalers). The variable is checked after closing the
- * overlay, so that the creation of a new output buffer for the scaler
- * can be triggered.
- */
- bool _needRestoreAfterOverlay;
+ bool _prevOverlayVisible;
bool _prevForceRedraw;
bool _prevCursorNeedsRedraw;
};
Commit: 6a5510247b45690fbb4a73a28e7503d51e95edb7
https://github.com/scummvm/scummvm/commit/6a5510247b45690fbb4a73a28e7503d51e95edb7
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2026-11-21T17:51:02+01:00
Commit Message:
SURFACESDL: Remove useless parameter to addDirtyRect
It was never specified so was always false.
Also avoid extending the dirty rect in overlay as it is not needed.
Changed paths:
backends/graphics/surfacesdl/surfacesdl-graphics.cpp
backends/graphics/surfacesdl/surfacesdl-graphics.h
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index 939ce9dcb1b..b3ececb2773 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -1800,7 +1800,7 @@ void SurfaceSdlGraphicsManager::fillScreen(const Common::Rect &r, uint32 col) {
unlockScreen();
}
-void SurfaceSdlGraphicsManager::addDirtyRect(int x, int y, int w, int h, bool inOverlay, bool realCoordinates) {
+void SurfaceSdlGraphicsManager::addDirtyRect(int x, int y, int w, int h, bool inOverlay) {
if (_forceRedraw)
return;
@@ -1811,23 +1811,22 @@ void SurfaceSdlGraphicsManager::addDirtyRect(int x, int y, int w, int h, bool in
int height, width;
- if (!inOverlay && !realCoordinates) {
+ if (!inOverlay) {
width = _videoMode.screenWidth;
height = _videoMode.screenHeight;
- } else {
- width = _videoMode.overlayWidth;
- height = _videoMode.overlayHeight;
- }
- // Extend the dirty region for scalers
- // that "smear" the screen, e.g. 2xSAI
- if (!realCoordinates) {
+ // Extend the dirty region for scalers
+ // that "smear" the screen, e.g. 2xSAI
// Aspect ratio correction requires this to be at least one
int adjust = MAX(_extraPixels, (uint)1);
x -= adjust;
y -= adjust;
w += adjust * 2;
h += adjust * 2;
+ } else {
+ width = _videoMode.overlayWidth;
+ height = _videoMode.overlayHeight;
+ // Overlay has no scaling so no extension
}
// clip
@@ -1850,7 +1849,7 @@ void SurfaceSdlGraphicsManager::addDirtyRect(int x, int y, int w, int h, bool in
}
#ifdef USE_ASPECT
- if (_videoMode.aspectRatioCorrection && !inOverlay && !realCoordinates)
+ if (_videoMode.aspectRatioCorrection && !inOverlay)
makeRectStretchable(x, y, w, h, _videoMode.filtering);
#endif
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.h b/backends/graphics/surfacesdl/surfacesdl-graphics.h
index 2cd1e04e96b..42e4badc3ad 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.h
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.h
@@ -415,7 +415,7 @@ protected:
Common::Rect _focusRect;
#endif
- virtual void addDirtyRect(int x, int y, int w, int h, bool inOverlay, bool realCoordinates = false);
+ virtual void addDirtyRect(int x, int y, int w, int h, bool inOverlay);
virtual void drawMouse();
virtual void undrawMouse();
Commit: 689e9649395a4ef496cf46cf11492bc599e4b9db
https://github.com/scummvm/scummvm/commit/689e9649395a4ef496cf46cf11492bc599e4b9db
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2026-11-21T17:51:02+01:00
Commit Message:
SURFACESDL: Remove unused attributes
These are only written, never read.
Changed paths:
backends/graphics/surfacesdl/surfacesdl-graphics.cpp
backends/graphics/surfacesdl/surfacesdl-graphics.h
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index b3ececb2773..b40475a5fd1 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -2377,15 +2377,6 @@ void SurfaceSdlGraphicsManager::blitCursor() {
// Adapt the real hotspot according to the scale factor.
int rW = fracToInt(w * cursorScaleX);
int rH = fracToInt(h * cursorScaleY);
- _mouseCurState.rHotX = fracToInt(_mouseCurState.hotX * cursorScaleX);
- _mouseCurState.rHotY = fracToInt(_mouseCurState.hotY * cursorScaleY);
-
- // The virtual dimensions will be the same as the original.
-
- _mouseCurState.vW = w;
- _mouseCurState.vH = h;
- _mouseCurState.vHotX = _mouseCurState.hotX;
- _mouseCurState.vHotY = _mouseCurState.hotY;
#ifdef USE_ASPECT
// store original to pass to aspect-correction function later
@@ -2394,7 +2385,6 @@ void SurfaceSdlGraphicsManager::blitCursor() {
if (!(_cursorScaleX == 0 && _cursorScaleY == 0) && _videoMode.aspectRatioCorrection) {
rH = real2Aspect(rH - 1) + 1;
- _mouseCurState.rHotY = real2Aspect(_mouseCurState.rHotY);
}
bool sizeChanged = false;
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.h b/backends/graphics/surfacesdl/surfacesdl-graphics.h
index 42e4badc3ad..4bfcecf2498 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.h
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.h
@@ -361,19 +361,12 @@ protected:
int16 w, h;
int16 hotX, hotY;
- // The size and hotspot of the pre-scaled cursor image, in real
+ // The size of the pre-scaled cursor image, in real
// coordinates.
int16 rW, rH;
- int16 rHotX, rHotY;
-
- // The size and hotspot of the pre-scaled cursor image, in game
- // coordinates.
- int16 vW, vH;
- int16 vHotX, vHotY;
MousePos() : w(0), h(0), hotX(0), hotY(0),
- rW(0), rH(0), rHotX(0), rHotY(0), vW(0), vH(0),
- vHotX(0), vHotY(0)
+ rW(0), rH(0)
{ }
};
Commit: 3d799b503dc5797aa7462fed8956c498c990f41a
https://github.com/scummvm/scummvm/commit/3d799b503dc5797aa7462fed8956c498c990f41a
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2026-11-21T17:51:02+01:00
Commit Message:
TESTBED: Setup proper cursor for testing mouse movement
Changed paths:
engines/testbed/graphics.cpp
diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp
index cd5230d9085..65928224c2d 100644
--- a/engines/testbed/graphics.cpp
+++ b/engines/testbed/graphics.cpp
@@ -1013,6 +1013,8 @@ TestExitStatus GFXtests::mouseMovements() {
return kTestSkipped;
}
+ GFXtests::drawCursor(false, FRAC_ONE, FRAC_ONE);
+
// Draw Rectangle
// Ensure that 2 represents red in current palette
GFXTestSuite::setCustomColor(255, 0, 0);
Commit: fda126421fcc6a96ac8d1bf8042f6396848f9b2e
https://github.com/scummvm/scummvm/commit/fda126421fcc6a96ac8d1bf8042f6396848f9b2e
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2026-11-21T17:51:02+01:00
Commit Message:
GRAPHICS: Remove unused argument in Scaler::setSource
The buffer pointer is not used and we even pass nullptr sometimes.
Remove it to avoid leaving the idea that the buffer passed is used by
the scaler.
Changed paths:
backends/graphics/surfacesdl/surfacesdl-graphics.cpp
graphics/scalerplugin.cpp
graphics/scalerplugin.h
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index b40475a5fd1..5f24535e8f5 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -719,8 +719,8 @@ void SurfaceSdlGraphicsManager::setGraphicsModeIntern() {
_useOldSrc = _scalerPlugin->useOldSource();
if (_useOldSrc) {
_scaler->enableSource(true);
- _scaler->setSource((byte *)_tmpscreen->pixels, _tmpscreen->pitch,
- _videoMode.screenWidth, _videoMode.screenHeight, _maxExtraPixels);
+ _scaler->setSource(_tmpscreen->pitch, _videoMode.screenWidth, _videoMode.screenHeight,
+ _maxExtraPixels);
}
// Blit everything to the screen
@@ -1057,8 +1057,7 @@ bool SurfaceSdlGraphicsManager::loadGFXMode() {
if (_useOldSrc) {
// Create surface containing previous frame's data to pass to scaler
- _scaler->setSource((byte *)_tmpscreen->pixels, _tmpscreen->pitch,
- _videoMode.screenWidth, _videoMode.screenHeight, _maxExtraPixels);
+ _scaler->setSource(_tmpscreen->pitch, _videoMode.screenWidth, _videoMode.screenHeight, _maxExtraPixels);
}
_overlayscreen = createSurface(_videoMode.overlayWidth, _videoMode.overlayHeight, _hwScreen);
@@ -1295,10 +1294,8 @@ void SurfaceSdlGraphicsManager::internUpdateScreen() {
// This is needed for the Edge scaler which seems to be the only scaler to use the "_useOldSrc" feature.
// Otherwise the screen will not be properly restored after removing the overlay. We need to trigger a
// regeneration of SourceScaler::_bufferedOutput. The call to _scaler->setFactor() down below could
- // do that in theory, but it won't unless the factor actually changes (which it doesn't). Now, the code
- // in SourceScaler::setSource() looks a bit fishy, e. g. the *src argument isn't even used. But otherwise
- // it does what we want here at least...
- _scaler->setSource(nullptr, _tmpscreen->pitch, _videoMode.screenWidth, _videoMode.screenHeight, _maxExtraPixels);
+ // do that in theory, but it won't unless the factor actually changes (which it doesn't).
+ _scaler->setSource(_tmpscreen->pitch, _videoMode.screenWidth, _videoMode.screenHeight, _maxExtraPixels);
}
origSurf = _screen;
diff --git a/graphics/scalerplugin.cpp b/graphics/scalerplugin.cpp
index e7f316571e7..97b4a4da71f 100644
--- a/graphics/scalerplugin.cpp
+++ b/graphics/scalerplugin.cpp
@@ -67,7 +67,7 @@ SourceScaler::~SourceScaler() {
_bufferedOutput.free();
}
-void SourceScaler::setSource(const byte *src, uint pitch, int width, int height, int padding) {
+void SourceScaler::setSource(uint pitch, int width, int height, int padding) {
if (_oldSrc != NULL)
delete[] _oldSrc;
diff --git a/graphics/scalerplugin.h b/graphics/scalerplugin.h
index 463d4fb0d20..13f6998915d 100644
--- a/graphics/scalerplugin.h
+++ b/graphics/scalerplugin.h
@@ -78,7 +78,7 @@ public:
* @param padding The number of pixels on the border (Used to prevent memory access crashes)
* @param type The surface type. This source will only be used when calling oldSrcScale with the same type.
*/
- virtual void setSource(const byte *src, uint pitch, int width, int height, int padding) {
+ virtual void setSource(uint pitch, int width, int height, int padding) {
// Should not be called unless overriden
assert(0);
}
@@ -116,7 +116,7 @@ public:
SourceScaler(const Graphics::PixelFormat &format);
virtual ~SourceScaler();
- virtual void setSource(const byte *src, uint pitch, int width, int height, int padding) final;
+ virtual void setSource(uint pitch, int width, int height, int padding) final;
virtual void enableSource(bool enable) final { _enable = enable; }
Commit: caaddab19b596ea8ef8be06a9c09c280b4b88802
https://github.com/scummvm/scummvm/commit/caaddab19b596ea8ef8be06a9c09c280b4b88802
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2026-11-21T17:51:02+01:00
Commit Message:
SURFACESDL: Disable source image use in scaler while clearing overlay
This avoids black overlay when using the edge scaler.
Changed paths:
backends/graphics/surfacesdl/surfacesdl-graphics.cpp
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index 5f24535e8f5..9be951fce44 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -2019,12 +2019,20 @@ void SurfaceSdlGraphicsManager::clearOverlay() {
}
}
+ // We use a different buffer as a destination so we can't rely on the N-1 image
+ // It would be the same as the last scaled image and make a black screen for scaler making use of it (Edge scaler).
+ if (_useOldSrc) {
+ _scaler->enableSource(false);
+ }
#if SDL_VERSION_ATLEAST(3, 0, 0)
_scaler->scale((byte *)(_tmpscreen->pixels) + _maxExtraPixels * _tmpscreen->pitch + _maxExtraPixels * pixelFormatDetails->bytes_per_pixel, _tmpscreen->pitch,
#else
_scaler->scale((byte *)(_tmpscreen->pixels) + _maxExtraPixels * _tmpscreen->pitch + _maxExtraPixels * _tmpscreen->format->BytesPerPixel, _tmpscreen->pitch,
#endif
(byte *)_overlayscreen->pixels, _overlayscreen->pitch, _videoMode.screenWidth, _videoMode.screenHeight, 0, 0);
+ if (_useOldSrc) {
+ _scaler->enableSource(true);
+ }
#ifdef USE_ASPECT
if (_videoMode.aspectRatioCorrection)
More information about the Scummvm-git-logs
mailing list