Bug 941559 - Invalidate nsDislaySolidColor display items when their color changes. r=roc
authorMatt Woodrow <mwoodrow@mozilla.com>
Mon, 25 Nov 2013 14:59:00 +1300
changeset 157285 3a9f42854971c92bc223e39cfb7167d79d8878e3
parent 157284 be686cc8419a8e50a54f56ec8db564c8770e86a5
child 157286 2ae10dc494d86c8dd2daf1107e8c57a451dbe53c
push id36679
push usermwoodrow@mozilla.com
push dateMon, 25 Nov 2013 02:51:54 +0000
treeherdermozilla-inbound@3a9f42854971 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs941559
milestone28.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 941559 - Invalidate nsDislaySolidColor display items when their color changes. r=roc
layout/base/nsDisplayList.h
layout/base/nsDisplayListInvalidation.h
--- a/layout/base/nsDisplayList.h
+++ b/layout/base/nsDisplayList.h
@@ -1929,27 +1929,42 @@ public:
     *aColor = mColor;
     return true;
   }
 
   virtual void Paint(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx) MOZ_OVERRIDE;
 
   virtual nsDisplayItemGeometry* AllocateGeometry(nsDisplayListBuilder* aBuilder) MOZ_OVERRIDE
   {
-    return new nsDisplayItemBoundsGeometry(this, aBuilder);
+    return new nsDisplaySolidColorGeometry(this, aBuilder, mColor);
   }
 
   virtual void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
                                          const nsDisplayItemGeometry* aGeometry,
                                          nsRegion* aInvalidRegion) MOZ_OVERRIDE
   {
-    const nsDisplayItemBoundsGeometry* geometry = static_cast<const nsDisplayItemBoundsGeometry*>(aGeometry);
+    const nsDisplaySolidColorGeometry* geometry =
+      static_cast<const nsDisplaySolidColorGeometry*>(aGeometry);
+    if (mColor != geometry->mColor) {
+      bool dummy;
+      aInvalidRegion->Or(geometry->mBounds, GetBounds(aBuilder, &dummy));
+      return;
+    }
     ComputeInvalidationRegionDifference(aBuilder, geometry, aInvalidRegion);
   }
 
+#ifdef MOZ_DUMP_PAINTING
+  virtual void WriteDebugInfo(FILE *aOutput) MOZ_OVERRIDE
+  {
+    fprintf(aOutput, "(rgba %d,%d,%d,%d)",
+            NS_GET_R(mColor), NS_GET_G(mColor),
+            NS_GET_B(mColor), NS_GET_A(mColor));
+  }
+#endif
+
   NS_DISPLAY_DECL_NAME("SolidColor", TYPE_SOLID_COLOR)
 
 private:
   nsRect  mBounds;
   nscolor mColor;
 };
 
 /**
--- a/layout/base/nsDisplayListInvalidation.h
+++ b/layout/base/nsDisplayListInvalidation.h
@@ -111,9 +111,22 @@ class nsDisplayBoxShadowInnerGeometry : 
 public:
   nsDisplayBoxShadowInnerGeometry(nsDisplayItem* aItem, nsDisplayListBuilder* aBuilder);
   
   virtual void MoveBy(const nsPoint& aOffset) MOZ_OVERRIDE;
 
   nsRect mPaddingRect;
 };
 
+class nsDisplaySolidColorGeometry : public nsDisplayItemBoundsGeometry
+{
+public:
+  nsDisplaySolidColorGeometry(nsDisplayItem* aItem,
+                              nsDisplayListBuilder* aBuilder,
+                              nscolor aColor)
+    : nsDisplayItemBoundsGeometry(aItem, aBuilder)
+    , mColor(aColor)
+  { }
+
+  nscolor mColor;
+};
+
 #endif /*NSDISPLAYLISTINVALIDATION_H_*/