libsdl-org / sdl12-compat

An SDL-1.2 compatibility layer that uses SDL 2.0 behind the scenes.
Other
193 stars 40 forks source link

DisplayYUVOverlay: Don't update screen surface if clean #280

Closed sulix closed 1 year ago

sulix commented 1 year ago

Currently, if there are multiple SDL_DisplayYUVOverlay() calls in a row, we force an SDL_Flip() between them, in order to make sure that the screen is updated. However, this results in the non-YUV video surface also being updated, even if it otherwise wouldn't be.

Instead, copy the code from all of the other places where we force an update of the screen, which checks if the surface is dirty, and if not calls PresentScreen() directly without updating the VideoSurface. (After checking we're in the correct thread, of course...)

Note that it's probably worth pulling the "force screen update" code out into a separate helper function, rather than copying it everywhere.

This hopefully fixes video artefacts in Alpha Centauri (bug #279)

vv221 commented 1 year ago

I should be able to give a try to this patch soon, I will share my feedback as soon as it’s done.

vv221 commented 1 year ago

I tested both current master: I get the artifacts reported in #279; and this patch: I do not get any artifact.

So it seems good to me, it does get rid of the screen artifacts on my setup.