KEMBAR78
SURFACESDL: Fix calculating the mouse dirty rectangle by ccawley2011 · Pull Request #4625 · scummvm/scummvm · GitHub
Skip to content

Conversation

@ccawley2011
Copy link
Member

No description provided.

@bluegr
Copy link
Member

bluegr commented Jan 15, 2023

Can you provide some more information? What has been fixed here? Can you provide a use case? Could you provide some screenshots that illustrate the problem?

@ccawley2011
Copy link
Member Author

Some background information can be found in this issue: https://bugs.scummvm.org/ticket/14024

This isn't a problem with SDL2 since the list of dirty rectangles is ignored by the SDL_UpdateRects replacement, but I'm not sure why it was only visible with 32-bit displays. This PR attempts to fix the issue by moving the addition of both mouse dirty rects to before the game screen or overlay is blitted.

@ccawley2011 ccawley2011 requested a review from phcoder January 16, 2023 00:23
@ccawley2011 ccawley2011 force-pushed the mouse-cursor-dirty-rect branch from bc4e90c to 9e7915f Compare January 16, 2023 01:25
@sev-
Copy link
Member

sev- commented Feb 7, 2023

Thank you!

@sev- sev- merged commit 2caa338 into scummvm:master Feb 7, 2023
@ccawley2011 ccawley2011 deleted the mouse-cursor-dirty-rect branch February 8, 2023 01:06
@lotharsm
Copy link
Member

lotharsm commented Feb 11, 2023

Unfortunately, it seems that this commit introduced (or uncovered) a regression either in SURFACESDL itself or the KYRA engine: https://bugs.scummvm.org/ticket/14147


dst.x += _currentShakeXOffset;
dst.y += _currentShakeYOffset;
dst.x = _mouseNextRect.x + _currentShakeXOffset;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is added twice: one in undrawMouse and now here.

// scaled and aspect-ratio corrected.

if (_mouseLastRect.w != 0 && _mouseLastRect.h != 0)
addDirtyRect(_mouseLastRect.x - hotX, _mouseLastRect.y - hotY, _mouseLastRect.w, _mouseLastRect.h, _overlayInGUI);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if hotX has changed between last frame and now, this calculation is invalid.
I believe it causes bug https://bugs.scummvm.org/ticket/14147

I wonder if everything should be calculated here and not in drawMouse

@moralrecordings
Copy link
Contributor

moralrecordings commented Mar 5, 2023

@ccawley2011 could you give an example of how to reproduce the issue with a 32-bit game? The bit making internUpdateScreen() call undrawMouse() every time is causing performance issues in Director (there's a lot of ad-hoc places which can call updateScreen, relying a bit on the assumption that it's near-zero cost when there's no dirty rects).

@ccawley2011
Copy link
Member Author

@ccawley2011 could you give an example of how to reproduce the issue with a 32-bit game? The bit making internUpdateScreen() call undrawMouse() every time is causing performance issues in Director (there's a lot of ad-hoc places which can call updateScreen, relying a bit on the assumption that it's near-zero cost when there's no dirty rects).

It can be replicated in the launcher when compiling on Linux with SDL 1.2 and changing the call to SDL_SetVideoMode to use 32bpp instead of 16bpp or 8bpp - without this PR, you should be able to notice the cursor graphic getting clipped when moving the mouse from side to side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants