alternative PR#11

This commit is contained in:
kanjitalk755 2019-02-26 14:57:02 +09:00
parent f67fe9671b
commit 1b6a63edf7

View File

@ -875,10 +875,6 @@ static int present_sdl_video()
SDL_SetRenderDrawColor(sdl_renderer, 0, 0, 0, 0); // Use black SDL_SetRenderDrawColor(sdl_renderer, 0, 0, 0, 0); // Use black
SDL_RenderClear(sdl_renderer); // Clear the display SDL_RenderClear(sdl_renderer); // Clear the display
// We're about to work with sdl_update_video_rect, so stop other threads from
// modifying it!
SDL_LockMutex(sdl_update_video_mutex);
// Convert from the guest OS' pixel format, to the host OS' texture, if necessary. // Convert from the guest OS' pixel format, to the host OS' texture, if necessary.
if (host_surface != guest_surface && if (host_surface != guest_surface &&
host_surface != NULL && host_surface != NULL &&
@ -886,14 +882,17 @@ static int present_sdl_video()
{ {
SDL_Rect destRect = sdl_update_video_rect; SDL_Rect destRect = sdl_update_video_rect;
LOCK_PALETTE; LOCK_PALETTE;
SDL_LockMutex(sdl_update_video_mutex);
int result = SDL_BlitSurface(guest_surface, &sdl_update_video_rect, host_surface, &destRect); int result = SDL_BlitSurface(guest_surface, &sdl_update_video_rect, host_surface, &destRect);
SDL_UnlockMutex(sdl_update_video_mutex);
UNLOCK_PALETTE; UNLOCK_PALETTE;
if (result != 0) { if (result != 0) return -1;
SDL_UnlockMutex(sdl_update_video_mutex);
return -1;
}
} }
// We're about to work with sdl_update_video_rect, so stop other threads from
// modifying it!
SDL_LockMutex(sdl_update_video_mutex);
// Update the host OS' texture // Update the host OS' texture
void * srcPixels = (void *)((uint8_t *)host_surface->pixels + void * srcPixels = (void *)((uint8_t *)host_surface->pixels +
sdl_update_video_rect.y * host_surface->pitch + sdl_update_video_rect.y * host_surface->pitch +