Skip to content

Commit

Permalink
Deal with updating the screen surface when conversion isn't necessary.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Mar 1, 2019
1 parent 2908f39 commit 5bd5570
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/SDL12_compat.c
Expand Up @@ -2856,11 +2856,26 @@ PresentScreen(void)
}

FIXME("Maybe lock texture always, until present, if no conversion needed?");
VideoConvertSurface20->pixels = pixels;
VideoConvertSurface20->pitch = pitch;
SDL20_UpperBlit(VideoSurface12->surface20, NULL, VideoConvertSurface20, NULL);
VideoConvertSurface20->pixels = NULL;
VideoConvertSurface20->pitch = 0;
if (VideoConvertSurface20) {
VideoConvertSurface20->pixels = pixels;
VideoConvertSurface20->pitch = pitch;
SDL20_UpperBlit(VideoSurface12->surface20, NULL, VideoConvertSurface20, NULL);
VideoConvertSurface20->pixels = NULL;
VideoConvertSurface20->pitch = 0;
} else if (pitch == VideoSurface12->pitch) {
SDL_memcpy(pixels, VideoSurface12->pixels, pitch * VideoSurface12->h);
} else {
const int srcpitch = VideoSurface12->pitch;
const int cpy = SDL_min(srcpitch, pitch);
const int h = VideoSurface12->h;
char *dst = (char *) pixels;
char *src = (char *) VideoSurface12->pixels;
for (int i = 0; i < h; i++) {
SDL_memcpy(dst, src, cpy);
src += srcpitch;
dst += pitch;
}
}

SDL20_UnlockTexture(VideoTexture20);
SDL20_RenderCopy(VideoRenderer20, VideoTexture20, NULL, NULL);
Expand Down

0 comments on commit 5bd5570

Please sign in to comment.