Bug 782786 - BasicCanvasLayer: avoid UpdateSurface of non-dirty canvases - r=BenWa
authorBenoit Jacob <bjacob@mozilla.com>
Thu, 23 Aug 2012 14:56:23 -0400
changeset 103695 d63bb4e02b3dfd4e864ea18a5ba38699ed3d4a0b
parent 103694 920d71aa1d2cac4290607eca2aa9e973a69ae387
child 103700 1f93692fea1ebc066e7df9119da5d8f5d16d3565
push id14119
push userbjacob@mozilla.com
push dateTue, 28 Aug 2012 19:41:22 +0000
treeherdermozilla-inbound@d63bb4e02b3d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBenWa
bugs782786
milestone18.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 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
@@ -388,16 +388,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