Bug 1039150 - Don't trigger creation a backbuffer when we set a canvas to be opaque. r=roc, a=2.0+
authorMatt Woodrow <mwoodrow@mozilla.com>
Wed, 16 Jul 2014 18:15:39 +1200
changeset 209114 e82d6205a60a5adc6e98d0ddd55141be7799a486
parent 209113 88a84442b2161b9f51193ad0ae66d13203678a04
child 209115 b19c6c55d3dd3c62751b62219a84303c275e8d36
push id494
push userraliiev@mozilla.com
push dateMon, 25 Aug 2014 18:42:16 +0000
treeherdermozilla-release@a3cc3e46b571 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, 2
bugs1039150
milestone32.0a2
Bug 1039150 - Don't trigger creation a backbuffer when we set a canvas to be opaque. r=roc, a=2.0+
content/canvas/src/CanvasRenderingContext2D.cpp
--- a/content/canvas/src/CanvasRenderingContext2D.cpp
+++ b/content/canvas/src/CanvasRenderingContext2D.cpp
@@ -1056,20 +1056,16 @@ CanvasRenderingContext2D::InitializeWith
 NS_IMETHODIMP
 CanvasRenderingContext2D::SetIsOpaque(bool isOpaque)
 {
   if (isOpaque != mOpaque) {
     mOpaque = isOpaque;
     ClearTarget();
   }
 
-  if (mOpaque) {
-    EnsureTarget();
-  }
-
   return NS_OK;
 }
 
 NS_IMETHODIMP
 CanvasRenderingContext2D::SetIsIPC(bool isIPC)
 {
   if (isIPC != mIPC) {
     mIPC = isIPC;
@@ -4222,16 +4218,22 @@ CanvasRenderingContext2D::CreateImageDat
 
 static uint8_t g2DContextLayerUserData;
 
 already_AddRefed<CanvasLayer>
 CanvasRenderingContext2D::GetCanvasLayer(nsDisplayListBuilder* aBuilder,
                                          CanvasLayer *aOldLayer,
                                          LayerManager *aManager)
 {
+  if (mOpaque) {
+    // If we're opaque then make sure we have a surface so we paint black
+    // instead of transparent.
+    EnsureTarget();
+  }
+
   // Don't call EnsureTarget() ... if there isn't already a surface, then
   // we have nothing to paint and there is no need to create a surface just
   // to paint nothing. Also, EnsureTarget() can cause creation of a persistent
   // layer manager which must NOT happen during a paint.
   if (!mTarget || !IsTargetValid()) {
     // No DidTransactionCallback will be received, so mark the context clean
     // now so future invalidations will be dispatched.
     MarkContextClean();