src/core/winrt/SDL_winrtapp_direct3d.cpp
changeset 8679 dd52820b7f5c
parent 8678 7149b02f106b
child 8755 f2fc45874b9c
     1.1 --- a/src/core/winrt/SDL_winrtapp_direct3d.cpp	Mon Mar 24 22:12:38 2014 -0400
     1.2 +++ b/src/core/winrt/SDL_winrtapp_direct3d.cpp	Mon Mar 24 22:51:03 2014 -0400
     1.3 @@ -70,6 +70,13 @@
     1.4  #include "SDL_winrtapp_common.h"
     1.5  #include "SDL_winrtapp_direct3d.h"
     1.6  
     1.7 +#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED
     1.8 +/* Calling IDXGIDevice3::Trim on the active Direct3D 11.x device is necessary
     1.9 + * when Windows 8.1 apps are about to get suspended.
    1.10 + */
    1.11 +extern "C" void D3D11_Trim(SDL_Renderer *);
    1.12 +#endif
    1.13 +
    1.14  
    1.15  // Compile-time debugging options:
    1.16  // To enable, uncomment; to disable, comment them out.
    1.17 @@ -616,6 +623,18 @@
    1.18          // WinRT.
    1.19          SDL_SendAppEvent(SDL_APP_DIDENTERBACKGROUND);
    1.20  
    1.21 +        // Let the Direct3D 11 renderer prepare for the app to be backgrounded.
    1.22 +        // This is necessary for Windows 8.1, possibly elsewhere in the future.
    1.23 +        // More details at: http://msdn.microsoft.com/en-us/library/windows/apps/Hh994929.aspx
    1.24 +#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED
    1.25 +        if (WINRT_GlobalSDLWindow) {
    1.26 +            SDL_Renderer * renderer = SDL_GetRenderer(WINRT_GlobalSDLWindow);
    1.27 +            if (renderer && (SDL_strcmp(renderer->info.name, "direct3d11") == 0)) {
    1.28 +                D3D11_Trim(renderer);
    1.29 +            }
    1.30 +        }
    1.31 +#endif
    1.32 +
    1.33          deferral->Complete();
    1.34      });
    1.35  }