Fixed infinite recursion in D3D_Reset()
authorSam Lantinga <slouken@libsdl.org>
Thu, 20 Feb 2014 21:07:56 -0800
changeset 8228 010ae1267485
parent 8227 bd491250c87d
child 8229 437c4e5961e0
Fixed infinite recursion in D3D_Reset()
src/render/direct3d/SDL_render_d3d.c
--- a/src/render/direct3d/SDL_render_d3d.c	Thu Feb 20 17:03:55 2014 -0300
+++ b/src/render/direct3d/SDL_render_d3d.c	Thu Feb 20 21:07:56 2014 -0800
@@ -217,6 +217,7 @@
 static int D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
                            const SDL_Rect * rect, void **pixels, int *pitch);
 static void D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
+static int D3D_SetRenderTargetInternal(SDL_Renderer * renderer, SDL_Texture * texture);
 static int D3D_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture);
 static int D3D_UpdateViewport(SDL_Renderer * renderer);
 static int D3D_UpdateClipRect(SDL_Renderer * renderer);
@@ -512,7 +513,7 @@
 
     IDirect3DDevice9_GetRenderTarget(data->device, 0, &data->defaultRenderTarget);
     D3D_InitRenderState(data);
-    D3D_SetRenderTarget(renderer, renderer->target);
+    D3D_SetRenderTargetInternal(renderer, renderer->target);
     D3D_UpdateViewport(renderer);
 
     /* Let the application know that render targets were reset */
@@ -1160,14 +1161,12 @@
 }
 
 static int
-D3D_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
+D3D_SetRenderTargetInternal(SDL_Renderer * renderer, SDL_Texture * texture)
 {
     D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
     D3D_TextureData *texturedata;
     HRESULT result;
 
-    D3D_ActivateRenderer(renderer);
-
     /* Release the previous render target if it wasn't the default one */
     if (data->currentRenderTarget != NULL) {
         IDirect3DSurface9_Release(data->currentRenderTarget);
@@ -1198,6 +1197,14 @@
 }
 
 static int
+D3D_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+    D3D_ActivateRenderer(renderer);
+
+    return D3D_SetRenderTargetInternal(renderer, texture);
+}
+
+static int
 D3D_UpdateViewport(SDL_Renderer * renderer)
 {
     D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;