Implemented ClipRect APIs.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 11 Apr 2013 00:20:35 -0400
changeset 2413ff8808236a
parent 23 171a5eadaca3
child 25 2dfd8573dba0
Implemented ClipRect APIs.
src/SDL12_compat.c
src/SDL20_syms.h
     1.1 --- a/src/SDL12_compat.c	Wed Apr 10 23:13:20 2013 -0400
     1.2 +++ b/src/SDL12_compat.c	Thu Apr 11 00:20:35 2013 -0400
     1.3 @@ -44,7 +44,6 @@
     1.4  // !!! IMPLEMENT_ME SDL_GL_SetAttribute
     1.5  // !!! IMPLEMENT_ME SDL_GL_Unlock
     1.6  // !!! IMPLEMENT_ME SDL_GL_UpdateRects
     1.7 -// !!! IMPLEMENT_ME SDL_GetClipRect
     1.8  // !!! IMPLEMENT_ME SDL_GetKeyName
     1.9  // !!! IMPLEMENT_ME SDL_GetKeyState
    1.10  // !!! IMPLEMENT_ME SDL_GetModState
    1.11 @@ -52,7 +51,6 @@
    1.12  // !!! IMPLEMENT_ME SDL_GetRelativeMouseState
    1.13  // !!! IMPLEMENT_ME SDL_LockSurface
    1.14  // !!! IMPLEMENT_ME SDL_LowerBlit
    1.15 -// !!! IMPLEMENT_ME SDL_SetClipRect
    1.16  // !!! IMPLEMENT_ME SDL_SetColorKey
    1.17  // !!! IMPLEMENT_ME SDL_SetModState
    1.18  // !!! IMPLEMENT_ME SDL_SoftStretch
    1.19 @@ -121,7 +119,7 @@
    1.20      Uint16 pitch;
    1.21      void *pixels;
    1.22      int offset;
    1.23 -    void *hwdata;
    1.24 +    SDL_Surface *hwdata; /* the real SDL 1.2 has an opaque pointer to a platform-specific thing here. */
    1.25      SDL_Rect clip_rect;
    1.26      Uint32 unused1;
    1.27      Uint32 locked;
    1.28 @@ -1012,7 +1010,7 @@
    1.29  void SDL_FreeSurface(SDL12_Surface *surface12)
    1.30  {
    1.31      if (surface12) {
    1.32 -        SDL20_FreeSurface((SDL_Surface *) surface12->hwdata);
    1.33 +        SDL20_FreeSurface(surface12->hwdata);
    1.34          if (surface12->format) {
    1.35              SDL20_free(surface12->format->palette);
    1.36              SDL20_free(surface12->format);
    1.37 @@ -1021,6 +1019,25 @@
    1.38      }
    1.39  }
    1.40  
    1.41 +void
    1.42 +SDL_GetClipRect(SDL12_Surface *surface12, SDL_Rect *rect)
    1.43 +{
    1.44 +    if (surface12 && rect)
    1.45 +	    SDL_memcpy(rect, &surface12->clip_rect, sizeof (SDL_Rect));
    1.46 +}
    1.47 +
    1.48 +SDL_bool
    1.49 +SDL_SetClipRect(SDL12_Surface *surface12, const SDL_Rect *rect)
    1.50 +{
    1.51 +    SDL_bool retval = SDL_FALSE;
    1.52 +    if (surface12)
    1.53 +    {
    1.54 +        retval = SDL20_SetClipRect(surface12->hwdata, rect);
    1.55 +        SDL20_GetClipRect(surface12->hwdata, &surface12->clip_rect);
    1.56 +    }
    1.57 +    return retval;
    1.58 +}
    1.59 +
    1.60  static SDL_PixelFormat *
    1.61  PixelFormat12to20(SDL_PixelFormat *format20, SDL_Palette *palette20, SDL12_PixelFormat *format12)
    1.62  {
     2.1 --- a/src/SDL20_syms.h	Wed Apr 10 23:13:20 2013 -0400
     2.2 +++ b/src/SDL20_syms.h	Thu Apr 11 00:20:35 2013 -0400
     2.3 @@ -45,6 +45,8 @@
     2.4  SDL20_SYM(int,SaveBMP_RW,(SDL_Surface *a, SDL_RWops *b, int c),(a,b,c),return)
     2.5  SDL20_SYM_PASSTHROUGH(int,GL_LoadLibrary,(const char *a),(a),return)
     2.6  SDL20_SYM_PASSTHROUGH(void *,GL_GetProcAddress,(const char *a),(a),return)
     2.7 +SDL20_SYM(void,GetClipRect,(SDL_Surface *a, SDL_Rect *b),(a,b),)
     2.8 +SDL20_SYM(SDL_bool,SetClipRect,(SDL_Surface *a, const SDL_Rect *b),(a,b),return)
     2.9  
    2.10  SDL20_SYM_PASSTHROUGH(int,ShowCursor,(int a),(a),return)
    2.11  SDL20_SYM(SDL_Cursor *,CreateCursor,(const Uint8 *a,const Uint8 *b,int c,int d,int e,int f),(a,b,c,d,e,f),return)