Bug 1217662 - part 1 - make LayerManagerUserDataDestroy a static function of LayerManager; r=mattwoodrow
authorNathan Froyd <froydnj@mozilla.com>
Thu, 22 Oct 2015 15:39:30 -0400
changeset 304384 885d1c949522a96dbaf996755d7513e64053f76f
parent 304383 259d7b810268ec4878663870727a42c7cd885e08
child 304385 06a3f9d0ed7dcc1c54ba26f13a99a6a2f7c675fa
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1217662
milestone44.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 1217662 - part 1 - make LayerManagerUserDataDestroy a static function of LayerManager; r=mattwoodrow LayerManagerUserDataDestroy is a static function in Layers.h that we only ever take a pointer to, to use it as a destruction function for gfx::UserData. It's *possible* the compiler is smart enough to call it directly, rather than through the function pointer stored in gfx::UserData, but that seems highly unlikely. And LayerManagerUserDataDestroy does a virtual call anyway, so it's not as though it being inlined is particularly important. All of this is to say that we don't need to define LayerManagerUserDataDestroy in Layers.h; defining it out-of-line will be just as effective. Defining it out-of-line also means that we don't need the definition of LayerUserData anywhere in Layers.h, and we can move LayerUserData to a separate header.
gfx/layers/Layers.cpp
gfx/layers/Layers.h
--- a/gfx/layers/Layers.cpp
+++ b/gfx/layers/Layers.cpp
@@ -200,16 +200,22 @@ LayerManager::CreateImageContainer(Image
 }
 
 bool
 LayerManager::AreComponentAlphaLayersEnabled()
 {
   return gfxPrefs::ComponentAlphaEnabled();
 }
 
+/*static*/ void
+LayerManager::LayerUserDataDestroy(void* data)
+{
+  delete static_cast<LayerUserData*>(data);
+}
+
 //--------------------------------------------------
 // Layer
 
 Layer::Layer(LayerManager* aManager, void* aImplData) :
   mManager(aManager),
   mParent(nullptr),
   mNextSibling(nullptr),
   mPrevSibling(nullptr),
--- a/gfx/layers/Layers.h
+++ b/gfx/layers/Layers.h
@@ -132,21 +132,16 @@ public:
  * rendered data between paints (i.e. uses cairo in just the way that
  * Gecko used it before layers were introduced). But we also don't want
  * to have bifurcated "layers"/"non-layers" rendering paths in Gecko.
  * Therefore the layers API is carefully designed to permit maximally
  * efficient implementation in an "immediate mode" style. See the
  * BasicLayerManager for such an implementation.
  */
 
-static void LayerManagerUserDataDestroy(void *data)
-{
-  delete static_cast<LayerUserData*>(data);
-}
-
 /**
  * A LayerManager controls a tree of layers. All layers in the tree
  * must use the same LayerManager.
  *
  * All modifications to a layer tree must happen inside a transaction.
  * Only the state of the layer tree at the end of a transaction is
  * rendered. Transactions cannot be nested
  *
@@ -504,17 +499,17 @@ public:
   virtual void GetBackendName(nsAString& aName) = 0;
 
   /**
    * This setter can be used anytime. The user data for all keys is
    * initially null. Ownership pases to the layer manager.
    */
   void SetUserData(void* aKey, LayerUserData* aData)
   {
-    mUserData.Add(static_cast<gfx::UserDataKey*>(aKey), aData, LayerManagerUserDataDestroy);
+    mUserData.Add(static_cast<gfx::UserDataKey*>(aKey), aData, LayerUserDataDestroy);
   }
   /**
    * This can be used anytime. Ownership passes to the caller!
    */
   nsAutoPtr<LayerUserData> RemoveUserData(void* aKey)
   {
     nsAutoPtr<LayerUserData> d(static_cast<LayerUserData*>(mUserData.Remove(static_cast<gfx::UserDataKey*>(aKey))));
     return d;
@@ -671,16 +666,18 @@ public:
   const TimeStamp& GetAnimationReadyTime() const {
     return mAnimationReadyTime;
   }
 
   virtual bool AsyncPanZoomEnabled() const {
     return false;
   }
 
+  static void LayerUserDataDestroy(void* data);
+
 protected:
   RefPtr<Layer> mRoot;
   gfx::UserData mUserData;
   bool mDestroyed;
   bool mSnapEffectiveTransforms;
 
   nsIntRegion mRegionToClear;
 
@@ -1384,17 +1381,17 @@ public:
   bool IsOpaqueForVisibility();
 
   /**
    * This setter can be used anytime. The user data for all keys is
    * initially null. Ownership pases to the layer manager.
    */
   void SetUserData(void* aKey, LayerUserData* aData)
   {
-    mUserData.Add(static_cast<gfx::UserDataKey*>(aKey), aData, LayerManagerUserDataDestroy);
+    mUserData.Add(static_cast<gfx::UserDataKey*>(aKey), aData, LayerManager::LayerUserDataDestroy);
   }
   /**
    * This can be used anytime. Ownership passes to the caller!
    */
   nsAutoPtr<LayerUserData> RemoveUserData(void* aKey)
   {
     nsAutoPtr<LayerUserData> d(static_cast<LayerUserData*>(mUserData.Remove(static_cast<gfx::UserDataKey*>(aKey))));
     return d;