Bug 877700: Limit the Source region to the area of the parent layer surface. r=roc
authorBas Schouten <bschouten@mozilla.com>
Mon, 29 Jul 2013 10:35:48 +0000
changeset 152625 de0950887682fa3e45d4c92c2eeb37c4ed758d5b
parent 152596 8c89fe2a5c92c6cda691263a46266d999f4e59a9
child 152626 5fc0330806d4343cc45ba236ead5001e291db228
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs877700
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 877700: Limit the Source region to the area of the parent layer surface. r=roc
gfx/layers/d3d10/ContainerLayerD3D10.cpp
--- a/gfx/layers/d3d10/ContainerLayerD3D10.cpp
+++ b/gfx/layers/d3d10/ContainerLayerD3D10.cpp
@@ -236,35 +236,37 @@ ContainerLayerD3D10::RenderLayer()
     }
 
     hr = device()->CreateRenderTargetView(renderTexture, nullptr, getter_AddRefs(rtView));
     NS_ASSERTION(SUCCEEDED(hr), "Failed to create render target view for ContainerLayerD3D10!");
 
     effect()->GetVariableByName("vRenderTargetOffset")->
       GetRawValue(previousRenderTargetOffset, 0, 8);
 
+    previousViewportSize = mD3DManager->GetViewport();
+
     if (mVisibleRegion.GetNumRects() != 1 || !(GetContentFlags() & CONTENT_OPAQUE)) {
       const gfx3DMatrix& transform3D = GetEffectiveTransform();
       gfxMatrix transform;
       // If we have an opaque ancestor layer, then we can be sure that
       // all the pixels we draw into are either opaque already or will be
       // covered by something opaque. Otherwise copying up the background is
       // not safe.
       if (mSupportsComponentAlphaChildren) {
         bool is2d = transform3D.Is2D(&transform);
         NS_ASSERTION(is2d, "Transform should be 2d when mSupportsComponentAlphaChildren.");
 
         // Copy background up from below. This applies any 2D transform that is
         // applied to use relative to our parent, and compensates for the offset
         // that was applied on our parent's rendering.
         D3D10_BOX srcBox;
-        srcBox.left = visibleRect.x + int32_t(transform.x0) - int32_t(previousRenderTargetOffset[0]);
-        srcBox.top = visibleRect.y + int32_t(transform.y0) - int32_t(previousRenderTargetOffset[1]);
-        srcBox.right = srcBox.left + visibleRect.width;
-        srcBox.bottom = srcBox.top + visibleRect.height;
+        srcBox.left = std::max<int32_t>(visibleRect.x + int32_t(transform.x0) - int32_t(previousRenderTargetOffset[0]), 0);
+        srcBox.top = std::max<int32_t>(visibleRect.y + int32_t(transform.y0) - int32_t(previousRenderTargetOffset[1]), 0);
+        srcBox.right = std::min<int32_t>(srcBox.left + visibleRect.width, previousViewportSize.width);
+        srcBox.bottom = std::min<int32_t>(srcBox.top + visibleRect.height, previousViewportSize.height);
         srcBox.back = 1;
         srcBox.front = 0;
 
         nsRefPtr<ID3D10Resource> srcResource;
         previousRTView->GetResource(getter_AddRefs(srcResource));
 
         device()->CopySubresourceRegion(renderTexture, 0,
                                         0, 0, 0,
@@ -279,17 +281,16 @@ ContainerLayerD3D10::RenderLayer()
     ID3D10RenderTargetView *rtViewPtr = rtView;
     device()->OMSetRenderTargets(1, &rtViewPtr, nullptr);
 
     renderTargetOffset[0] = (float)visibleRect.x;
     renderTargetOffset[1] = (float)visibleRect.y;
     effect()->GetVariableByName("vRenderTargetOffset")->
       SetRawValue(renderTargetOffset, 0, 8);
 
-    previousViewportSize = mD3DManager->GetViewport();
     mD3DManager->SetViewport(nsIntSize(visibleRect.Size()));
   }
     
   D3D10_RECT oldD3D10Scissor;
   UINT numRects = 1;
   device()->RSGetScissorRects(&numRects, &oldD3D10Scissor);
   // Convert scissor to an nsIntRect. D3D10_RECT's are exclusive
   // on the bottom and right values.