Bug 770617 - Always mark inactive CanvasLayers as being dirty. r=cjones
authorMatt Woodrow <mwoodrow@mozilla.com>
Sun, 30 Sep 2012 19:20:25 +1300
changeset 114955 a680fd777c3b92d81650dd51c8cb3e9e5faf6398
parent 114954 b332f047a93bf9492740435cd0aad176bec2d162
child 114956 afd368401fdbf2f1f4ccdd417f17f91072c4f753
push id1708
push userakeybl@mozilla.com
push dateMon, 19 Nov 2012 21:10:21 +0000
treeherdermozilla-beta@27b14fe50103 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscjones
bugs770617
milestone18.0a1
first release with
nightly linux32
a680fd777c3b / 18.0a1 / 20120930030610 / files
nightly linux64
a680fd777c3b / 18.0a1 / 20120930030610 / files
nightly mac
a680fd777c3b / 18.0a1 / 20120930030610 / files
nightly win32
a680fd777c3b / 18.0a1 / 20120930030610 / files
nightly win64
a680fd777c3b / 18.0a1 / 20120930030610 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 770617 - Always mark inactive CanvasLayers as being dirty. r=cjones
gfx/layers/Layers.h
gfx/layers/basic/BasicCanvasLayer.cpp
gfx/layers/d3d10/CanvasLayerD3D10.cpp
gfx/layers/d3d9/CanvasLayerD3D9.cpp
gfx/layers/opengl/CanvasLayerOGL.cpp
--- a/gfx/layers/Layers.h
+++ b/gfx/layers/Layers.h
@@ -1385,16 +1385,36 @@ public:
 
   /**
    * Notify this CanvasLayer that the canvas surface contents have
    * changed (or will change) before the next transaction.
    */
   void Updated() { mDirty = true; SetInvalidRectToVisibleRegion(); }
 
   /**
+   * Notify this CanvasLayer that the canvas surface contents have
+   * been painted since the last change.
+   */
+  void Painted() { mDirty = false; }
+
+  /**
+   * Returns true if the canvas surface contents have changed since the
+   * last paint.
+   */
+  bool IsDirty() 
+  { 
+    // We can only tell if we are dirty if we're part of the
+    // widget's retained layer tree.
+    if (!mManager || !mManager->IsWidgetLayerManager()) {
+      return true;
+    }
+    return mDirty; 
+  }
+
+  /**
    * Register a callback to be called at the end of each transaction.
    */
   typedef void (* DidTransactionCallback)(void* aClosureData);
   void SetDidTransactionCallback(DidTransactionCallback aCallback, void* aClosureData)
   {
     mCallback = aCallback;
     mCallbackData = aClosureData;
   }
@@ -1438,16 +1458,18 @@ protected:
 
   /**
    * 0, 0, canvaswidth, canvasheight
    */
   nsIntRect mBounds;
   DidTransactionCallback mCallback;
   void* mCallbackData;
   gfxPattern::GraphicsFilter mFilter;
+
+private:
   /**
    * Set to true in Updated(), cleared during a transaction.
    */
   bool mDirty;
 };
 
 /**
  * ContainerLayer that refers to a "foreign" layer tree, through an
--- a/gfx/layers/basic/BasicCanvasLayer.cpp
+++ b/gfx/layers/basic/BasicCanvasLayer.cpp
@@ -115,19 +115,19 @@ BasicCanvasLayer::Initialize(const Data&
   }
 
   mBounds.SetRect(0, 0, aData.mSize.width, aData.mSize.height);
 }
 
 void
 BasicCanvasLayer::UpdateSurface(gfxASurface* aDestSurface, Layer* aMaskLayer)
 {
-  if (!mDirty)
+  if (!IsDirty())
     return;
-  mDirty = false;
+  Painted();
 
   if (mDrawTarget) {
     mDrawTarget->Flush();
     // TODO Fix me before turning accelerated quartz canvas by default
     //mSurface = gfxPlatform::GetPlatform()->GetThebesSurfaceForDrawTarget(mDrawTarget);
   }
 
   if (!mGLContext && aDestSurface) {
@@ -388,17 +388,17 @@ BasicShadowableCanvasLayer::Initialize(c
 void
 BasicShadowableCanvasLayer::Paint(gfxContext* aContext, Layer* aMaskLayer)
 {
   if (!HasShadow()) {
     BasicCanvasLayer::Paint(aContext, aMaskLayer);
     return;
   }
 
-  if (!mDirty)
+  if (!IsDirty())
     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)
--- a/gfx/layers/d3d10/CanvasLayerD3D10.cpp
+++ b/gfx/layers/d3d10/CanvasLayerD3D10.cpp
@@ -98,19 +98,19 @@ CanvasLayerD3D10::Initialize(const Data&
   }
 
   device()->CreateShaderResourceView(mTexture, NULL, getter_AddRefs(mSRView));
 }
 
 void
 CanvasLayerD3D10::UpdateSurface()
 {
-  if (!mDirty)
+  if (!IsDirty())
     return;
-  mDirty = false;
+  Painted();
 
   if (mDrawTarget) {
     mDrawTarget->Flush();
   } else if (mIsD2DTexture) {
     mSurface->Flush();
     return;
   } else if (mUsingSharedTexture) {
     // need to sync on the d3d9 device
--- a/gfx/layers/d3d9/CanvasLayerD3D9.cpp
+++ b/gfx/layers/d3d9/CanvasLayerD3D9.cpp
@@ -53,19 +53,19 @@ CanvasLayerD3D9::Initialize(const Data& 
   mBounds.SetRect(0, 0, aData.mSize.width, aData.mSize.height);
 
   CreateTexture();
 }
 
 void
 CanvasLayerD3D9::UpdateSurface()
 {
-  if (!mDirty && mTexture)
+  if (!IsDirty() && mTexture)
     return;
-  mDirty = false;
+  Painted();
 
   if (!mTexture) {
     CreateTexture();
 
     if (!mTexture) {
       NS_WARNING("CanvasLayerD3D9::Updated called but no texture present and creation failed!");
       return;
     }
--- a/gfx/layers/opengl/CanvasLayerOGL.cpp
+++ b/gfx/layers/opengl/CanvasLayerOGL.cpp
@@ -167,19 +167,19 @@ MakeIOSurfaceTexture(void* aCGIOSurfaceC
 
 /**
  * Following UpdateSurface(), mTexture on context this->gl() should contain the data we want,
  * unless mDelayedUpdates is true because of a too-large surface.
  */
 void
 CanvasLayerOGL::UpdateSurface()
 {
-  if (!mDirty)
+  if (!IsDirty())
     return;
-  mDirty = false;
+  Painted();
 
   if (mDestroyed || mDelayedUpdates) {
     return;
   }
 
 #if defined(MOZ_X11) && !defined(MOZ_PLATFORM_MAEMO)
   if (mPixmap) {
     return;