Bug 593224 - ContainerLayerD3D9 can reset the clip rect r=Bas, a=blocking2.0
authorMatt Woodrow <mwoodrow@mozilla.com>
Fri, 03 Sep 2010 15:50:53 +1200
changeset 51962 e2f75964a5e808f3135962d398ab53f12f9fdb9a
parent 51961 79b1b3fe72f27c8255078a4d81ef4db8440a7fe9
child 51963 388e25a30cab946c4d7beb3b8f914eeae9c5fa98
push idunknown
push userunknown
push dateunknown
reviewersBas, blocking2
bugs593224
milestone2.0b6pre
Bug 593224 - ContainerLayerD3D9 can reset the clip rect r=Bas, a=blocking2.0
gfx/layers/d3d9/ContainerLayerD3D9.cpp
--- a/gfx/layers/d3d9/ContainerLayerD3D9.cpp
+++ b/gfx/layers/d3d9/ContainerLayerD3D9.cpp
@@ -136,24 +136,26 @@ ContainerLayerD3D9::GetFirstChildD3D9()
 
 void
 ContainerLayerD3D9::RenderLayer()
 {
   float opacity = GetOpacity();
   nsRefPtr<IDirect3DSurface9> previousRenderTarget;
   nsRefPtr<IDirect3DTexture9> renderTexture;
   float previousRenderTargetOffset[4];
+  RECT oldClipRect;
   float renderTargetOffset[] = { 0, 0, 0, 0 };
   float oldViewMatrix[4][4];
 
   nsIntRect visibleRect = mVisibleRegion.GetBounds();
   PRBool useIntermediate = (opacity != 1.0 || !mTransform.IsIdentity());
 
   if (useIntermediate) {
     device()->GetRenderTarget(0, getter_AddRefs(previousRenderTarget));
+    device()->GetScissorRect(&oldClipRect);
     device()->CreateTexture(visibleRect.width, visibleRect.height, 1,
                             D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
                             D3DPOOL_DEFAULT, getter_AddRefs(renderTexture),
                             NULL);
     nsRefPtr<IDirect3DSurface9> renderSurface;
     renderTexture->GetSurfaceLevel(0, getter_AddRefs(renderSurface));
     device()->SetRenderTarget(0, renderSurface);
     device()->GetVertexShaderConstantF(12, previousRenderTargetOffset, 1);
@@ -219,16 +221,17 @@ ContainerLayerD3D9::RenderLayer()
     Layer *nextSibling = layerToRender->GetLayer()->GetNextSibling();
     layerToRender = nextSibling ? static_cast<LayerD3D9*>(nextSibling->
                                                           ImplData())
                                 : nsnull;
   }
 
   if (useIntermediate) {
     device()->SetRenderTarget(0, previousRenderTarget);
+    device()->SetScissorRect(&oldClipRect);
     device()->SetVertexShaderConstantF(12, previousRenderTargetOffset, 1);
     device()->SetVertexShaderConstantF(8, &oldViewMatrix[0][0], 4);
 
     float quadTransform[4][4];
     /*
      * Matrix to transform the <0.0,0.0>, <1.0,1.0> quad to the correct position
      * and size. To get pixel perfect mapping we offset the quad half a pixel
      * to the top-left.