Skip to content

Commit

Permalink
Implement SDL_ConvertSurface and SDL_DisplayFormat.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Feb 18, 2019
1 parent 98a9e58 commit 21a0f7c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
29 changes: 24 additions & 5 deletions src/SDL12_compat.c
Expand Up @@ -50,10 +50,8 @@
// !!! IMPLEMENT_ME SDL_CDResume
// !!! IMPLEMENT_ME SDL_CDStatus
// !!! IMPLEMENT_ME SDL_CDStop
// !!! IMPLEMENT_ME SDL_ConvertSurface
// !!! IMPLEMENT_ME SDL_CreateYUVOverlay

// !!! IMPLEMENT_ME SDL_DisplayFormat
// !!! IMPLEMENT_ME SDL_DisplayFormatAlpha
// !!! IMPLEMENT_ME SDL_DisplayYUVOverlay
// !!! IMPLEMENT_ME SDL_EnableKeyRepeat
Expand Down Expand Up @@ -1952,12 +1950,33 @@ SDL_SetAlpha(SDL12_Surface * surface, Uint32 flag, Uint8 value)
return SDL20_Unsupported();
}

DECLSPEC SDL12_Surface * SDLCALL
SDL_ConvertSurface(SDL12_Surface *src12, const SDL12_PixelFormat *format12, Uint32 flags12)
{
Uint32 flags20 = 0;
SDL_PixelFormat format20;
SDL_Palette palette20;
SDL_Surface *surface20;
SDL12_Surface *retval = NULL;

if (flags12 & SDL12_PREALLOC) flags20 |= SDL_PREALLOC;
if (flags12 & SDL12_RLEACCEL) flags20 |= SDL_RLEACCEL;

surface20 = SDL20_ConvertSurface(src12->surface20, PixelFormat12to20(&format20, &palette20, format12), flags20);
if (surface20) {
retval = Surface20to12(surface20);
if (!retval) {
SDL20_FreeSurface(surface20);
}
}
return retval;
}

DECLSPEC SDL12_Surface * SDLCALL
SDL_DisplayFormat(SDL12_Surface *surface12)
{
FIXME("write me");
SDL20_Unsupported();
return NULL;
const Uint32 flags = surface12->flags & (SDL12_SRCCOLORKEY|SDL12_SRCALPHA|SDL12_RLEACCELOK);
return SDL_ConvertSurface(surface12, VideoSurface12->format, flags);
}

DECLSPEC SDL12_Surface * SDLCALL
Expand Down
2 changes: 2 additions & 0 deletions src/SDL20_include_wrapper.h
Expand Up @@ -85,6 +85,7 @@
#define SDL_LoadWAV_RW IGNORE_THIS_VERSION_OF_SDL_LoadWAV_RW
#define SDL_UpperBlit IGNORE_THIS_VERSION_OF_SDL_UpperBlit
#define SDL_LowerBlit IGNORE_THIS_VERSION_OF_SDL_LowerBlit
#define SDL_ConvertSurface IGNORE_THIS_VERSION_OF_SDL_ConvertSurface

#define BUILD_SDL 1
#include "SDL.h"
Expand Down Expand Up @@ -147,6 +148,7 @@
#undef SDL_LoadWAV_RW
#undef SDL_UpperBlit
#undef SDL_LowerBlit
#undef SDL_ConvertSurface

#ifdef SDL_BlitSurface
#undef SDL_BlitSurface
Expand Down
1 change: 1 addition & 0 deletions src/SDL20_syms.h
Expand Up @@ -87,6 +87,7 @@ SDL20_SYM(void,FreeFormat,(SDL_PixelFormat *a),(a),)
SDL20_SYM(SDL_Surface *,CreateRGBSurface,(Uint32 a, int b, int c, int d, Uint32 e, Uint32 f, Uint32 g, Uint32 h),(a,b,c,d,e,f,g,h),return)
SDL20_SYM(SDL_Surface *,CreateRGBSurfaceFrom,(void *a, int b, int c, int d, int e, Uint32 f, Uint32 g, Uint32 h, Uint32 i),(a,b,c,d,e,f,g,h,i),return)
SDL20_SYM(SDL_Surface *,CreateRGBSurfaceWithFormat,(Uint32 a, int b, int c, int d, Uint32 e),(a,b,c,d,e),return)
SDL20_SYM(SDL_Surface *,ConvertSurface,(SDL_Surface *a, const SDL_PixelFormat *b, Uint32 c),(a,b,c),return)
SDL20_SYM(int,UpperBlit,(SDL_Surface *a,const SDL_Rect *b,SDL_Surface *c, SDL_Rect *d),(a,b,c,d),return)
SDL20_SYM(int,LowerBlit,(SDL_Surface *a,const SDL_Rect *b,SDL_Surface *c, SDL_Rect *d),(a,b,c,d),return)
SDL20_SYM(void,FreeSurface,(SDL_Surface *a),(a),)
Expand Down

0 comments on commit 21a0f7c

Please sign in to comment.