Bug 739679 - Part 1: Add BasicImplData header into its own file. r=roc a=blocking-fennec
authorBenoit Girard <b56girard@gmail.com>
Mon, 16 Apr 2012 18:23:03 -0400
changeset 95430 a0ffd7065ef5db4829fe706fb875ef2cf5e38fbd
parent 95429 ad583c18d336bc3c2ffa93f947eaf9980fd5c299
child 95431 ee415e3f509d36f663a2abdbe99dfb7d94f63d31
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, blocking-fennec
bugs739679
milestone14.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 739679 - Part 1: Add BasicImplData header into its own file. r=roc a=blocking-fennec
gfx/layers/basic/BasicImplData.h
gfx/layers/basic/BasicLayers.cpp
gfx/layers/basic/BasicLayers.h
new file mode 100644
--- /dev/null
+++ b/gfx/layers/basic/BasicImplData.h
@@ -0,0 +1,118 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef GFX_BASICIMPLDATA_H
+#define GFX_BASICIMPLDATA_H
+
+namespace mozilla {
+namespace layers {
+
+/**
+ * This is the ImplData for all Basic layers. It also exposes methods
+ * private to the Basic implementation that are common to all Basic layer types.
+ * In particular, there is an internal Paint() method that we can use
+ * to paint the contents of non-Thebes layers.
+ *
+ * The class hierarchy for Basic layers is like this:
+ *                                 BasicImplData
+ * Layer                            |   |   |
+ *  |                               |   |   |
+ *  +-> ContainerLayer              |   |   |
+ *  |    |                          |   |   |
+ *  |    +-> BasicContainerLayer <--+   |   |
+ *  |                                   |   |
+ *  +-> ThebesLayer                     |   |
+ *  |    |                              |   |
+ *  |    +-> BasicThebesLayer <---------+   |
+ *  |                                       |
+ *  +-> ImageLayer                          |
+ *       |                                  |
+ *       +-> BasicImageLayer <--------------+
+ */
+class BasicImplData {
+public:
+  BasicImplData() : mHidden(false),
+    mClipToVisibleRegion(false),
+    mDrawAtomically(false),
+    mOperator(gfxContext::OPERATOR_OVER)
+  {
+    MOZ_COUNT_CTOR(BasicImplData);
+  }
+  virtual ~BasicImplData()
+  {
+    MOZ_COUNT_DTOR(BasicImplData);
+  }
+
+  /**
+   * Layers that paint themselves, such as ImageLayers, should paint
+   * in response to this method call. aContext will already have been
+   * set up to account for all the properties of the layer (transform,
+   * opacity, etc).
+   */
+  virtual void Paint(gfxContext* aContext) {}
+
+  /**
+   * Like Paint() but called for ThebesLayers with the additional parameters
+   * they need.
+   * If mClipToVisibleRegion is set, then the layer must clip to its
+   * effective visible region (snapped or unsnapped, it doesn't matter).
+   */
+  virtual void PaintThebes(gfxContext* aContext,
+                           LayerManager::DrawThebesLayerCallback aCallback,
+                           void* aCallbackData,
+                           ReadbackProcessor* aReadback) {}
+
+  virtual ShadowableLayer* AsShadowableLayer() { return nsnull; }
+
+  /**
+   * Implementations return true here if they *must* retain their
+   * layer contents.  This is true of shadowable layers with shadows,
+   * because there's no target on which to composite directly in the
+   * layer-publishing child process.
+   */
+  virtual bool MustRetainContent() { return false; }
+
+  /**
+   * Layers will get this call when their layer manager is destroyed, this
+   * indicates they should clear resources they don't really need after their
+   * LayerManager ceases to exist.
+   */
+  virtual void ClearCachedResources() {}
+
+  /**
+   * This variable is set by MarkLayersHidden() before painting. It indicates
+   * that the layer should not be composited during this transaction.
+   */
+  void SetHidden(bool aCovered) { mHidden = aCovered; }
+  bool IsHidden() const { return false; }
+  /**
+   * This variable is set by MarkLayersHidden() before painting. This is
+   * the operator to be used when compositing the layer in this transaction. It must
+   * be OVER or SOURCE.
+   */
+  void SetOperator(gfxContext::GraphicsOperator aOperator)
+  {
+    NS_ASSERTION(aOperator == gfxContext::OPERATOR_OVER ||
+                 aOperator == gfxContext::OPERATOR_SOURCE,
+                 "Bad composition operator");
+    mOperator = aOperator;
+  }
+  gfxContext::GraphicsOperator GetOperator() const { return mOperator; }
+
+  bool GetClipToVisibleRegion() { return mClipToVisibleRegion; }
+  void SetClipToVisibleRegion(bool aClip) { mClipToVisibleRegion = aClip; }
+
+  void SetDrawAtomically(bool aDrawAtomically) { mDrawAtomically = aDrawAtomically; }
+
+protected:
+  bool mHidden;
+  bool mClipToVisibleRegion;
+  bool mDrawAtomically;
+  gfxContext::GraphicsOperator mOperator;
+};
+
+} // layers
+} // mozilla
+
+#endif
--- a/gfx/layers/basic/BasicLayers.cpp
+++ b/gfx/layers/basic/BasicLayers.cpp
@@ -43,16 +43,17 @@
 #include "mozilla/layers/PLayerChild.h"
 #include "mozilla/layers/PLayersChild.h"
 #include "mozilla/layers/PLayersParent.h"
 #include "mozilla/gfx/2D.h"
 
 #include "ipc/ShadowLayerChild.h"
 
 #include "BasicLayers.h"
+#include "BasicImplData.h"
 #include "ImageLayers.h"
 #include "RenderTrace.h"
 
 #include "prprf.h"
 #include "nsTArray.h"
 #include "nsGUIEvent.h"
 #include "gfxContext.h"
 #include "gfxImageSurface.h"
@@ -73,120 +74,16 @@
 #include "pixman.h"
 
 namespace mozilla {
 namespace layers {
 
 class BasicContainerLayer;
 class ShadowableLayer;
 
-/**
- * This is the ImplData for all Basic layers. It also exposes methods
- * private to the Basic implementation that are common to all Basic layer types.
- * In particular, there is an internal Paint() method that we can use
- * to paint the contents of non-Thebes layers.
- *
- * The class hierarchy for Basic layers is like this:
- *                                 BasicImplData
- * Layer                            |   |   |
- *  |                               |   |   |
- *  +-> ContainerLayer              |   |   |
- *  |    |                          |   |   |
- *  |    +-> BasicContainerLayer <--+   |   |
- *  |                                   |   |
- *  +-> ThebesLayer                     |   |
- *  |    |                              |   |
- *  |    +-> BasicThebesLayer <---------+   |
- *  |                                       |
- *  +-> ImageLayer                          |
- *       |                                  |
- *       +-> BasicImageLayer <--------------+
- */
-class BasicImplData {
-public:
-  BasicImplData() : mHidden(false),
-    mClipToVisibleRegion(false),
-    mDrawAtomically(false),
-    mOperator(gfxContext::OPERATOR_OVER)
-  {
-    MOZ_COUNT_CTOR(BasicImplData);
-  }
-  virtual ~BasicImplData()
-  {
-    MOZ_COUNT_DTOR(BasicImplData);
-  }
-
-  /**
-   * Layers that paint themselves, such as ImageLayers, should paint
-   * in response to this method call. aContext will already have been
-   * set up to account for all the properties of the layer (transform,
-   * opacity, etc).
-   */
-  virtual void Paint(gfxContext* aContext) {}
-
-  /**
-   * Like Paint() but called for ThebesLayers with the additional parameters
-   * they need.
-   * If mClipToVisibleRegion is set, then the layer must clip to its
-   * effective visible region (snapped or unsnapped, it doesn't matter).
-   */
-  virtual void PaintThebes(gfxContext* aContext,
-                           LayerManager::DrawThebesLayerCallback aCallback,
-                           void* aCallbackData,
-                           ReadbackProcessor* aReadback) {}
-
-  virtual ShadowableLayer* AsShadowableLayer() { return nsnull; }
-
-  /**
-   * Implementations return true here if they *must* retain their
-   * layer contents.  This is true of shadowable layers with shadows,
-   * because there's no target on which to composite directly in the
-   * layer-publishing child process.
-   */
-  virtual bool MustRetainContent() { return false; }
-
-  /**
-   * Layers will get this call when their layer manager is destroyed, this
-   * indicates they should clear resources they don't really need after their
-   * LayerManager ceases to exist.
-   */
-  virtual void ClearCachedResources() {}
-
-  /**
-   * This variable is set by MarkLayersHidden() before painting. It indicates
-   * that the layer should not be composited during this transaction.
-   */
-  void SetHidden(bool aCovered) { mHidden = aCovered; }
-  bool IsHidden() const { return false; }
-  /**
-   * This variable is set by MarkLayersHidden() before painting. This is
-   * the operator to be used when compositing the layer in this transaction. It must
-   * be OVER or SOURCE.
-   */
-  void SetOperator(gfxContext::GraphicsOperator aOperator)
-  {
-    NS_ASSERTION(aOperator == gfxContext::OPERATOR_OVER ||
-                 aOperator == gfxContext::OPERATOR_SOURCE,
-                 "Bad composition operator");
-    mOperator = aOperator;
-  }
-  gfxContext::GraphicsOperator GetOperator() const { return mOperator; }
-
-  bool GetClipToVisibleRegion() { return mClipToVisibleRegion; }
-  void SetClipToVisibleRegion(bool aClip) { mClipToVisibleRegion = aClip; }
-
-  void SetDrawAtomically(bool aDrawAtomically) { mDrawAtomically = aDrawAtomically; }
-
-protected:
-  bool mHidden;
-  bool mClipToVisibleRegion;
-  bool mDrawAtomically;
-  gfxContext::GraphicsOperator mOperator;
-};
-
 class AutoSetOperator {
 public:
   AutoSetOperator(gfxContext* aContext, gfxContext::GraphicsOperator aOperator) {
     if (aOperator != gfxContext::OPERATOR_OVER) {
       aContext->SetOperator(aOperator);
       mContext = aContext;
     }
   }
@@ -2112,63 +2009,23 @@ BasicLayerManager::CreateCanvasLayer()
 already_AddRefed<ReadbackLayer>
 BasicLayerManager::CreateReadbackLayer()
 {
   NS_ASSERTION(InConstruction(), "Only allowed in construction phase");
   nsRefPtr<ReadbackLayer> layer = new BasicReadbackLayer(this);
   return layer.forget();
 }
 
-class BasicShadowableThebesLayer;
-class BasicShadowableLayer : public ShadowableLayer
+BasicShadowableLayer::~BasicShadowableLayer()
 {
-public:
-  BasicShadowableLayer()
-  {
-    MOZ_COUNT_CTOR(BasicShadowableLayer);
-  }
-
-  ~BasicShadowableLayer()
-  {
-    if (HasShadow()) {
-      PLayerChild::Send__delete__(GetShadow());
-    }
-    MOZ_COUNT_DTOR(BasicShadowableLayer);
-  }
-
-  void SetShadow(PLayerChild* aShadow)
-  {
-    NS_ABORT_IF_FALSE(!mShadow, "can't have two shadows (yet)");
-    mShadow = aShadow;
+  if (HasShadow()) {
+    PLayerChild::Send__delete__(GetShadow());
   }
-
-  virtual void SetBackBuffer(const SurfaceDescriptor& aBuffer)
-  {
-    NS_RUNTIMEABORT("if this default impl is called, |aBuffer| leaks");
-  }
-  
-  virtual void SetBackBufferYUVImage(gfxSharedImageSurface* aYBuffer,
-                                     gfxSharedImageSurface* aUBuffer,
-                                     gfxSharedImageSurface* aVBuffer)
-  {
-    NS_RUNTIMEABORT("if this default impl is called, |aBuffer| leaks");
-  }
-
-  virtual void Disconnect()
-  {
-    // This is an "emergency Disconnect()", called when the compositing
-    // process has died.  |mShadow| and our Shmem buffers are
-    // automatically managed by IPDL, so we don't need to explicitly
-    // free them here (it's hard to get that right on emergency
-    // shutdown anyway).
-    mShadow = nsnull;
-  }
-
-  virtual BasicShadowableThebesLayer* AsThebes() { return nsnull; }
-};
+  MOZ_COUNT_DTOR(BasicShadowableLayer);
+}
 
 static ShadowableLayer*
 ToShadowable(Layer* aLayer)
 {
   return ToData(aLayer)->AsShadowableLayer();
 }
 
 // Some layers, like ReadbackLayers, can't be shadowed and shadowing
--- a/gfx/layers/basic/BasicLayers.h
+++ b/gfx/layers/basic/BasicLayers.h
@@ -273,12 +273,55 @@ private:
   /**
    * Forward transaction results to the parent context.
    */
   void ForwardTransaction();
 
   LayerRefArray mKeepAlive;
 };
 
+class BasicShadowableThebesLayer;
+class BasicShadowableLayer : public ShadowableLayer
+{
+public:
+  BasicShadowableLayer()
+  {
+    MOZ_COUNT_CTOR(BasicShadowableLayer);
+  }
+
+  ~BasicShadowableLayer();
+
+  void SetShadow(PLayerChild* aShadow)
+  {
+    NS_ABORT_IF_FALSE(!mShadow, "can't have two shadows (yet)");
+    mShadow = aShadow;
+  }
+
+  virtual void SetBackBuffer(const SurfaceDescriptor& aBuffer)
+  {
+    NS_RUNTIMEABORT("if this default impl is called, |aBuffer| leaks");
+  }
+  
+  virtual void SetBackBufferYUVImage(gfxSharedImageSurface* aYBuffer,
+                                     gfxSharedImageSurface* aUBuffer,
+                                     gfxSharedImageSurface* aVBuffer)
+  {
+    NS_RUNTIMEABORT("if this default impl is called, |aBuffer| leaks");
+  }
+
+  virtual void Disconnect()
+  {
+    // This is an "emergency Disconnect()", called when the compositing
+    // process has died.  |mShadow| and our Shmem buffers are
+    // automatically managed by IPDL, so we don't need to explicitly
+    // free them here (it's hard to get that right on emergency
+    // shutdown anyway).
+    mShadow = nsnull;
+  }
+
+  virtual BasicShadowableThebesLayer* AsThebes() { return nsnull; }
+};
+
+
 }
 }
 
 #endif /* GFX_BASICLAYERS_H */