Remove LayerManagerComposite's geometry changed flag. (bug 1363249, r=mattwoodrow)
authorDavid Anderson <danderson@mozilla.com>
Wed, 10 May 2017 10:49:31 -0700
changeset 357547 09153d47e1bdf4d04e7d9c5f705d528bad16abee
parent 357546 e916525919a900e91ba6b165768b89eefb74ea07
child 357548 a92f82ecbf109bac753109ca11f6c001bc6d55ae
push id90149
push userdanderson@mozilla.com
push dateWed, 10 May 2017 17:51:39 +0000
treeherdermozilla-inbound@09153d47e1bd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1363249
milestone55.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
Remove LayerManagerComposite's geometry changed flag. (bug 1363249, r=mattwoodrow)
gfx/layers/LayerTreeInvalidation.cpp
gfx/layers/LayerTreeInvalidation.h
gfx/layers/composite/LayerManagerComposite.cpp
gfx/layers/composite/LayerManagerComposite.h
--- a/gfx/layers/LayerTreeInvalidation.cpp
+++ b/gfx/layers/LayerTreeInvalidation.cpp
@@ -177,24 +177,22 @@ struct LayerPropertiesBase : public Laye
   }
 
 protected:
   LayerPropertiesBase(const LayerPropertiesBase& a) = delete;
   LayerPropertiesBase& operator=(const LayerPropertiesBase& a) = delete;
 
 public:
   nsIntRegion ComputeDifferences(Layer* aRoot,
-                                 NotifySubDocInvalidationFunc aCallback,
-                                 bool* aGeometryChanged) override;
+                                 NotifySubDocInvalidationFunc aCallback) override;
 
   void MoveBy(const IntPoint& aOffset) override;
 
   nsIntRegion ComputeChange(const char* aPrefix,
-                            NotifySubDocInvalidationFunc aCallback,
-                            bool& aGeometryChanged)
+                            NotifySubDocInvalidationFunc aCallback)
   {
     // Bug 1251615: This canary is sometimes hit. We're still not sure why.
     mCanary.Check();
     bool transformChanged = !mTransform.FuzzyEqual(GetTransformForInvalidation(mLayer)) ||
                              mLayer->GetPostXScale() != mPostXScale ||
                              mLayer->GetPostYScale() != mPostYScale;
     const Maybe<ParentLayerIntRect>& otherClip = mLayer->GetLocalClipRect();
     nsIntRegion result;
@@ -211,49 +209,47 @@ public:
 
     Layer* otherMask = mLayer->GetMaskLayer();
     if ((mMaskLayer ? mMaskLayer->mLayer : nullptr) != otherMask ||
         ancestorMaskChanged ||
         (mUseClipRect != !!otherClip) ||
         mLayer->GetLocalOpacity() != mOpacity ||
         transformChanged)
     {
-      aGeometryChanged = true;
       result = OldTransformedBounds();
       LTI_DUMP(result, "oldtransform");
       LTI_DUMP(NewTransformedBounds(), "newtransform");
       AddRegion(result, NewTransformedBounds());
 
       // We can't bail out early because we need to update mChildrenChanged.
     }
 
-    nsIntRegion internal = ComputeChangeInternal(aPrefix, aCallback, aGeometryChanged);
+    nsIntRegion internal = ComputeChangeInternal(aPrefix, aCallback);
     LTI_DUMP(internal, "internal");
     AddRegion(result, internal);
     LTI_DUMP(mLayer->GetInvalidRegion().GetRegion(), "invalid");
     AddTransformedRegion(result, mLayer->GetInvalidRegion().GetRegion(), mTransform);
 
     if (mMaskLayer && otherMask) {
-      nsIntRegion mask = mMaskLayer->ComputeChange(aPrefix, aCallback, aGeometryChanged);
+      nsIntRegion mask = mMaskLayer->ComputeChange(aPrefix, aCallback);
       LTI_DUMP(mask, "mask");
       AddTransformedRegion(result, mask, mTransform);
     }
 
     for (size_t i = 0;
          i < std::min(mAncestorMaskLayers.Length(), mLayer->GetAncestorMaskLayerCount());
          i++)
     {
-      nsIntRegion mask = mAncestorMaskLayers[i]->ComputeChange(aPrefix, aCallback, aGeometryChanged);
+      nsIntRegion mask = mAncestorMaskLayers[i]->ComputeChange(aPrefix, aCallback);
       LTI_DUMP(mask, "ancestormask");
       AddTransformedRegion(result, mask, mTransform);
     }
 
     if (mUseClipRect && otherClip) {
       if (!mClipRect.IsEqualInterior(*otherClip)) {
-        aGeometryChanged = true;
         nsIntRegion tmp;
         tmp.Xor(mClipRect.ToUnknownRect(), otherClip->ToUnknownRect());
         LTI_DUMP(tmp, "clip");
         AddRegion(result, tmp);
       }
     }
 
     mLayer->ClearInvalidRect();
@@ -273,18 +269,17 @@ public:
   }
 
   virtual IntRect OldTransformedBounds()
   {
     return TransformRect(mVisibleRegion.ToUnknownRegion().GetBounds(), mTransform);
   }
 
   virtual nsIntRegion ComputeChangeInternal(const char* aPrefix,
-                                            NotifySubDocInvalidationFunc aCallback,
-                                            bool& aGeometryChanged)
+                                            NotifySubDocInvalidationFunc aCallback)
   {
     return IntRect();
   }
 
   RefPtr<Layer> mLayer;
   UniquePtr<LayerPropertiesBase> mMaskLayer;
   nsTArray<UniquePtr<LayerPropertiesBase>> mAncestorMaskLayers;
   nsIntRegion mVisibleRegion;
@@ -311,32 +306,30 @@ struct ContainerLayerProperties : public
   }
 
 protected:
   ContainerLayerProperties(const ContainerLayerProperties& a) = delete;
   ContainerLayerProperties& operator=(const ContainerLayerProperties& a) = delete;
 
 public:
   nsIntRegion ComputeChangeInternal(const char *aPrefix,
-                                    NotifySubDocInvalidationFunc aCallback,
-                                    bool& aGeometryChanged) override
+                                    NotifySubDocInvalidationFunc aCallback) override
   {
     // Make sure we got our virtual call right
     mSubtypeCanary.Check();
     ContainerLayer* container = mLayer->AsContainerLayer();
     nsIntRegion invalidOfLayer; // Invalid regions of this layer.
     nsIntRegion result;         // Invliad regions for children only.
 
     container->CheckCanary();
 
     bool childrenChanged = false;
 
     if (mPreXScale != container->GetPreXScale() ||
         mPreYScale != container->GetPreYScale()) {
-      aGeometryChanged = true;
       invalidOfLayer = OldTransformedBounds();
       AddRegion(invalidOfLayer, NewTransformedBounds());
       childrenChanged = true;
 
       // Can't bail out early, we need to update the child container layers
     }
 
     // A low frame rate is especially visible to users when scrolling, so we
@@ -370,17 +363,17 @@ public:
               LTI_DUMP(mChildren[j]->OldTransformedBounds(), "reordered child");
               AddRegion(result, mChildren[j]->OldTransformedBounds());
               childrenChanged |= true;
             }
             if (childsOldIndex >= mChildren.Length()) {
               MOZ_CRASH("Out of bounds");
             }
             // Invalidate any regions of the child that have changed:
-            nsIntRegion region = mChildren[childsOldIndex]->ComputeChange(LTI_DEEPER(aPrefix), aCallback, aGeometryChanged);
+            nsIntRegion region = mChildren[childsOldIndex]->ComputeChange(LTI_DEEPER(aPrefix), aCallback);
             i = childsOldIndex + 1;
             if (!region.IsEmpty()) {
               LTI_LOG("%s%p: child %p produced %s\n", aPrefix, mLayer.get(),
                 mChildren[childsOldIndex]->mLayer.get(), Stringify(region).c_str());
               AddRegion(result, region);
               childrenChanged |= true;
             }
           } else {
@@ -393,17 +386,16 @@ public:
           // |child| is new
           invalidateChildsCurrentArea = true;
         }
       } else {
         // |child| is new, or was reordered to a higher index
         invalidateChildsCurrentArea = true;
       }
       if (invalidateChildsCurrentArea) {
-        aGeometryChanged = true;
         LTI_DUMP(child->GetLocalVisibleRegion().ToUnknownRegion(), "invalidateChidlsCurrentArea");
         AddTransformedRegion(result, child->GetLocalVisibleRegion().ToUnknownRegion(),
                              GetTransformForInvalidation(child));
         if (aCallback) {
           NotifySubdocumentInvalidation(child, aCallback);
         } else {
           ClearInvalidations(child);
         }
@@ -480,23 +472,21 @@ struct ColorLayerProperties : public Lay
   { }
 
 protected:
   ColorLayerProperties(const ColorLayerProperties& a) = delete;
   ColorLayerProperties& operator=(const ColorLayerProperties& a) = delete;
 
 public:
   nsIntRegion ComputeChangeInternal(const char* aPrefix,
-                                    NotifySubDocInvalidationFunc aCallback,
-                                    bool& aGeometryChanged) override
+                                    NotifySubDocInvalidationFunc aCallback) override
   {
     ColorLayer* color = static_cast<ColorLayer*>(mLayer.get());
 
     if (mColor != color->GetColor()) {
-      aGeometryChanged = true;
       LTI_DUMP(NewTransformedBounds(), "color");
       return NewTransformedBounds();
     }
 
     nsIntRegion boundsDiff;
     boundsDiff.Xor(mBounds, color->GetBounds());
     LTI_DUMP(boundsDiff, "colorbounds");
 
@@ -521,33 +511,30 @@ struct BorderLayerProperties : public La
   { }
 
 protected:
   BorderLayerProperties(const BorderLayerProperties& a) = delete;
   BorderLayerProperties& operator=(const BorderLayerProperties& a) = delete;
 
 public:
   nsIntRegion ComputeChangeInternal(const char* aPrefix,
-                                    NotifySubDocInvalidationFunc aCallback,
-                                    bool& aGeometryChanged) override
+                                    NotifySubDocInvalidationFunc aCallback) override
   {
     BorderLayer* border = static_cast<BorderLayer*>(mLayer.get());
 
     if (!border->GetLocalVisibleRegion().ToUnknownRegion().IsEqual(mVisibleRegion)) {
-      aGeometryChanged = true;
       IntRect result = NewTransformedBounds();
       result = result.Union(OldTransformedBounds());
       return result;
     }
 
     if (!PodEqual(&mColors[0], &border->GetColors()[0], 4) ||
         !PodEqual(&mWidths[0], &border->GetWidths()[0], 4) ||
         !PodEqual(&mCorners[0], &border->GetCorners()[0], 4) ||
         !mRect.IsEqualEdges(border->GetRect())) {
-      aGeometryChanged = true;
       LTI_DUMP(NewTransformedBounds(), "bounds");
       return NewTransformedBounds();
     }
 
     return nsIntRegion();
   }
 
   BorderColors mColors;
@@ -566,32 +553,29 @@ struct TextLayerProperties : public Laye
   { }
 
 protected:
   TextLayerProperties(const TextLayerProperties& a) = delete;
   TextLayerProperties& operator=(const TextLayerProperties& a) = delete;
 
 public:
   nsIntRegion ComputeChangeInternal(const char* aPrefix,
-                                    NotifySubDocInvalidationFunc aCallback,
-                                    bool& aGeometryChanged) override
+                                    NotifySubDocInvalidationFunc aCallback) override
   {
     TextLayer* text = static_cast<TextLayer*>(mLayer.get());
 
     if (!text->GetLocalVisibleRegion().ToUnknownRegion().IsEqual(mVisibleRegion)) {
-      aGeometryChanged = true;
       IntRect result = NewTransformedBounds();
       result = result.Union(OldTransformedBounds());
       return result;
     }
 
     if (!mBounds.IsEqualEdges(text->GetBounds()) ||
         mGlyphs != text->GetGlyphs() ||
         mFont != text->GetScaledFont()) {
-      aGeometryChanged = true;
       LTI_DUMP(NewTransformedBounds(), "bounds");
       return NewTransformedBounds();
     }
 
     return nsIntRegion();
   }
 
   gfx::IntRect mBounds;
@@ -623,38 +607,35 @@ struct ImageLayerProperties : public Lay
   {
     if (mImageHost) {
       mLastProducerID = mImageHost->GetLastProducerID();
       mLastFrameID = mImageHost->GetLastFrameID();
     }
   }
 
   nsIntRegion ComputeChangeInternal(const char* aPrefix,
-                                    NotifySubDocInvalidationFunc aCallback,
-                                    bool& aGeometryChanged) override
+                                    NotifySubDocInvalidationFunc aCallback) override
   {
     ImageLayer* imageLayer = static_cast<ImageLayer*>(mLayer.get());
 
     if (!imageLayer->GetLocalVisibleRegion().ToUnknownRegion().IsEqual(mVisibleRegion)) {
-      aGeometryChanged = true;
       IntRect result = NewTransformedBounds();
       result = result.Union(OldTransformedBounds());
       return result;
     }
 
     ImageContainer* container = imageLayer->GetContainer();
     ImageHost* host = GetImageHost(imageLayer);
     if (mContainer != container ||
         mSamplingFilter != imageLayer->GetSamplingFilter() ||
         mScaleToSize != imageLayer->GetScaleToSize() ||
         mScaleMode != imageLayer->GetScaleMode() ||
         host != mImageHost ||
         (host && host->GetProducerID() != mLastProducerID) ||
         (host && host->GetFrameID() != mLastFrameID)) {
-      aGeometryChanged = true;
 
       if (mIsMask) {
         // Mask layers have an empty visible region, so we have to
         // use the image size instead.
         IntSize size;
         if (container) {
           size = container->GetCurrentSize();
         }
@@ -687,25 +668,22 @@ struct CanvasLayerProperties : public La
   explicit CanvasLayerProperties(CanvasLayer* aCanvas)
     : LayerPropertiesBase(aCanvas)
     , mImageHost(GetImageHost(aCanvas))
   {
     mFrameID = mImageHost ? mImageHost->GetFrameID() : -1;
   }
 
   nsIntRegion ComputeChangeInternal(const char* aPrefix,
-                                    NotifySubDocInvalidationFunc aCallback,
-                                    bool& aGeometryChanged) override
+                                    NotifySubDocInvalidationFunc aCallback) override
   {
     CanvasLayer* canvasLayer = static_cast<CanvasLayer*>(mLayer.get());
 
     ImageHost* host = GetImageHost(canvasLayer);
     if (host && host->GetFrameID() != mFrameID) {
-      aGeometryChanged = true;
-
       LTI_DUMP(NewTransformedBounds(), "frameId");
       return NewTransformedBounds();
     }
 
     return IntRect();
   }
 
   RefPtr<ImageHost> mImageHost;
@@ -769,40 +747,32 @@ LayerProperties::ClearInvalidations(Laye
             ClearInvalidations(layer->GetAncestorMaskLayerAt(i));
           }
 
         }
       );
 }
 
 nsIntRegion
-LayerPropertiesBase::ComputeDifferences(Layer* aRoot, NotifySubDocInvalidationFunc aCallback,
-                                        bool* aGeometryChanged = nullptr)
+LayerPropertiesBase::ComputeDifferences(Layer* aRoot, NotifySubDocInvalidationFunc aCallback)
 {
   NS_ASSERTION(aRoot, "Must have a layer tree to compare against!");
   if (mLayer != aRoot) {
     if (aCallback) {
       NotifySubdocumentInvalidation(aRoot, aCallback);
     } else {
       ClearInvalidations(aRoot);
     }
     IntRect result = TransformRect(
       aRoot->GetLocalVisibleRegion().ToUnknownRegion().GetBounds(),
       aRoot->GetLocalTransform());
     result = result.Union(OldTransformedBounds());
-    if (aGeometryChanged != nullptr) {
-      *aGeometryChanged = true;
-    }
     return result;
   }
-  bool geometryChanged = (aGeometryChanged != nullptr) ? *aGeometryChanged : false;
-  nsIntRegion invalid = ComputeChange("  ", aCallback, geometryChanged);
-  if (aGeometryChanged != nullptr) {
-    *aGeometryChanged = geometryChanged;
-  }
+  nsIntRegion invalid = ComputeChange("  ", aCallback);
   return invalid;
 }
 
 void
 LayerPropertiesBase::MoveBy(const IntPoint& aOffset)
 {
   mTransform.PostTranslate(aOffset.x, aOffset.y, 0);
 }
--- a/gfx/layers/LayerTreeInvalidation.h
+++ b/gfx/layers/LayerTreeInvalidation.h
@@ -60,18 +60,17 @@ public:
    * tree and generates the changed rectangle.
    *
    * @param aRoot Root layer of the layer tree to compare against.
    * @param aCallback If specified, callback to call when ContainerLayers
    * are invalidated.
    * @return Painted area changed by the layer tree changes.
    */
   virtual nsIntRegion ComputeDifferences(Layer* aRoot,
-                                         NotifySubDocInvalidationFunc aCallback,
-                                         bool* aGeometryChanged = nullptr) = 0;
+                                         NotifySubDocInvalidationFunc aCallback) = 0;
 
   virtual void MoveBy(const gfx::IntPoint& aOffset) = 0;
 };
 
 } // namespace layers
 } // namespace mozilla
 
 #endif /* GFX_LAYER_TREE_INVALIDATON_H */
--- a/gfx/layers/composite/LayerManagerComposite.cpp
+++ b/gfx/layers/composite/LayerManagerComposite.cpp
@@ -142,17 +142,16 @@ HostLayerManager::RecordUpdateTime(float
  * LayerManagerComposite
  */
 LayerManagerComposite::LayerManagerComposite(Compositor* aCompositor)
 : mUnusedApzTransformWarning(false)
 , mDisabledApzWarning(false)
 , mCompositor(aCompositor)
 , mInTransaction(false)
 , mIsCompositorReady(false)
-, mGeometryChanged(true)
 #if defined(MOZ_WIDGET_ANDROID)
 , mScreenPixelsTarget(nullptr)
 #endif // defined(MOZ_WIDGET_ANDROID)
 {
   mTextRenderer = new TextRenderer();
   mDiagnostics = MakeUnique<Diagnostics>();
   MOZ_ASSERT(aCompositor);
 
@@ -430,19 +429,16 @@ LayerManagerComposite::EndTransaction(co
   // ComputeEffectiveTransforms (so the correct video frame size is picked) and
   // also to compute invalid regions properly.
   SetCompositionTime(aTimeStamp);
 
   if (mRoot && !(aFlags & END_NO_IMMEDIATE_REDRAW)) {
     MOZ_ASSERT(!aTimeStamp.IsNull());
     UpdateAndRender();
     mCompositor->FlushPendingNotifyNotUsed();
-  } else {
-    // Modified the layer tree.
-    mGeometryChanged = true;
   }
 
   mCompositor->ClearTargetContext();
   mTarget = nullptr;
 
 #ifdef MOZ_LAYERS_HAVE_LOG
   Log();
   MOZ_LAYERS_LOG(("]----- EndTransaction"));
@@ -463,17 +459,17 @@ LayerManagerComposite::UpdateAndRender()
     // Effective transforms are needed by ComputeDifferences().
     mRoot->ComputeEffectiveTransforms(gfx::Matrix4x4());
     didEffectiveTransforms = true;
 
     // We need to compute layer tree differences even if we're not going to
     // immediately use the resulting damage area, since ComputeDifferences
     // is also responsible for invalidates intermediate surfaces in
     // ContainerLayers.
-    nsIntRegion changed = mClonedLayerTreeProperties->ComputeDifferences(mRoot, nullptr, &mGeometryChanged);
+    nsIntRegion changed = mClonedLayerTreeProperties->ComputeDifferences(mRoot, nullptr);
 
     if (mTarget) {
       // Since we're composing to an external target, we're not going to use
       // the damage region from layers changes - we want to composite
       // everything in the target bounds. Instead we accumulate the layers
       // damage region for the next window composite.
       mInvalidRegion.Or(mInvalidRegion, changed);
     } else {
@@ -511,17 +507,16 @@ LayerManagerComposite::UpdateAndRender()
     // so we don't need to pass any global transform here.
     mRoot->ComputeEffectiveTransforms(gfx::Matrix4x4());
   }
 
   Render(invalid, opaque);
 #if defined(MOZ_WIDGET_ANDROID)
   RenderToPresentationSurface();
 #endif
-  mGeometryChanged = false;
   mWindowOverlayChanged = false;
 
   // Update cached layer tree information.
   mClonedLayerTreeProperties = LayerProperties::CloneFrom(GetRoot());
 }
 
 already_AddRefed<DrawTarget>
 LayerManagerComposite::CreateOptimalMaskDrawTarget(const IntSize &aSize)
--- a/gfx/layers/composite/LayerManagerComposite.h
+++ b/gfx/layers/composite/LayerManagerComposite.h
@@ -480,17 +480,16 @@ private:
                            CSSIntRegion> VisibleRegions;
   VisibleRegions mVisibleRegions;
 
   bool mInTransaction;
   bool mIsCompositorReady;
 
   RefPtr<CompositingRenderTarget> mTwoPassTmpTarget;
   RefPtr<TextRenderer> mTextRenderer;
-  bool mGeometryChanged;
 
 #ifdef USE_SKIA
   /**
    * Render paint and composite times above the frame.
    */
   void DrawPaintTimes(Compositor* aCompositor);
   RefPtr<PaintCounter> mPaintCounter;
 #endif