Bug 743393: Reset scissorrect when clearing surfaces. r=jrmuizel
authorBas Schouten <bschouten@mozilla.com>
Wed, 11 Apr 2012 16:55:31 +0200
changeset 91435 0260266fa8b5fe5e78971e8a61fcd643dd338c44
parent 91434 f99886297f833872e02362515f614f70ccc981d7
child 91436 bc29c3a684199d44a0251b880d1a59e7c99091e7
push id672
push usertim.taubert@gmx.de
push dateFri, 13 Apr 2012 10:22:59 +0000
treeherderfx-team@cb2e81306595 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs743393
milestone14.0a1
Bug 743393: Reset scissorrect when clearing surfaces. r=jrmuizel
gfx/layers/d3d10/ThebesLayerD3D10.cpp
gfx/layers/d3d10/ThebesLayerD3D10.h
--- a/gfx/layers/d3d10/ThebesLayerD3D10.cpp
+++ b/gfx/layers/d3d10/ThebesLayerD3D10.cpp
@@ -361,67 +361,44 @@ ThebesLayerD3D10::VerifyContentType(Surf
     mD2DSurfaceOnWhite = nsnull;
     mSRViewOnWhite = nsnull;
     mTextureOnWhite = nsnull;
     mValidRegion.SetEmpty();
   }
 }
 
 void
-ThebesLayerD3D10::SetupDualViewports(const gfxIntSize &aSize)
-{
-    D3D10_VIEWPORT viewport;
-    viewport.MaxDepth = 1.0f;
-    viewport.MinDepth = 0;
-    viewport.Width = aSize.width;
-    viewport.Height = aSize.height;
-    viewport.TopLeftX = 0;
-    viewport.TopLeftY = 0;
-
-    D3D10_VIEWPORT vps[2] = { viewport, viewport };
-    device()->RSSetViewports(2, vps);
-
-    gfx3DMatrix projection;
-    /*
-     * Matrix to transform to viewport space ( <-1.0, 1.0> topleft,
-     * <1.0, -1.0> bottomright)
-     */
-    projection._11 = 2.0f / aSize.width;
-    projection._22 = -2.0f / aSize.height;
-    projection._33 = 0.0f;
-    projection._41 = -1.0f;
-    projection._42 = 1.0f;
-    projection._44 = 1.0f;
-
-    effect()->GetVariableByName("mProjection")->
-      SetRawValue(&projection._11, 0, 64);
-}
-
-void
 ThebesLayerD3D10::FillTexturesBlackWhite(const nsIntRegion& aRegion, const nsIntPoint& aOffset)
 {
   if (mTexture && mTextureOnWhite) {
     // It would be more optimal to draw the actual geometry, but more code
     // and probably not worth the win here as this will often be a single
     // rect.
     nsRefPtr<ID3D10RenderTargetView> oldRT;
     device()->OMGetRenderTargets(1, getter_AddRefs(oldRT), NULL);
 
     nsRefPtr<ID3D10RenderTargetView> viewBlack;
     nsRefPtr<ID3D10RenderTargetView> viewWhite;
     device()->CreateRenderTargetView(mTexture, NULL, getter_AddRefs(viewBlack));
     device()->CreateRenderTargetView(mTextureOnWhite, NULL, getter_AddRefs(viewWhite));
 
+    D3D10_RECT oldScissor;
+    UINT numRects = 1;
+    device()->RSGetScissorRects(&numRects, &oldScissor);
+
     D3D10_TEXTURE2D_DESC desc;
     mTexture->GetDesc(&desc);
 
+    D3D10_RECT scissor = { 0, 0, desc.Width, desc.Height };
+    device()->RSSetScissorRects(1, &scissor);
+
     mD3DManager->SetupInputAssembler();
     nsIntSize oldVP = mD3DManager->GetViewport();
 
-    SetupDualViewports(gfxIntSize(desc.Width, desc.Height));
+    mD3DManager->SetViewport(nsIntSize(desc.Width, desc.Height));
 
     ID3D10RenderTargetView *views[2] = { viewBlack, viewWhite };
     device()->OMSetRenderTargets(2, views, NULL);
 
     gfx3DMatrix transform;
     transform.Translate(gfxPoint3D(-aOffset.x, -aOffset.y, 0));
     void* raw = &const_cast<gfx3DMatrix&>(transform)._11;
     effect()->GetVariableByName("mLayerTransform")->SetRawValue(raw, 0, 64);
@@ -443,16 +420,17 @@ ThebesLayerD3D10::FillTexturesBlackWhite
 
       technique->GetPassByIndex(0)->Apply(0);
       device()->Draw(4, 0);
     }
 
     views[0] = oldRT;
     device()->OMSetRenderTargets(1, views, NULL);
     mD3DManager->SetViewport(oldVP);
+    device()->RSSetScissorRects(1, &oldScissor);
   }
 }
 
 void
 ThebesLayerD3D10::DrawRegion(nsIntRegion &aRegion, SurfaceMode aMode)
 {
   nsIntRect visibleRect = mVisibleRegion.GetBounds();
 
--- a/gfx/layers/d3d10/ThebesLayerD3D10.h
+++ b/gfx/layers/d3d10/ThebesLayerD3D10.h
@@ -92,18 +92,16 @@ private:
   nsRefPtr<gfxASurface> mD2DSurfaceOnWhite;
 
   /* Have a region of our layer drawn */
   void DrawRegion(nsIntRegion &aRegion, SurfaceMode aMode);
 
   /* Create a new texture */
   void CreateNewTextures(const gfxIntSize &aSize, SurfaceMode aMode);
 
-  void SetupDualViewports(const gfxIntSize &aSize);
-  
   // Fill textures with opaque black and white in the specified region.
   void FillTexturesBlackWhite(const nsIntRegion& aRegion, const nsIntPoint& aOffset);
 
   /* Copy a texture region */
   void CopyRegion(ID3D10Texture2D* aSrc, const nsIntPoint &aSrcOffset,
                   ID3D10Texture2D* aDest, const nsIntPoint &aDestOffset,
                   const nsIntRegion &aCopyRegion, nsIntRegion* aValidRegion);
 };