Fixed bug 5113 - SDL_UpdateWindowSurfaceRects BitBlt the entire surface on Win32
authorSam Lantinga <slouken@libsdl.org>
Fri, 29 May 2020 21:26:32 -0700
changeset 13884ba1ed72249c0
parent 13883 44fbeca0872e
child 13885 d495c4d822cc
Fixed bug 5113 - SDL_UpdateWindowSurfaceRects BitBlt the entire surface on Win32

Ryan C. Gordon

As discussed here:
https://discourse.libsdl.org/t/question-about-implementation-of-sdl-updatewindowsurfacerects/27561

"As you can see this function [WIN_UpdateWindowFramebuffer, in src/video/windows/SDL_windowsframebuffer.c] calls BitBlt on entire screen, even though it accepts the rects. Rects variable is not even used in this function at all. Now my question is why is that the case?"
src/video/windows/SDL_windowsframebuffer.c
     1.1 --- a/src/video/windows/SDL_windowsframebuffer.c	Fri May 29 21:22:11 2020 -0700
     1.2 +++ b/src/video/windows/SDL_windowsframebuffer.c	Fri May 29 21:26:32 2020 -0700
     1.3 @@ -99,8 +99,12 @@
     1.4  int WIN_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects)
     1.5  {
     1.6      SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
     1.7 +	int i;
     1.8  
     1.9 -    BitBlt(data->hdc, 0, 0, window->w, window->h, data->mdc, 0, 0, SRCCOPY);
    1.10 +    for (i = 0; i < numrects; ++i) {
    1.11 +        BitBlt(data->hdc, rects[i].x, rects[i].y, rects[i].w, rects[i].h,
    1.12 +               data->mdc, rects[i].x, rects[i].y, SRCCOPY);
    1.13 +    }
    1.14      return 0;
    1.15  }
    1.16