src/render/direct3d/SDL_render_d3d.c
changeset 5299 33987021a1ed
parent 5297 1800dc39b74c
child 5484 e20c93bc9122
     1.1 --- a/src/render/direct3d/SDL_render_d3d.c	Tue Feb 15 14:10:50 2011 -0800
     1.2 +++ b/src/render/direct3d/SDL_render_d3d.c	Tue Feb 15 14:17:42 2011 -0800
     1.3 @@ -704,7 +704,6 @@
     1.4  D3D_RenderClear(SDL_Renderer * renderer)
     1.5  {
     1.6      D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
     1.7 -    D3DVIEWPORT9 viewport;
     1.8      DWORD color;
     1.9      HRESULT result;
    1.10  
    1.11 @@ -712,27 +711,36 @@
    1.12          return -1;
    1.13      }
    1.14  
    1.15 -    /* Clear is defined to clear the entire render target */
    1.16 -    viewport.X = 0;
    1.17 -    viewport.Y = 0;
    1.18 -    viewport.Width = data->pparams.BackBufferWidth;
    1.19 -    viewport.Height = data->pparams.BackBufferHeight;
    1.20 -    viewport.MinZ = 0.0f;
    1.21 -    viewport.MaxZ = 1.0f;
    1.22 -    IDirect3DDevice9_SetViewport(data->device, &viewport);
    1.23 -
    1.24      color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
    1.25  
    1.26 -    result = IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET, color, 0.0f, 0);
    1.27 +    /* Don't reset the viewport if we don't have to! */
    1.28 +    if (!renderer->viewport.x && !renderer->viewport.y &&
    1.29 +        renderer->viewport.w == data->pparams.BackBufferWidth &&
    1.30 +        renderer->viewport.h == data->pparams.BackBufferHeight) {
    1.31 +        result = IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET, color, 0.0f, 0);
    1.32 +    } else {
    1.33 +        D3DVIEWPORT9 viewport;
    1.34  
    1.35 -    /* Reset the viewport */
    1.36 -    viewport.X = renderer->viewport.x;
    1.37 -    viewport.Y = renderer->viewport.y;
    1.38 -    viewport.Width = renderer->viewport.w;
    1.39 -    viewport.Height = renderer->viewport.h;
    1.40 -    viewport.MinZ = 0.0f;
    1.41 -    viewport.MaxZ = 1.0f;
    1.42 -    IDirect3DDevice9_SetViewport(data->device, &viewport);
    1.43 +        /* Clear is defined to clear the entire render target */
    1.44 +        viewport.X = 0;
    1.45 +        viewport.Y = 0;
    1.46 +        viewport.Width = data->pparams.BackBufferWidth;
    1.47 +        viewport.Height = data->pparams.BackBufferHeight;
    1.48 +        viewport.MinZ = 0.0f;
    1.49 +        viewport.MaxZ = 1.0f;
    1.50 +        IDirect3DDevice9_SetViewport(data->device, &viewport);
    1.51 +
    1.52 +        result = IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET, color, 0.0f, 0);
    1.53 +
    1.54 +        /* Reset the viewport */
    1.55 +        viewport.X = renderer->viewport.x;
    1.56 +        viewport.Y = renderer->viewport.y;
    1.57 +        viewport.Width = renderer->viewport.w;
    1.58 +        viewport.Height = renderer->viewport.h;
    1.59 +        viewport.MinZ = 0.0f;
    1.60 +        viewport.MaxZ = 1.0f;
    1.61 +        IDirect3DDevice9_SetViewport(data->device, &viewport);
    1.62 +    }
    1.63  
    1.64      if (FAILED(result)) {
    1.65          D3D_SetError("Clear()", result);