Bug 570294, part b: Add a Mutated() API allowing Layers to notify their managers that their Layer attributes have changed. r=Bas sr=roc
authorChris Jones <jones.chris.g@gmail.com>
Wed, 21 Jul 2010 16:17:33 -0500
changeset 48135 6ee9399bde01da63f0d95e3f7bd8f811262407d4
parent 48134 c428d17cd3e74d97c28881888adde8c007346446
child 48136 f3ee7f068902cfcd619766029fc92e6736ea82b4
push id14589
push usercjones@mozilla.com
push dateFri, 23 Jul 2010 17:12:29 +0000
treeherderautoland@49185ce20807 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas, roc
bugs570294
milestone2.0b3pre
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 570294, part b: Add a Mutated() API allowing Layers to notify their managers that their Layer attributes have changed. r=Bas sr=roc
gfx/layers/Layers.h
--- a/gfx/layers/Layers.h
+++ b/gfx/layers/Layers.h
@@ -210,16 +210,22 @@ public:
   virtual void SetRoot(Layer* aLayer) = 0;
   /**
    * Can be called anytime
    */
   Layer* GetRoot() { return mRoot; }
 
   /**
    * CONSTRUCTION PHASE ONLY
+   * Called when a managee has mutated.
+   */
+  virtual void Mutated(Layer* aLayer) { }
+
+  /**
+   * CONSTRUCTION PHASE ONLY
    * Create a ThebesLayer for this manager's layer tree.
    */
   virtual already_AddRefed<ThebesLayer> CreateThebesLayer() = 0;
   /**
    * CONSTRUCTION PHASE ONLY
    * Create a ContainerLayer for this manager's layer tree.
    */
   virtual already_AddRefed<ContainerLayer> CreateContainerLayer() = 0;
@@ -327,32 +333,44 @@ public:
   /**
    * CONSTRUCTION PHASE ONLY
    * If this is called with aOpaque set to true, the caller is promising
    * that by the end of this transaction the entire visible region
    * (as specified by SetVisibleRegion) will be filled with opaque
    * content. This enables some internal quality and performance
    * optimizations.
    */
-  void SetIsOpaqueContent(PRBool aOpaque) { mIsOpaqueContent = aOpaque; }
+  void SetIsOpaqueContent(PRBool aOpaque)
+  {
+    mIsOpaqueContent = aOpaque;
+    Mutated();
+  }
   /**
    * CONSTRUCTION PHASE ONLY
    * Tell this layer which region will be visible. It is the responsibility
    * of the caller to ensure that content outside this region does not
    * contribute to the final visible window. This can be an
    * overapproximation to the true visible region.
    */
-  virtual void SetVisibleRegion(const nsIntRegion& aRegion) { mVisibleRegion = aRegion; }
+  virtual void SetVisibleRegion(const nsIntRegion& aRegion)
+  {
+    mVisibleRegion = aRegion;
+    Mutated();
+  }
 
   /**
    * CONSTRUCTION PHASE ONLY
    * Set the opacity which will be applied to this layer as it
    * is composited to the destination.
    */
-  void SetOpacity(float aOpacity) { mOpacity = aOpacity; }
+  void SetOpacity(float aOpacity)
+  {
+    mOpacity = aOpacity;
+    Mutated();
+  }
 
   /**
    * CONSTRUCTION PHASE ONLY
    * Set a clip rect which will be applied to this layer as it is
    * composited to the destination. The coordinates are relative to
    * the parent layer (i.e. the contents of this layer
    * are transformed before this clip rect is applied).
    * For the root layer, the coordinates are relative to the widget,
@@ -360,16 +378,17 @@ public:
    * If aRect is null no clipping will be performed. 
    */
   void SetClipRect(const nsIntRect* aRect)
   {
     mUseClipRect = aRect != nsnull;
     if (aRect) {
       mClipRect = *aRect;
     }
+    Mutated();
   }
   /**
    * CONSTRUCTION PHASE ONLY
    * Set a clip rect which will be applied to this layer as it is
    * composited to the destination. The coordinates are relative to
    * the parent layer (i.e. the contents of this layer
    * are transformed before this clip rect is applied).
    * For the root layer, the coordinates are relative to the widget,
@@ -379,26 +398,31 @@ public:
   void IntersectClipRect(const nsIntRect& aRect)
   {
     if (mUseClipRect) {
       mClipRect.IntersectRect(mClipRect, aRect);
     } else {
       mUseClipRect = PR_TRUE;
       mClipRect = aRect;
     }
+    Mutated();
   }
 
   /**
    * CONSTRUCTION PHASE ONLY
    * Tell this layer what its transform should be. The transformation
    * is applied when compositing the layer into its parent container.
    * XXX Currently only transformations corresponding to 2D affine transforms
    * are supported.
    */
-  void SetTransform(const gfx3DMatrix& aMatrix) { mTransform = aMatrix; }
+  void SetTransform(const gfx3DMatrix& aMatrix)
+  {
+    mTransform = aMatrix;
+    Mutated();
+  }
 
   // These getters can be used anytime.
   float GetOpacity() { return mOpacity; }
   const nsIntRect* GetClipRect() { return mUseClipRect ? &mClipRect : nsnull; }
   PRBool IsOpaqueContent() { return mIsOpaqueContent; }
   const nsIntRegion& GetVisibleRegion() { return mVisibleRegion; }
   ContainerLayer* GetParent() { return mParent; }
   Layer* GetNextSibling() { return mNextSibling; }
@@ -473,16 +497,18 @@ protected:
     mPrevSibling(nsnull),
     mImplData(aImplData),
     mUserData(nsnull),
     mOpacity(1.0),
     mUseClipRect(PR_FALSE),
     mIsOpaqueContent(PR_FALSE)
     {}
 
+  void Mutated() { mManager->Mutated(this); }
+
   // Print interesting information about this into aTo.  Internally
   // used to implement Dump*() and Log*().  If subclasses have
   // additional interesting properties, they should override this with
   // an implementation that first calls the base implementation then
   // appends additional info to aTo.
   virtual nsACString& PrintInfo(nsACString& aTo, const char* aPrefix);
 
   LayerManager* mManager;