Fixed bug 3981 - Inverted logic bug in SDL_renderer "overscan" feature
authorSam Lantinga <slouken@libsdl.org>
Tue, 12 Dec 2017 16:34:16 -0800
changeset 11771cb68160b3ace
parent 11770 58a69c196061
child 11772 cf9c6a79123f
Fixed bug 3981 - Inverted logic bug in SDL_renderer "overscan" feature

Eric wing

There is a tiny bug in the new overscan code for the SDL_renderer.

In SDL_renderer.c, line 1265, the if check for SDL_strcasecmp with "direct3d" needs to be inverted.

Instead of:
if(SDL_strcasecmp("direct3d", SDL_GetCurrentVideoDriver())) {

It should be:
if(0 == SDL_strcasecmp("direct3d", SDL_GetCurrentVideoDriver())) {

This bug causes the "overscan" mode to pretty much be completely ignored in all cases and all things remain letterboxed (as before the feature).
src/render/SDL_render.c
     1.1 --- a/src/render/SDL_render.c	Tue Dec 12 16:25:43 2017 -0800
     1.2 +++ b/src/render/SDL_render.c	Tue Dec 12 16:34:16 2017 -0800
     1.3 @@ -1248,7 +1248,7 @@
     1.4      SDL_Rect viewport;
     1.5      /* 0 is for letterbox, 1 is for overscan */
     1.6      int scale_policy = 0;
     1.7 -    const char *hint = SDL_GetHint(SDL_HINT_RENDER_LOGICAL_SIZE_MODE);
     1.8 +    const char *hint;
     1.9  
    1.10      if (!renderer->logical_w || !renderer->logical_h) {
    1.11          return 0;
    1.12 @@ -1257,23 +1257,20 @@
    1.13          return -1;
    1.14      }
    1.15  
    1.16 -    if (!hint) {
    1.17 -        scale_policy = 0;
    1.18 -    } else if ( *hint == '1' || SDL_strcasecmp(hint, "overscan") == 0)  {
    1.19 -        /* Unfortunately, Direct3D 9 does't support negative viewport numbers
    1.20 -        which the main overscan implementation relies on.
    1.21 -        D3D11 does support negative values and uses a different id string
    1.22 -        so overscan will work for D3D11.
    1.23 +    hint = SDL_GetHint(SDL_HINT_RENDER_LOGICAL_SIZE_MODE);
    1.24 +    if (hint && (*hint == '1' || SDL_strcasecmp(hint, "overscan") == 0))  {
    1.25 +        SDL_bool overscan_supported = SDL_TRUE;
    1.26 +        /* Unfortunately, Direct3D 9 doesn't support negative viewport numbers
    1.27 +           which the overscan implementation relies on.
    1.28          */
    1.29 -        if(SDL_strcasecmp("direct3d", SDL_GetCurrentVideoDriver())) {
    1.30 -            scale_policy = 0;
    1.31 -        } else {
    1.32 +        if (SDL_strcasecmp(SDL_GetCurrentVideoDriver(), "direct3d") == 0) {
    1.33 +            overscan_supported = SDL_FALSE;
    1.34 +        }
    1.35 +        if (overscan_supported) {
    1.36              scale_policy = 1;
    1.37          }
    1.38 -    } else {
    1.39 -        scale_policy = 0;
    1.40      }
    1.41 -    
    1.42 +
    1.43      want_aspect = (float)renderer->logical_w / renderer->logical_h;
    1.44      real_aspect = (float)w / h;
    1.45