Bug 852489. Part 6: Don't temporarily reset clip when recycling Thebes/Image/ColorLayers. r=mattwoodrow
authorRobert O'Callahan <robert@ocallahan.org>
Fri, 22 Mar 2013 15:17:29 +1300
changeset 126687 643b78450848a17005742ce9e9bcf310a5a618ae
parent 126686 d9916e4fb4eb5b21e2cd88aef044b5047982d7c0
child 126688 c226b01745609ffbfa065bf548df0cbdbf419529
push idunknown
push userunknown
push dateunknown
reviewersmattwoodrow
bugs852489
milestone22.0a1
Bug 852489. Part 6: Don't temporarily reset clip when recycling Thebes/Image/ColorLayers. r=mattwoodrow
layout/base/FrameLayerBuilder.cpp
--- a/layout/base/FrameLayerBuilder.cpp
+++ b/layout/base/FrameLayerBuilder.cpp
@@ -1175,17 +1175,16 @@ FrameLayerBuilder::GetDebugOldLayerFor(n
 
 already_AddRefed<ColorLayer>
 ContainerState::CreateOrRecycleColorLayer(ThebesLayer *aThebes)
 {
   ThebesDisplayItemLayerUserData* data = 
       static_cast<ThebesDisplayItemLayerUserData*>(aThebes->GetUserData(&gThebesDisplayItemLayerUserData));
   nsRefPtr<ColorLayer> layer = data->mColorLayer;
   if (layer) {
-    layer->SetClipRect(nullptr);
     layer->SetMaskLayer(nullptr);
   } else {
     // Create a new layer
     layer = mManager->CreateColorLayer();
     if (!layer)
       return nullptr;
     // Mark this layer as being used for Thebes-painting display items
     data->mColorLayer = layer;
@@ -1199,17 +1198,16 @@ ContainerState::CreateOrRecycleColorLaye
 
 already_AddRefed<ImageLayer>
 ContainerState::CreateOrRecycleImageLayer(ThebesLayer *aThebes)
 {
   ThebesDisplayItemLayerUserData* data = 
       static_cast<ThebesDisplayItemLayerUserData*>(aThebes->GetUserData(&gThebesDisplayItemLayerUserData));
   nsRefPtr<ImageLayer> layer = data->mImageLayer;
   if (layer) {
-    layer->SetClipRect(nullptr);
     layer->SetMaskLayer(nullptr);
   } else {
     // Create a new layer
     layer = mManager->CreateImageLayer();
     if (!layer)
       return nullptr;
     // Mark this layer as being used for Thebes-painting display items
     data->mImageLayer = layer;
@@ -1300,17 +1298,16 @@ ContainerState::CreateOrRecycleThebesLay
   bool didResetScrollPositionForLayerPixelAlignment = false;
 #endif
   if (mNextFreeRecycledThebesLayer < mRecycledThebesLayers.Length()) {
     // Recycle a layer
     layer = mRecycledThebesLayers[mNextFreeRecycledThebesLayer];
     ++mNextFreeRecycledThebesLayer;
     // Clear clip rect and mask layer so we don't accidentally stay clipped.
     // We will reapply any necessary clipping.
-    layer->SetClipRect(nullptr);
     layer->SetMaskLayer(nullptr);
 
     data = static_cast<ThebesDisplayItemLayerUserData*>
         (layer->GetUserData(&gThebesDisplayItemLayerUserData));
     NS_ASSERTION(data, "Recycled ThebesLayers must have user data");
 
     // This gets called on recycled ThebesLayers that are going to be in the
     // final layer tree, so it's a convenient time to invalidate the
@@ -1567,17 +1564,19 @@ ContainerState::PopThebesLayerData()
       nsRefPtr<ImageLayer> imageLayer = CreateOrRecycleImageLayer(data->mLayer);
       imageLayer->SetContainer(imageContainer);
       data->mImage->ConfigureLayer(imageLayer, mParameters.mOffset);
       imageLayer->SetPostScale(mParameters.mXScale,
                                mParameters.mYScale);
       if (data->mItemClip.mHaveClipRect) {
         nsIntRect clip = ScaleToNearestPixels(data->mItemClip.mClipRect);
         clip.MoveBy(mParameters.mOffset);
-        imageLayer->IntersectClipRect(clip);
+        imageLayer->SetClipRect(&clip);
+      } else {
+        imageLayer->SetClipRect(nullptr);
       }
       layer = imageLayer;
       mLayerBuilder->StoreOptimizedLayerForFrame(data->mImage,
                                                  imageLayer);
     } else {
       nsRefPtr<ColorLayer> colorLayer = CreateOrRecycleColorLayer(data->mLayer);
       colorLayer->SetIsFixedPosition(data->mLayer->GetIsFixedPosition());
       colorLayer->SetColor(data->mSolidColor);
@@ -1601,21 +1600,23 @@ ContainerState::PopThebesLayerData()
 
     NS_ASSERTION(!mNewChildLayers.Contains(layer), "Layer already in list???");
     AutoLayersArray::index_type index = mNewChildLayers.IndexOf(data->mLayer);
     NS_ASSERTION(index != AutoLayersArray::NoIndex, "Thebes layer not found?");
     mNewChildLayers.InsertElementAt(index + 1, layer);
 
     // Hide the ThebesLayer. We leave it in the layer tree so that we
     // can find and recycle it later.
-    data->mLayer->IntersectClipRect(nsIntRect());
+    nsIntRect emptyRect;
+    data->mLayer->SetClipRect(&emptyRect);
     data->mLayer->SetVisibleRegion(nsIntRegion());
   } else {
     layer = data->mLayer;
     imageContainer = nullptr;
+    layer->SetClipRect(nullptr);
   }
 
   gfxMatrix transform;
   if (!layer->GetTransform().Is2D(&transform)) {
     NS_ERROR("Only 2D transformations currently supported");
   }
 
   // ImageLayers are already configured with a visible region