WinRT: made use of SDL's framebuffer emulation code, instead of the custom stuff; then removed SDL_winrtrenderer
authorDavid Ludwig <dludwig@pobox.com>
Sat, 09 Feb 2013 19:39:42 -0500
changeset 841743f837ba544b
parent 8416 17040ce2693d
child 8418 5230bba62cf2
WinRT: made use of SDL's framebuffer emulation code, instead of the custom stuff; then removed SDL_winrtrenderer
VisualC-WinPhone/SDL/SDL_VS2012-WinPhone.vcxproj
VisualC-WinPhone/SDL/SDL_VS2012-WinPhone.vcxproj.filters
VisualC-WinRT/SDL/SDL_VS2012-WinRT.vcxproj
VisualC-WinRT/SDL/SDL_VS2012-WinRT.vcxproj.filters
src/video/windowsrt/SDL_WinRTApp.cpp
src/video/windowsrt/SDL_WinRTApp.h
src/video/windowsrt/SDL_winrtframebuffer.cpp
src/video/windowsrt/SDL_winrtframebuffer_c.h
src/video/windowsrt/SDL_winrtrenderer.cpp
src/video/windowsrt/SDL_winrtrenderer.h
src/video/windowsrt/SDL_winrtvideo.cpp
     1.1 --- a/VisualC-WinPhone/SDL/SDL_VS2012-WinPhone.vcxproj	Sat Feb 09 18:58:13 2013 -0500
     1.2 +++ b/VisualC-WinPhone/SDL/SDL_VS2012-WinPhone.vcxproj	Sat Feb 09 19:39:42 2013 -0500
     1.3 @@ -248,9 +248,7 @@
     1.4      <ClInclude Include="..\..\src\video\windowsrt\SDLmain_WinRT_common.h" />
     1.5      <ClInclude Include="..\..\src\video\windowsrt\SDL_WinRTApp.h" />
     1.6      <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtevents_c.h" />
     1.7 -    <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtframebuffer_c.h" />
     1.8      <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtmouse.h" />
     1.9 -    <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtrenderer.h" />
    1.10      <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtvideo.h" />
    1.11    </ItemGroup>
    1.12    <ItemGroup>
    1.13 @@ -366,24 +364,12 @@
    1.14        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
    1.15        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
    1.16      </ClCompile>
    1.17 -    <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtframebuffer.cpp">
    1.18 -      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
    1.19 -      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
    1.20 -      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
    1.21 -      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
    1.22 -    </ClCompile>
    1.23      <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtmouse.cpp">
    1.24        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
    1.25        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
    1.26        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
    1.27        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
    1.28      </ClCompile>
    1.29 -    <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtrenderer.cpp">
    1.30 -      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
    1.31 -      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
    1.32 -      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
    1.33 -      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
    1.34 -    </ClCompile>
    1.35      <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtvideo.cpp">
    1.36        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
    1.37        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
     2.1 --- a/VisualC-WinPhone/SDL/SDL_VS2012-WinPhone.vcxproj.filters	Sat Feb 09 18:58:13 2013 -0500
     2.2 +++ b/VisualC-WinPhone/SDL/SDL_VS2012-WinPhone.vcxproj.filters	Sat Feb 09 19:39:42 2013 -0500
     2.3 @@ -333,15 +333,9 @@
     2.4      <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtevents_c.h">
     2.5        <Filter>Source Files</Filter>
     2.6      </ClInclude>
     2.7 -    <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtframebuffer_c.h">
     2.8 -      <Filter>Source Files</Filter>
     2.9 -    </ClInclude>
    2.10      <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtmouse.h">
    2.11        <Filter>Source Files</Filter>
    2.12      </ClInclude>
    2.13 -    <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtrenderer.h">
    2.14 -      <Filter>Source Files</Filter>
    2.15 -    </ClInclude>
    2.16      <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtvideo.h">
    2.17        <Filter>Source Files</Filter>
    2.18      </ClInclude>
    2.19 @@ -593,15 +587,9 @@
    2.20      <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtevents.cpp">
    2.21        <Filter>Source Files</Filter>
    2.22      </ClCompile>
    2.23 -    <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtframebuffer.cpp">
    2.24 -      <Filter>Source Files</Filter>
    2.25 -    </ClCompile>
    2.26      <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtmouse.cpp">
    2.27        <Filter>Source Files</Filter>
    2.28      </ClCompile>
    2.29 -    <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtrenderer.cpp">
    2.30 -      <Filter>Source Files</Filter>
    2.31 -    </ClCompile>
    2.32      <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtvideo.cpp">
    2.33        <Filter>Source Files</Filter>
    2.34      </ClCompile>
     3.1 --- a/VisualC-WinRT/SDL/SDL_VS2012-WinRT.vcxproj	Sat Feb 09 18:58:13 2013 -0500
     3.2 +++ b/VisualC-WinRT/SDL/SDL_VS2012-WinRT.vcxproj	Sat Feb 09 19:39:42 2013 -0500
     3.3 @@ -151,14 +151,6 @@
     3.4        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
     3.5        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
     3.6      </ClCompile>
     3.7 -    <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtframebuffer.cpp">
     3.8 -      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
     3.9 -      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
    3.10 -      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
    3.11 -      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
    3.12 -      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
    3.13 -      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
    3.14 -    </ClCompile>
    3.15      <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtmouse.cpp">
    3.16        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
    3.17        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
    3.18 @@ -167,14 +159,6 @@
    3.19        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
    3.20        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
    3.21      </ClCompile>
    3.22 -    <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtrenderer.cpp">
    3.23 -      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
    3.24 -      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
    3.25 -      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
    3.26 -      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
    3.27 -      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
    3.28 -      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
    3.29 -    </ClCompile>
    3.30      <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtvideo.cpp">
    3.31        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
    3.32        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
    3.33 @@ -293,9 +277,7 @@
    3.34      <ClInclude Include="..\..\src\video\windowsrt\SDLmain_WinRT_common.h" />
    3.35      <ClInclude Include="..\..\src\video\windowsrt\SDL_WinRTApp.h" />
    3.36      <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtevents_c.h" />
    3.37 -    <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtframebuffer_c.h" />
    3.38      <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtmouse.h" />
    3.39 -    <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtrenderer.h" />
    3.40      <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtvideo.h" />
    3.41    </ItemGroup>
    3.42    <ItemGroup>
     4.1 --- a/VisualC-WinRT/SDL/SDL_VS2012-WinRT.vcxproj.filters	Sat Feb 09 18:58:13 2013 -0500
     4.2 +++ b/VisualC-WinRT/SDL/SDL_VS2012-WinRT.vcxproj.filters	Sat Feb 09 19:39:42 2013 -0500
     4.3 @@ -234,15 +234,9 @@
     4.4      <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtevents.cpp">
     4.5        <Filter>Source Files</Filter>
     4.6      </ClCompile>
     4.7 -    <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtframebuffer.cpp">
     4.8 -      <Filter>Source Files</Filter>
     4.9 -    </ClCompile>
    4.10      <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtmouse.cpp">
    4.11        <Filter>Source Files</Filter>
    4.12      </ClCompile>
    4.13 -    <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtrenderer.cpp">
    4.14 -      <Filter>Source Files</Filter>
    4.15 -    </ClCompile>
    4.16      <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtvideo.cpp">
    4.17        <Filter>Source Files</Filter>
    4.18      </ClCompile>
    4.19 @@ -356,9 +350,6 @@
    4.20      <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtevents_c.h">
    4.21        <Filter>Source Files</Filter>
    4.22      </ClInclude>
    4.23 -    <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtframebuffer_c.h">
    4.24 -      <Filter>Source Files</Filter>
    4.25 -    </ClInclude>
    4.26      <ClInclude Include="..\..\src\render\SDL_yuv_sw_c.h">
    4.27        <Filter>Source Files</Filter>
    4.28      </ClInclude>
    4.29 @@ -578,9 +569,6 @@
    4.30      <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtmouse.h">
    4.31        <Filter>Source Files</Filter>
    4.32      </ClInclude>
    4.33 -    <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtrenderer.h">
    4.34 -      <Filter>Source Files</Filter>
    4.35 -    </ClInclude>
    4.36      <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtvideo.h">
    4.37        <Filter>Source Files</Filter>
    4.38      </ClInclude>
     5.1 --- a/src/video/windowsrt/SDL_WinRTApp.cpp	Sat Feb 09 18:58:13 2013 -0500
     5.2 +++ b/src/video/windowsrt/SDL_WinRTApp.cpp	Sat Feb 09 19:39:42 2013 -0500
     5.3 @@ -1,5 +1,6 @@
     5.4  #include "SDLmain_WinRT_common.h"
     5.5  #include "SDL_WinRTApp.h"
     5.6 +#include "ppltasks.h"
     5.7  
     5.8  extern "C" {
     5.9  #include "SDL_assert.h"
    5.10 @@ -47,8 +48,7 @@
    5.11      m_windowClosed(false),
    5.12      m_windowVisible(true),
    5.13      m_sdlWindowData(NULL),
    5.14 -    m_useRelativeMouseMode(false),
    5.15 -    m_renderer(nullptr)
    5.16 +    m_useRelativeMouseMode(false)
    5.17  {
    5.18  }
    5.19  
    5.20 @@ -62,8 +62,6 @@
    5.21  
    5.22      CoreApplication::Resuming +=
    5.23          ref new EventHandler<Platform::Object^>(this, &SDL_WinRTApp::OnResuming);
    5.24 -
    5.25 -    m_renderer = ref new SDL_winrtrenderer();
    5.26  }
    5.27  
    5.28  void SDL_WinRTApp::SetWindow(CoreWindow^ window)
    5.29 @@ -136,15 +134,6 @@
    5.30      }
    5.31  }
    5.32  
    5.33 -void SDL_WinRTApp::UpdateWindowFramebuffer(SDL_Surface * surface, SDL_Rect * rects, int numrects)
    5.34 -{
    5.35 -    if (!m_windowClosed && m_windowVisible)
    5.36 -    {
    5.37 -        m_renderer->Render(surface, rects, numrects);
    5.38 -        m_renderer->Present(); // This call is synchronized to the display frame rate.
    5.39 -    }
    5.40 -}
    5.41 -
    5.42  void SDL_WinRTApp::Uninitialize()
    5.43  {
    5.44  }
    5.45 @@ -649,11 +638,6 @@
    5.46      m_sdlWindowData = windowData;
    5.47  }
    5.48  
    5.49 -void SDL_WinRTApp::ResizeMainTexture(int w, int h)
    5.50 -{
    5.51 -    m_renderer->ResizeMainTexture(w, h);
    5.52 -}
    5.53 -
    5.54  IFrameworkView^ Direct3DApplicationSource::CreateView()
    5.55  {
    5.56      // TODO, WinRT: see if this function (CreateView) can ever get called
     6.1 --- a/src/video/windowsrt/SDL_WinRTApp.h	Sat Feb 09 18:58:13 2013 -0500
     6.2 +++ b/src/video/windowsrt/SDL_WinRTApp.h	Sat Feb 09 19:39:42 2013 -0500
     6.3 @@ -2,7 +2,6 @@
     6.4  
     6.5  #include "SDLmain_WinRT_common.h"
     6.6  #include "SDL_winrtvideo.h"
     6.7 -#include "SDL_winrtrenderer.h"
     6.8  #include <vector>
     6.9  
    6.10  using namespace Windows::UI::Core;
    6.11 @@ -27,8 +26,6 @@
    6.12      bool HasSDLWindowData() const;
    6.13      void SetRelativeMouseMode(bool enable);
    6.14      void SetSDLWindowData(const SDL_WindowData * windowData);
    6.15 -    void UpdateWindowFramebuffer(SDL_Surface * surface, SDL_Rect * rects, int numrects);
    6.16 -    void ResizeMainTexture(int w, int h);
    6.17      Windows::Foundation::Point TransformCursor(Windows::Foundation::Point rawPosition);
    6.18  
    6.19  protected:
    6.20 @@ -47,9 +44,6 @@
    6.21      void OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
    6.22      void OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
    6.23  
    6.24 -internal:
    6.25 -    SDL_winrtrenderer^ m_renderer;
    6.26 -
    6.27  private:
    6.28      bool m_windowClosed;
    6.29      bool m_windowVisible;
     7.1 --- a/src/video/windowsrt/SDL_winrtframebuffer.cpp	Sat Feb 09 18:58:13 2013 -0500
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,104 +0,0 @@
     7.4 -/*
     7.5 -  Simple DirectMedia Layer
     7.6 -  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
     7.7 -
     7.8 -  This software is provided 'as-is', without any express or implied
     7.9 -  warranty.  In no event will the authors be held liable for any damages
    7.10 -  arising from the use of this software.
    7.11 -
    7.12 -  Permission is granted to anyone to use this software for any purpose,
    7.13 -  including commercial applications, and to alter it and redistribute it
    7.14 -  freely, subject to the following restrictions:
    7.15 -
    7.16 -  1. The origin of this software must not be misrepresented; you must not
    7.17 -     claim that you wrote the original software. If you use this software
    7.18 -     in a product, an acknowledgment in the product documentation would be
    7.19 -     appreciated but is not required.
    7.20 -  2. Altered source versions must be plainly marked as such, and must not be
    7.21 -     misrepresented as being the original software.
    7.22 -  3. This notice may not be removed or altered from any source distribution.
    7.23 -*/
    7.24 -#include "SDL_config.h"
    7.25 -
    7.26 -#if SDL_VIDEO_DRIVER_WINRT
    7.27 -
    7.28 -#include "../SDL_sysvideo.h"
    7.29 -#include "SDL_winrtframebuffer_c.h"
    7.30 -#include "SDL_WinRTApp.h"
    7.31 -
    7.32 -extern SDL_WinRTApp ^ SDL_WinRTGlobalApp;
    7.33 -
    7.34 -
    7.35 -#define WINRT_SURFACE   "_SDL_WinRTSurface"
    7.36 -
    7.37 -int SDL_WINRT_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch)
    7.38 -{
    7.39 -    SDL_Surface *surface;
    7.40 -    const Uint32 surface_format = SDL_PIXELFORMAT_RGB888;
    7.41 -    int w, h;
    7.42 -    int bpp;
    7.43 -    Uint32 Rmask, Gmask, Bmask, Amask;
    7.44 -
    7.45 -    /* Free the old framebuffer surface */
    7.46 -    surface = (SDL_Surface *) SDL_GetWindowData(window, WINRT_SURFACE);
    7.47 -    if (surface) {
    7.48 -        SDL_FreeSurface(surface);
    7.49 -    }
    7.50 -
    7.51 -    /* Create a new one */
    7.52 -    SDL_PixelFormatEnumToMasks(surface_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask);
    7.53 -    SDL_GetWindowSize(window, &w, &h);
    7.54 -    surface = SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask);
    7.55 -    if (!surface) {
    7.56 -        return -1;
    7.57 -    }
    7.58 -
    7.59 -    /* Save info on the surface */
    7.60 -    SDL_SetWindowData(window, WINRT_SURFACE, surface);
    7.61 -    *format = surface_format;
    7.62 -    *pixels = surface->pixels;
    7.63 -    *pitch = surface->pitch;
    7.64 -
    7.65 -    /* Make sure a Direct3D texture exists to draw the surface onto */
    7.66 -    SDL_WinRTGlobalApp->ResizeMainTexture(surface->w, surface->h);
    7.67 -
    7.68 -    return 0;
    7.69 -}
    7.70 -
    7.71 -int SDL_WINRT_UpdateWindowFramebuffer(_THIS, SDL_Window * window, SDL_Rect * rects, int numrects)
    7.72 -{
    7.73 -    static int frame_number;
    7.74 -    SDL_Surface *surface;
    7.75 -
    7.76 -    surface = (SDL_Surface *) SDL_GetWindowData(window, WINRT_SURFACE);
    7.77 -    if (!surface) {
    7.78 -        SDL_SetError("Couldn't find WinRT surface for window");
    7.79 -        return -1;
    7.80 -    }
    7.81 -
    7.82 -    /* Send the data to the display */
    7.83 -    if (SDL_getenv("SDL_VIDEO_WINRT_SAVE_FRAMES")) {
    7.84 -        char file[128];
    7.85 -        SDL_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp",
    7.86 -                     SDL_GetWindowID(window), ++frame_number);
    7.87 -        SDL_SaveBMP(surface, file);
    7.88 -    }
    7.89 -
    7.90 -    SDL_WinRTGlobalApp->UpdateWindowFramebuffer(surface, rects, numrects);
    7.91 -
    7.92 -    return 0;
    7.93 -}
    7.94 -
    7.95 -void SDL_WINRT_DestroyWindowFramebuffer(_THIS, SDL_Window * window)
    7.96 -{
    7.97 -    SDL_Surface *surface;
    7.98 -
    7.99 -    surface = (SDL_Surface *) SDL_SetWindowData(window, WINRT_SURFACE, NULL);
   7.100 -    if (surface) {
   7.101 -        SDL_FreeSurface(surface);
   7.102 -    }
   7.103 -}
   7.104 -
   7.105 -#endif /* SDL_VIDEO_DRIVER_WINRT */
   7.106 -
   7.107 -/* vi: set ts=4 sw=4 expandtab: */
     8.1 --- a/src/video/windowsrt/SDL_winrtframebuffer_c.h	Sat Feb 09 18:58:13 2013 -0500
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,27 +0,0 @@
     8.4 -/*
     8.5 -  Simple DirectMedia Layer
     8.6 -  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
     8.7 -
     8.8 -  This software is provided 'as-is', without any express or implied
     8.9 -  warranty.  In no event will the authors be held liable for any damages
    8.10 -  arising from the use of this software.
    8.11 -
    8.12 -  Permission is granted to anyone to use this software for any purpose,
    8.13 -  including commercial applications, and to alter it and redistribute it
    8.14 -  freely, subject to the following restrictions:
    8.15 -
    8.16 -  1. The origin of this software must not be misrepresented; you must not
    8.17 -     claim that you wrote the original software. If you use this software
    8.18 -     in a product, an acknowledgment in the product documentation would be
    8.19 -     appreciated but is not required.
    8.20 -  2. Altered source versions must be plainly marked as such, and must not be
    8.21 -     misrepresented as being the original software.
    8.22 -  3. This notice may not be removed or altered from any source distribution.
    8.23 -*/
    8.24 -#include "SDL_config.h"
    8.25 -
    8.26 -extern int SDL_WINRT_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch);
    8.27 -extern int SDL_WINRT_UpdateWindowFramebuffer(_THIS, SDL_Window * window, SDL_Rect * rects, int numrects);
    8.28 -extern void SDL_WINRT_DestroyWindowFramebuffer(_THIS, SDL_Window * window);
    8.29 -
    8.30 -/* vi: set ts=4 sw=4 expandtab: */
     9.1 --- a/src/video/windowsrt/SDL_winrtrenderer.cpp	Sat Feb 09 18:58:13 2013 -0500
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,87 +0,0 @@
     9.4 -
     9.5 -#include <fstream>
     9.6 -#include <string>
     9.7 -#include <vector>
     9.8 -#include "SDLmain_WinRT_common.h"
     9.9 -#include "SDL_winrtrenderer.h"
    9.10 -
    9.11 -extern "C" {
    9.12 -#include "SDL_syswm.h"
    9.13 -#include "../../core/windows/SDL_windows.h"
    9.14 -}
    9.15 -
    9.16 -using namespace DirectX;
    9.17 -using namespace Microsoft::WRL;
    9.18 -using namespace std;
    9.19 -using namespace Windows::UI::Core;
    9.20 -using namespace Windows::Foundation;
    9.21 -using namespace Windows::Graphics::Display;
    9.22 -
    9.23 -// Constructor.
    9.24 -SDL_winrtrenderer::SDL_winrtrenderer() :
    9.25 -    m_sdlRenderer(NULL),
    9.26 -    m_sdlRendererData(NULL),
    9.27 -    m_mainTexture(NULL)
    9.28 -{
    9.29 -}
    9.30 -
    9.31 -SDL_winrtrenderer::~SDL_winrtrenderer()
    9.32 -{
    9.33 -    if (m_mainTexture) {
    9.34 -        SDL_DestroyTexture(m_mainTexture);
    9.35 -        m_mainTexture = NULL;
    9.36 -    }
    9.37 -}
    9.38 -
    9.39 -void SDL_winrtrenderer::ResizeMainTexture(int w, int h)
    9.40 -{
    9.41 -    if (m_mainTexture) {
    9.42 -        SDL_DestroyTexture(m_mainTexture);
    9.43 -        m_mainTexture = NULL;
    9.44 -    }
    9.45 -
    9.46 -    m_mainTexture = SDL_CreateTexture(m_sdlRenderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_TARGET, w, h);
    9.47 -}
    9.48 -
    9.49 -static inline Platform::Exception ^
    9.50 -WINRT_CreateExceptionWithSDLError()
    9.51 -{
    9.52 -    wchar_t * sdlErrorMessage = WIN_UTF8ToString(SDL_GetError());
    9.53 -    Platform::String ^ errorMessage = ref new Platform::String(sdlErrorMessage);
    9.54 -    SDL_free(sdlErrorMessage);
    9.55 -    throw ref new Platform::FailureException(errorMessage);
    9.56 -}
    9.57 -
    9.58 -void SDL_winrtrenderer::Render(SDL_Surface * surface, SDL_Rect * rects, int numrects)
    9.59 -{
    9.60 -    D3D11_TextureData * textureData = (D3D11_TextureData *)m_mainTexture->driverdata;
    9.61 -
    9.62 -    SDL_SetRenderDrawColor(m_sdlRenderer, 0, 0, 0, 0);
    9.63 -    if (SDL_RenderClear(m_sdlRenderer) != 0) {
    9.64 -        throw WINRT_CreateExceptionWithSDLError();
    9.65 -    }
    9.66 -
    9.67 -    // Only draw the screen once it is loaded (some loading is asynchronous).
    9.68 -    if (!m_sdlRendererData->loadingComplete) {
    9.69 -        return;
    9.70 -    }
    9.71 -    if (!textureData->mainTextureResourceView) {
    9.72 -        return;
    9.73 -    }
    9.74 -
    9.75 -    // Update the main texture (for SDL usage).
    9.76 -    // TODO, WinRT: only update the requested rects (passed to SDL_UpdateWindowSurface), rather than everything
    9.77 -    if (SDL_UpdateTexture(m_mainTexture, NULL, surface->pixels, surface->pitch) != 0) {
    9.78 -        throw WINRT_CreateExceptionWithSDLError();
    9.79 -    }
    9.80 -
    9.81 -    if (SDL_RenderCopy(m_sdlRenderer, m_mainTexture, NULL, NULL) != 0) {
    9.82 -        throw WINRT_CreateExceptionWithSDLError();
    9.83 -    }
    9.84 -}
    9.85 -
    9.86 -// Method to deliver the final image to the display.
    9.87 -void SDL_winrtrenderer::Present()
    9.88 -{
    9.89 -    SDL_RenderPresent(m_sdlRenderer);
    9.90 -}
    10.1 --- a/src/video/windowsrt/SDL_winrtrenderer.h	Sat Feb 09 18:58:13 2013 -0500
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,33 +0,0 @@
    10.4 -#pragma once
    10.5 -
    10.6 -#include "DirectXHelper.h"
    10.7 -#include "../../render/direct3d11/SDL_render_d3d11_cpp.h"
    10.8 -
    10.9 -extern "C" {
   10.10 -#include "SDL.h"
   10.11 -#include "../../render/SDL_sysrender.h"
   10.12 -}
   10.13 -
   10.14 -// Helper class that initializes DirectX APIs for 3D rendering.
   10.15 -ref class SDL_winrtrenderer
   10.16 -{
   10.17 -internal:
   10.18 -    SDL_winrtrenderer();
   10.19 -
   10.20 -public:
   10.21 -    virtual ~SDL_winrtrenderer();
   10.22 -    virtual void Present();
   10.23 -
   10.24 -internal:
   10.25 -    virtual void Render(SDL_Surface * surface, SDL_Rect * rects, int numrects);
   10.26 -    void ResizeMainTexture(int w, int h);
   10.27 -
   10.28 -internal:
   10.29 -    // Internal SDL renderer (likely a temporary addition, for refactoring purposes):
   10.30 -    SDL_Renderer * m_sdlRenderer;
   10.31 -    D3D11_RenderData * m_sdlRendererData;
   10.32 -
   10.33 -protected private:
   10.34 -    // UpdateWindowSurface helper objects
   10.35 -    SDL_Texture * m_mainTexture;
   10.36 -};
    11.1 --- a/src/video/windowsrt/SDL_winrtvideo.cpp	Sat Feb 09 18:58:13 2013 -0500
    11.2 +++ b/src/video/windowsrt/SDL_winrtvideo.cpp	Sat Feb 09 19:39:42 2013 -0500
    11.3 @@ -41,7 +41,6 @@
    11.4  #include "SDL_WinRTApp.h"
    11.5  #include "SDL_winrtvideo.h"
    11.6  #include "SDL_winrtevents_c.h"
    11.7 -#include "SDL_winrtframebuffer_c.h"
    11.8  #include "SDL_winrtmouse.h"
    11.9  
   11.10  /* On Windows, windows.h defines CreateWindow */
   11.11 @@ -100,9 +99,9 @@
   11.12      device->DestroyWindow = WINRT_DestroyWindow;
   11.13      device->SetDisplayMode = WINRT_SetDisplayMode;
   11.14      device->PumpEvents = WINRT_PumpEvents;
   11.15 -    device->CreateWindowFramebuffer = SDL_WINRT_CreateWindowFramebuffer;
   11.16 -    device->UpdateWindowFramebuffer = SDL_WINRT_UpdateWindowFramebuffer;
   11.17 -    device->DestroyWindowFramebuffer = SDL_WINRT_DestroyWindowFramebuffer;
   11.18 +    //device->CreateWindowFramebuffer = SDL_WINRT_CreateWindowFramebuffer;
   11.19 +    //device->UpdateWindowFramebuffer = SDL_WINRT_UpdateWindowFramebuffer;
   11.20 +    //device->DestroyWindowFramebuffer = SDL_WINRT_DestroyWindowFramebuffer;
   11.21      device->GetWindowWMInfo = WINRT_GetWindowWMInfo;
   11.22  
   11.23      device->free = WINRT_DeleteDevice;
   11.24 @@ -167,6 +166,7 @@
   11.25          SDL_OutOfMemory();
   11.26          return -1;
   11.27      }
   11.28 +    window->driverdata = data;
   11.29      data->sdlWindow = window;
   11.30      data->coreWindow = new CoreWindow^(CoreWindow::GetForCurrentThread());
   11.31  
   11.32 @@ -213,27 +213,6 @@
   11.33      */
   11.34      SDL_WinRTGlobalApp->SetSDLWindowData(data);
   11.35  
   11.36 -    /* For now, create a Direct3D 11 renderer up-front.  Eventually, this
   11.37 -       won't be done in WINRT_CreateWindow, although it may get done in
   11.38 -       SDL_WINRT_CreateWindowFramebuffer.
   11.39 -    */
   11.40 -
   11.41 -    // Link SDL_winrtrenderer to the SDL_Renderer temporarily,
   11.42 -    // for refactoring purposes.  Initialize the SDL_Renderer
   11.43 -    // first in order to give it the opportunity to create key
   11.44 -    // resources first.
   11.45 -    //
   11.46 -    // TODO, WinRT: either make WINRT_CreateWindow not call SDL_CreateRenderer, or have it do error checking if it does call it
   11.47 -
   11.48 -    // HACK: make sure the SDL window references SDL_WindowData data now, in
   11.49 -    // order to allow the SDL_Renderer to be created in WINRT_CreateWindow
   11.50 -    window->driverdata = data;
   11.51 -
   11.52 -    SDL_Renderer * renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE);
   11.53 -    SDL_WinRTGlobalApp->m_renderer->m_sdlRenderer = renderer;
   11.54 -    SDL_WinRTGlobalApp->m_renderer->m_sdlRendererData = (D3D11_RenderData *) renderer->driverdata;
   11.55 -    //SDL_WinRTGlobalApp->m_renderer->Initialize();
   11.56 -
   11.57      /* All done! */
   11.58      return 0;
   11.59  }