1
0
Fork 0

refine 4315 a bit. At least on windows, an overlay needs to be locked before the real pitch data is returned instead of a wild pointer

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4334
This commit is contained in:
Peter Veenstra 2020-02-25 20:53:02 +00:00
parent 5afd7057f3
commit 9ab84c503d

View file

@ -900,13 +900,18 @@ dosurface:
if (!(flags & GFX_CAN_32) || (flags & GFX_RGBONLY)) goto dosurface;
if (!GFX_SetupSurfaceScaled(0,0)) goto dosurface;
sdl.overlay = SDL_CreateYUVOverlay(width * 2, height, SDL_UYVY_OVERLAY, sdl.surface);
if (sdl.overlay && sdl.overlay->pitches[0] < 4 * width) {
// We get a distorted image in this case. Cleanup and go to surface.
LOG_MSG("SDL: overlay pitch is too small. (%u < %" sBitfs(u) ")", sdl.overlay->pitches[0], width * 4);
SDL_FreeYUVOverlay(sdl.overlay);
sdl.overlay = 0;
if (sdl.overlay && SDL_LockYUVOverlay(sdl.overlay) == 0) {
//Need to lock in order to get real pitchdata (at least on windows with dx backend)
if (sdl.overlay->pitches[0] < 4 * width) {
// We get a distorted image in this case. Cleanup and go to surface.
LOG_MSG("SDL: overlay pitch is too small. (%u < %" sBitfs(u) ")", sdl.overlay->pitches[0], width * 4);
SDL_UnlockYUVOverlay(sdl.overlay);
SDL_FreeYUVOverlay(sdl.overlay);
sdl.overlay = 0;
} else SDL_UnlockYUVOverlay(sdl.overlay);
}
if (!sdl.overlay) {
LOG_MSG("SDL: Failed to create overlay, switching back to surface.");
goto dosurface;