|
@@ -1884,12 +1884,7 @@ int SDL_RecreateWindow(SDL_Window *window, Uint32 flags)
|
|
|
}
|
|
|
|
|
|
/* Tear down the old native window */
|
|
|
- if (window->surface) {
|
|
|
- window->surface->flags &= ~SDL_DONTFREE;
|
|
|
- SDL_FreeSurface(window->surface);
|
|
|
- window->surface = NULL;
|
|
|
- window->surface_valid = SDL_FALSE;
|
|
|
- }
|
|
|
+ SDL_DestroyWindowSurface(window);
|
|
|
|
|
|
if (_this->checked_texture_framebuffer) { /* never checked? No framebuffer to destroy. Don't risk calling the wrong implementation. */
|
|
|
if (_this->DestroyWindowFramebuffer) {
|
|
@@ -2670,16 +2665,19 @@ static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window)
|
|
|
return SDL_CreateRGBSurfaceFrom(pixels, window->w, window->h, bpp, pitch, Rmask, Gmask, Bmask, Amask);
|
|
|
}
|
|
|
|
|
|
+SDL_bool SDL_HasWindowSurface(SDL_Window *window)
|
|
|
+{
|
|
|
+ CHECK_WINDOW_MAGIC(window, SDL_FALSE);
|
|
|
+
|
|
|
+ return window->surface ? SDL_TRUE : SDL_FALSE;
|
|
|
+}
|
|
|
+
|
|
|
SDL_Surface *SDL_GetWindowSurface(SDL_Window *window)
|
|
|
{
|
|
|
CHECK_WINDOW_MAGIC(window, NULL);
|
|
|
|
|
|
if (!window->surface_valid) {
|
|
|
- if (window->surface) {
|
|
|
- window->surface->flags &= ~SDL_DONTFREE;
|
|
|
- SDL_FreeSurface(window->surface);
|
|
|
- window->surface = NULL;
|
|
|
- }
|
|
|
+ SDL_DestroyWindowSurface(window);
|
|
|
window->surface = SDL_CreateWindowFramebuffer(window);
|
|
|
if (window->surface) {
|
|
|
window->surface_valid = SDL_TRUE;
|
|
@@ -2761,6 +2759,19 @@ int SDL_SetWindowOpacity(SDL_Window * window, float opacity)
|
|
|
return retval;
|
|
|
}
|
|
|
|
|
|
+int SDL_DestroyWindowSurface(SDL_Window *window)
|
|
|
+{
|
|
|
+ CHECK_WINDOW_MAGIC(window, -1);
|
|
|
+
|
|
|
+ if (window->surface) {
|
|
|
+ window->surface->flags &= ~SDL_DONTFREE;
|
|
|
+ SDL_DestroySurface(window->surface);
|
|
|
+ window->surface = NULL;
|
|
|
+ window->surface_valid = SDL_FALSE;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
int SDL_GetWindowOpacity(SDL_Window *window, float *out_opacity)
|
|
|
{
|
|
|
CHECK_WINDOW_MAGIC(window, -1);
|
|
@@ -3206,12 +3217,7 @@ void SDL_DestroyWindow(SDL_Window *window)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (window->surface) {
|
|
|
- window->surface->flags &= ~SDL_DONTFREE;
|
|
|
- SDL_FreeSurface(window->surface);
|
|
|
- window->surface = NULL;
|
|
|
- window->surface_valid = SDL_FALSE;
|
|
|
- }
|
|
|
+ SDL_DestroyWindowSurface(window);
|
|
|
if (_this->checked_texture_framebuffer) { /* never checked? No framebuffer to destroy. Don't risk calling the wrong implementation. */
|
|
|
if (_this->DestroyWindowFramebuffer) {
|
|
|
_this->DestroyWindowFramebuffer(_this, window);
|