Fixed 4669 - Using the software SDL_Renderer on Android leads to GL errors & black screen when window resizes
authorSam Lantinga <slouken@libsdl.org>
Tue, 18 Jun 2019 10:08:19 -0700
changeset 128811e71522317eb
parent 12880 e46fc7b6d880
child 12882 d629b4244b87
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/45b56ed51919/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
src/render/software/SDL_render_sw.c
     1.1 --- a/src/render/software/SDL_render_sw.c	Tue Jun 18 18:53:58 2019 +0200
     1.2 +++ b/src/render/software/SDL_render_sw.c	Tue Jun 18 10:08:19 2019 -0700
     1.3 @@ -82,20 +82,25 @@
     1.4  static int
     1.5  SW_GetOutputSize(SDL_Renderer * renderer, int *w, int *h)
     1.6  {
     1.7 -    SDL_Surface *surface = SW_ActivateRenderer(renderer);
     1.8 +    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
     1.9  
    1.10 -    if (surface) {
    1.11 +    if (data->surface) {
    1.12          if (w) {
    1.13 -            *w = surface->w;
    1.14 +            *w = data->surface->w;
    1.15          }
    1.16          if (h) {
    1.17 -            *h = surface->h;
    1.18 +            *h = data->surface->h;
    1.19          }
    1.20          return 0;
    1.21 -    } else {
    1.22 -        SDL_SetError("Software renderer doesn't have an output surface");
    1.23 -        return -1;
    1.24      }
    1.25 +
    1.26 +    if (renderer->window) {
    1.27 +        SDL_GetWindowSize(renderer->window, w, h);
    1.28 +        return 0;
    1.29 +    }
    1.30 +
    1.31 +    SDL_SetError("Software renderer doesn't have an output surface");
    1.32 +    return -1;
    1.33  }
    1.34  
    1.35  static int
    1.36 @@ -179,7 +184,7 @@
    1.37  {
    1.38      SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
    1.39  
    1.40 -    if (texture ) {
    1.41 +    if (texture) {
    1.42          data->surface = (SDL_Surface *) texture->driverdata;
    1.43      } else {
    1.44          data->surface = data->window;