src/SDL12_compat.c
changeset 71 7a5593f0cd40
parent 70 aa6bf2a4a8c3
child 72 d20d9d70694b
     1.1 --- a/src/SDL12_compat.c	Mon Feb 18 00:28:06 2019 -0500
     1.2 +++ b/src/SDL12_compat.c	Mon Feb 18 00:43:28 2019 -0500
     1.3 @@ -441,8 +441,6 @@
     1.4  static SDL12_Surface *VideoSurface12 = NULL;
     1.5  static SDL_Surface *VideoConvertSurface20 = NULL;
     1.6  static SDL_GLContext *VideoGLContext20 = NULL;
     1.7 -static int VideoNumDirtyRects = 0;
     1.8 -static SDL_Rect VideoDirtyRects[16];
     1.9  static char *WindowTitle = NULL;
    1.10  static char *WindowIconTitle = NULL;
    1.11  static SDL12_Surface *VideoIcon12;
    1.12 @@ -922,25 +920,12 @@
    1.13      return GetDriverName(SDL20_GetCurrentVideoDriver(), namebuf, maxlen);
    1.14  }
    1.15  
    1.16 -static void PresentScreen(void);
    1.17 -
    1.18 -DECLSPEC void SDLCALL
    1.19 -SDL_PumpEvents(void)
    1.20 -{
    1.21 -    /* catch things that want to do dirty rectangles but ignore DOUBLEBUF.
    1.22 -       Since we have to compose the whole scene at once, catch it in here. */
    1.23 -    if (VideoSurface12 && VideoNumDirtyRects) {
    1.24 -        PresentScreen();
    1.25 -    }
    1.26 -    SDL20_PumpEvents();
    1.27 -}
    1.28 -
    1.29  DECLSPEC int SDLCALL
    1.30  SDL_PollEvent(SDL12_Event *event12)
    1.31  {
    1.32      EventQueueType *next;
    1.33  
    1.34 -    SDL_PumpEvents();  /* this will run our filter and build our 1.2 queue. */
    1.35 +    SDL20_PumpEvents();  /* this will run our filter and build our 1.2 queue. */
    1.36  
    1.37      if (EventQueueHead == NULL)
    1.38          return 0;  /* no events at the moment. */
    1.39 @@ -1870,8 +1855,6 @@
    1.40          }
    1.41      }
    1.42  
    1.43 -    VideoNumDirtyRects = 0;
    1.44 -
    1.45      VideoSurface12->surface20->flags |= SDL_PREALLOC;
    1.46      VideoSurface12->flags |= SDL12_PREALLOC;
    1.47      VideoSurface12->pixels = VideoSurface12->surface20->pixels = NULL;
    1.48 @@ -1939,6 +1922,7 @@
    1.49          }
    1.50  
    1.51          VideoSurface12->flags &= ~SDL12_OPENGL;
    1.52 +        VideoSurface12->flags |= SDL12_DOUBLEBUF;
    1.53          VideoSurface12->surface20->pixels = SDL20_malloc(height * VideoSurface12->pitch);
    1.54          VideoSurface12->pixels = VideoSurface12->surface20->pixels;
    1.55          if (!VideoSurface12->pixels) {
    1.56 @@ -2031,13 +2015,8 @@
    1.57  {
    1.58      void *pixels = NULL;
    1.59      int pitch = 0;
    1.60 -    int i;
    1.61  
    1.62      SDL_assert(VideoSurface12 != NULL);
    1.63 -    SDL_assert(VideoNumDirtyRects > 0);  /* only called internally from places that add rects */
    1.64 -    SDL_assert(VideoNumDirtyRects <= SDL_arraysize(VideoDirtyRects));
    1.65 -
    1.66 -    FIXME("Maybe lock a subset of the texture if only one dirty rectangle?");
    1.67  
    1.68      if (SDL20_LockTexture(VideoTexture20, NULL, &pixels, &pitch) < 0) {
    1.69          return;  /* oh well */
    1.70 @@ -2046,46 +2025,18 @@
    1.71      FIXME("Maybe lock texture always, until present, if no conversion needed?");
    1.72      VideoConvertSurface20->pixels = pixels;
    1.73      VideoConvertSurface20->pitch = pitch;
    1.74 -
    1.75 -    for (i = 0; i < VideoNumDirtyRects; i++) {
    1.76 -        SDL20_UpperBlit(VideoSurface12->surface20, &VideoDirtyRects[i], VideoConvertSurface20, &VideoDirtyRects[i]);
    1.77 -    }
    1.78 -
    1.79 +    SDL20_UpperBlit(VideoSurface12->surface20, NULL, VideoConvertSurface20, NULL);
    1.80      VideoConvertSurface20->pixels = NULL;
    1.81      VideoConvertSurface20->pitch = 0;
    1.82 -    VideoNumDirtyRects = 0;
    1.83  
    1.84      SDL20_UnlockTexture(VideoTexture20);
    1.85      SDL20_RenderCopy(VideoRenderer20, VideoTexture20, NULL, NULL);
    1.86      SDL20_RenderPresent(VideoRenderer20);
    1.87  }
    1.88  
    1.89 -static void
    1.90 -AddDirtyRect(const SDL_Rect *r)
    1.91 -{
    1.92 -    const int sw = VideoSurface12->w;
    1.93 -    const int sh = VideoSurface12->h;
    1.94 -    FIXME("Clip against the surface geometry");
    1.95 -    if (r == NULL) {
    1.96 -        VideoNumDirtyRects = -1;  /* NULL == "replace whole screen" */
    1.97 -    } else if ((r->x <= 0) && (r->y <= 0) && (r->w >= VideoSurface12->w) && (r->h >= VideoSurface12->h)) {
    1.98 -        VideoNumDirtyRects = -1;  /* this rect covers whole screen */
    1.99 -    } else if (VideoNumDirtyRects >= SDL_arraysize(VideoDirtyRects)) {
   1.100 -        VideoNumDirtyRects = -1;  /* too many rects, just do it all */
   1.101 -    } else if ((r->x >= sw) || (r->y >= sh)) {
   1.102 -        return;  /* nothing to do */
   1.103 -    } else if (VideoNumDirtyRects >= 0) {
   1.104 -        FIXME("Clip against other rectangles?");
   1.105 -        SDL_memcpy(&VideoDirtyRects[VideoNumDirtyRects], r, sizeof (*r));
   1.106 -        VideoNumDirtyRects++;
   1.107 -    }
   1.108 -}
   1.109 -
   1.110  DECLSPEC void SDLCALL
   1.111  SDL_UpdateRects(SDL12_Surface *surface12, int numrects, SDL_Rect *rects)
   1.112  {
   1.113 -    int i;
   1.114 -
   1.115      /* strangely, SDL 1.2 doesn't check if surface12 is NULL before touching it */
   1.116      /* (UpdateRect, singular, does...) */
   1.117      if (surface12->flags & SDL12_OPENGL) {
   1.118 @@ -2093,11 +2044,7 @@
   1.119          return;
   1.120      }
   1.121  
   1.122 -    if (surface12 == VideoSurface12) {
   1.123 -        for (i = 0; i < numrects; i++) {
   1.124 -            AddDirtyRect(&rects[i]);
   1.125 -        }
   1.126 -    }
   1.127 +    /* everything else is marked SDL12_DOUBLEBUF and is a no-op here. */
   1.128  }
   1.129  
   1.130  DECLSPEC void SDLCALL
   1.131 @@ -2121,7 +2068,6 @@
   1.132      }
   1.133  
   1.134      if (surface12 == VideoSurface12) {
   1.135 -        AddDirtyRect(NULL);
   1.136          PresentScreen();
   1.137      }
   1.138