Fixed 4669 - Using the software SDL_Renderer on Android leads to GL errors & black screen when window resizes

Sylvain

I think what happening with the software renderer is:

* you're somehow in background (so texture creation is not possible)
* it resizes and wants to push a SDL_WINDOWEVENT_SIZE_CHANGED
It call:
https://hg.libsdl.org/SDL/file/a010811d40dd/src/render/SDL_render.c#l683
* GetOutputSize
* SW_GetOutputSize
* SW_ActivateRenderer
* SDL_GetWindowSurface
* SDL_CreateWindowFramebuffer which is mapped to SDL_CreateWindowTexture
and it ends up re-creating the surface/a texture, while being in background
This commit is contained in:
Sam Lantinga 2019-06-18 10:08:19 -07:00
parent e96d4760ac
commit 5dcac4ccdf

View File

@ -82,21 +82,26 @@ SW_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
static int static int
SW_GetOutputSize(SDL_Renderer * renderer, int *w, int *h) SW_GetOutputSize(SDL_Renderer * renderer, int *w, int *h)
{ {
SDL_Surface *surface = SW_ActivateRenderer(renderer); SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
if (surface) { if (data->surface) {
if (w) { if (w) {
*w = surface->w; *w = data->surface->w;
} }
if (h) { if (h) {
*h = surface->h; *h = data->surface->h;
} }
return 0; return 0;
} else { }
if (renderer->window) {
SDL_GetWindowSize(renderer->window, w, h);
return 0;
}
SDL_SetError("Software renderer doesn't have an output surface"); SDL_SetError("Software renderer doesn't have an output surface");
return -1; return -1;
} }
}
static int static int
SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)