Bug 782786 - BasicCanvasLayer: avoid UpdateSurface of non-dirty canvases - r=BenWa
☠☠ backed out by c95b9d40a173 ☠ ☠
authorBenoit Jacob <bjacob@mozilla.com>
Thu, 23 Aug 2012 14:56:23 -0400
changeset 105239 156eaa94f73c9110bd521063f08fefff432209e0
parent 105238 05d1a3fba90bd35e41719d48a28641952c9fb454
child 105241 da0aa4b65f8429596939f3ef441af682d1ca60e9
push id55
push usershu@rfrn.org
push dateThu, 30 Aug 2012 01:33:09 +0000
reviewersBenWa
bugs782786
milestone17.0a1
Bug 782786 - BasicCanvasLayer: avoid UpdateSurface of non-dirty canvases - r=BenWa
gfx/layers/basic/BasicCanvasLayer.cpp
--- a/gfx/layers/basic/BasicCanvasLayer.cpp
+++ b/gfx/layers/basic/BasicCanvasLayer.cpp
@@ -115,33 +115,33 @@ BasicCanvasLayer::Initialize(const Data&
   }
 
   mBounds.SetRect(0, 0, aData.mSize.width, aData.mSize.height);
 }
 
 void
 BasicCanvasLayer::UpdateSurface(gfxASurface* aDestSurface, Layer* aMaskLayer)
 {
+  if (!mDirty)
+    return;
+  mDirty = false;
+
   if (mDrawTarget) {
     mDrawTarget->Flush();
     // TODO Fix me before turning accelerated quartz canvas by default
     //mSurface = gfxPlatform::GetPlatform()->GetThebesSurfaceForDrawTarget(mDrawTarget);
   }
 
   if (!mGLContext && aDestSurface) {
     nsRefPtr<gfxContext> tmpCtx = new gfxContext(aDestSurface);
     tmpCtx->SetOperator(gfxContext::OPERATOR_SOURCE);
     BasicCanvasLayer::PaintWithOpacity(tmpCtx, 1.0f, aMaskLayer);
     return;
   }
 
-  if (!mDirty)
-    return;
-  mDirty = false;
-
   if (mGLContext) {
     if (aDestSurface && aDestSurface->GetType() != gfxASurface::SurfaceTypeImage) {
       NS_ASSERTION(aDestSurface->GetType() == gfxASurface::SurfaceTypeImage,
                    "Destination surface must be ImageSurface type");
       return;
     }
 
     // We need to read from the GLContext
@@ -224,16 +224,19 @@ BasicCanvasLayer::UpdateSurface(gfxASurf
       mSurface = resultSurf;
     }
   }
 }
 
 void
 BasicCanvasLayer::Paint(gfxContext* aContext, Layer* aMaskLayer)
 {
+  if (!mDirty)
+    return;
+
   if (IsHidden())
     return;
   UpdateSurface();
   FireDidTransactionCallback();
   PaintWithOpacity(aContext, GetEffectiveOpacity(), aMaskLayer);
 }
 
 void
@@ -388,16 +391,19 @@ BasicShadowableCanvasLayer::Initialize(c
 void
 BasicShadowableCanvasLayer::Paint(gfxContext* aContext, Layer* aMaskLayer)
 {
   if (!HasShadow()) {
     BasicCanvasLayer::Paint(aContext, aMaskLayer);
     return;
   }
 
+  if (!mDirty)
+    return;
+
   if (mGLContext &&
       !mForceReadback &&
       BasicManager()->GetParentBackendType() == mozilla::layers::LAYERS_OPENGL) {
     TextureImage::TextureShareType flags;
     // if process type is default, then it is single-process (non-e10s)
     if (XRE_GetProcessType() == GeckoProcessType_Default)
       flags = TextureImage::ThreadShared;
     else