src/SDL12_compat.c
changeset 96 4735fcd0fd8a
parent 95 2fa2951e5c96
child 97 45e4b37e14f3
     1.1 --- a/src/SDL12_compat.c	Fri Mar 01 10:53:25 2019 -0500
     1.2 +++ b/src/SDL12_compat.c	Fri Mar 01 23:52:32 2019 -0500
     1.3 @@ -716,6 +716,7 @@
     1.4  static SDL_Renderer *VideoRenderer20 = NULL;
     1.5  static SDL_Texture *VideoTexture20 = NULL;
     1.6  static SDL12_Surface *VideoSurface12 = NULL;
     1.7 +static SDL_bool VideoSurfaceUpdated = SDL_FALSE;
     1.8  static SDL_Surface *VideoConvertSurface20 = NULL;
     1.9  static SDL_GLContext *VideoGLContext20 = NULL;
    1.10  static char *WindowTitle = NULL;
    1.11 @@ -1312,7 +1313,7 @@
    1.12  {
    1.13      EventQueueType *next;
    1.14  
    1.15 -    SDL20_PumpEvents();  /* this will run our filter and build our 1.2 queue. */
    1.16 +    SDL_PumpEvents();  /* this will run our filter and build our 1.2 queue. */
    1.17  
    1.18      if (EventQueueHead == NULL)
    1.19          return 0;  /* no events at the moment. */
    1.20 @@ -2735,6 +2736,8 @@
    1.21  
    1.22      FIXME("setup screen saver");
    1.23  
    1.24 +    VideoSurfaceUpdated = SDL_FALSE;
    1.25 +
    1.26      return VideoSurface12;
    1.27  }
    1.28  
    1.29 @@ -2880,6 +2883,7 @@
    1.30      SDL20_UnlockTexture(VideoTexture20);
    1.31      SDL20_RenderCopy(VideoRenderer20, VideoTexture20, NULL, NULL);
    1.32      SDL20_RenderPresent(VideoRenderer20);
    1.33 +    VideoSurfaceUpdated = SDL_FALSE;
    1.34  }
    1.35  
    1.36  DECLSPEC void SDLCALL
    1.37 @@ -2892,7 +2896,26 @@
    1.38          return;
    1.39      }
    1.40  
    1.41 -    /* everything else is marked SDL12_DOUBLEBUF and is a no-op here. */
    1.42 +    // everything else is marked SDL12_DOUBLEBUF and SHOULD BE a no-op here,
    1.43 +    //  but in practice most apps never got a double-buffered surface and
    1.44 +    //  don't handle it correctly, so we have to work around it.
    1.45 +    if (surface12 == VideoSurface12) {
    1.46 +        SDL_bool whole_screen = SDL_FALSE;
    1.47 +        if (numrects == 1) {
    1.48 +            const SDL12_Rect *r = rects12;
    1.49 +            if (!r->x && !r->y && !r->w && !r->h) {
    1.50 +                whole_screen = SDL_TRUE;
    1.51 +            } else if (!r->x && !r->y && (r->w == surface12->w) && (r->h == surface12->h)) {
    1.52 +                whole_screen = SDL_TRUE;
    1.53 +            }
    1.54 +        }
    1.55 +                
    1.56 +        if (whole_screen) {  
    1.57 +            PresentScreen();  // flip it now.
    1.58 +        } else {
    1.59 +            VideoSurfaceUpdated = SDL_TRUE;  // flip it later.
    1.60 +        }
    1.61 +    }
    1.62  }
    1.63  
    1.64  DECLSPEC void SDLCALL
    1.65 @@ -2923,6 +2946,18 @@
    1.66  }
    1.67  
    1.68  DECLSPEC void SDLCALL
    1.69 +SDL_PumpEvents(void)
    1.70 +{
    1.71 +    // If the app is doing dirty rectangles, we set a flag and present the
    1.72 +    //  screen surface when they pump for new events, which we consider a
    1.73 +    //  sign that they are done rendering for the current frame.
    1.74 +    if (VideoSurfaceUpdated) {
    1.75 +        PresentScreen();
    1.76 +    }
    1.77 +    SDL20_PumpEvents();
    1.78 +}
    1.79 +
    1.80 +DECLSPEC void SDLCALL
    1.81  SDL_WM_SetCaption(const char *title, const char *icon)
    1.82  {
    1.83      if (WindowTitle) {