simplify SDL_DUMMY/OFFSCREEN_CreateWindowFramebuffer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
diff --git a/src/video/dummy/SDL_nullframebuffer.c b/src/video/dummy/SDL_nullframebuffer.c
index f11ee3f..dd7cbbd 100644
--- a/src/video/dummy/SDL_nullframebuffer.c
+++ b/src/video/dummy/SDL_nullframebuffer.c
@@ -33,17 +33,13 @@ int SDL_DUMMY_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * forma
SDL_Surface *surface;
const Uint32 surface_format = SDL_PIXELFORMAT_RGB888;
int w, h;
- int bpp;
- Uint32 Rmask, Gmask, Bmask, Amask;
/* Free the old framebuffer surface */
- surface = (SDL_Surface *) SDL_GetWindowData(window, DUMMY_SURFACE);
- SDL_FreeSurface(surface);
+ SDL_DUMMY_DestroyWindowFramebuffer(_this, window);
/* Create a new one */
- SDL_PixelFormatEnumToMasks(surface_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask);
SDL_GetWindowSize(window, &w, &h);
- surface = SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask);
+ surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, surface_format);
if (!surface) {
return -1;
}
diff --git a/src/video/offscreen/SDL_offscreenframebuffer.c b/src/video/offscreen/SDL_offscreenframebuffer.c
index 9b77489..3ca57e8 100644
--- a/src/video/offscreen/SDL_offscreenframebuffer.c
+++ b/src/video/offscreen/SDL_offscreenframebuffer.c
@@ -34,17 +34,13 @@ int SDL_OFFSCREEN_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * f
SDL_Surface *surface;
const Uint32 surface_format = SDL_PIXELFORMAT_RGB888;
int w, h;
- int bpp;
- Uint32 Rmask, Gmask, Bmask, Amask;
/* Free the old framebuffer surface */
- surface = (SDL_Surface *) SDL_GetWindowData(window, OFFSCREEN_SURFACE);
- SDL_FreeSurface(surface);
+ SDL_OFFSCREEN_DestroyWindowFramebuffer(_this, window);
/* Create a new one */
- SDL_PixelFormatEnumToMasks(surface_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask);
SDL_GetWindowSize(window, &w, &h);
- surface = SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask);
+ surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, surface_format);
if (!surface) {
return -1;
}