Bug 795694 - Invalidate changed visible regions of layers. r=roc
authorMatt Woodrow <mwoodrow@mozilla.com>
Mon, 01 Oct 2012 16:38:46 +1300
changeset 108814 281019df934376a248ff555dd6a328271696edb5
parent 108813 4a7836f11aa7d751b7c974cf707d312617ee0982
child 108815 beee809b7ade112df78eef6191791e11edf33d9c
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewersroc
bugs795694
milestone18.0a1
Bug 795694 - Invalidate changed visible regions of layers. r=roc
gfx/layers/LayerTreeInvalidation.cpp
--- a/gfx/layers/LayerTreeInvalidation.cpp
+++ b/gfx/layers/LayerTreeInvalidation.cpp
@@ -59,17 +59,17 @@ NotifySubdocumentInvalidationRecursive(L
   aCallback(container, container->GetVisibleRegion());
 }
 
 struct LayerPropertiesBase : public LayerProperties
 {
   LayerPropertiesBase(Layer* aLayer)
     : mLayer(aLayer)
     , mMaskLayer(nullptr)
-    , mVisibleBounds(aLayer->GetVisibleRegion().GetBounds())
+    , mVisibleRegion(aLayer->GetVisibleRegion())
     , mTransform(aLayer->GetTransform())
     , mOpacity(aLayer->GetOpacity())
     , mUseClipRect(!!aLayer->GetClipRect())
   {
     MOZ_COUNT_CTOR(LayerPropertiesBase);
     if (aLayer->GetMaskLayer()) {
       mMaskLayer = CloneLayerTreePropertiesInternal(aLayer->GetMaskLayer());
     }
@@ -113,16 +113,20 @@ struct LayerPropertiesBase : public Laye
       // layers then we can just stop here since we've already invalidated the entire
       // old and new bounds.
       if (!aCallback) {
         ClearInvalidations(mLayer);
         return result;
       }
     }
 
+    nsIntRegion visible;
+    visible.Xor(mVisibleRegion, mLayer->GetVisibleRegion());
+    result = result.Union(TransformRect(visible.GetBounds(), mTransform));
+
     result = result.Union(ComputeChangeInternal(aCallback));
     result = result.Union(TransformRect(mLayer->GetInvalidRegion().GetBounds(), mTransform));
 
     if (mMaskLayer && otherMask) {
       nsIntRect maskDiff = mMaskLayer->ComputeChange(aCallback);
       result = result.Union(TransformRect(maskDiff, mTransform));
     }
 
@@ -140,24 +144,24 @@ struct LayerPropertiesBase : public Laye
 
   nsIntRect NewTransformedBounds()
   {
     return TransformRect(mLayer->GetVisibleRegion().GetBounds(), mLayer->GetTransform());
   }
 
   nsIntRect OldTransformedBounds()
   {
-    return TransformRect(mVisibleBounds, mTransform);
+    return TransformRect(mVisibleRegion.GetBounds(), mTransform);
   }
 
   virtual nsIntRect ComputeChangeInternal(NotifySubDocInvalidationFunc aCallback) { return nsIntRect(); }
 
   nsRefPtr<Layer> mLayer;
   nsAutoPtr<LayerPropertiesBase> mMaskLayer;
-  nsIntRect mVisibleBounds;
+  nsIntRegion mVisibleRegion;
   gfx3DMatrix mTransform;
   float mOpacity;
   nsIntRect mClipRect;
   bool mUseClipRect;
 };
 
 struct ContainerLayerProperties : public LayerPropertiesBase
 {