Bug 935778 - Part 0.7: Emit the correct type name from FilterNodeLightingSoftware; r=jrmuizel, parts r=dbaron
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 26 Feb 2014 10:13:48 -0500
changeset 171037 9dd9e9cf9646b62b33b241257fd699527e4dd11c
parent 171036 c3fc351a1c5512a93560f321572aaf66936a4a18
child 171038 52c0111e9852c6c89e48d1f925d6b5a4cf74e34a
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersjrmuizel, parts, dbaron
bugs935778
milestone30.0a1
Bug 935778 - Part 0.7: Emit the correct type name from FilterNodeLightingSoftware; r=jrmuizel, parts r=dbaron
gfx/2d/FilterNodeSoftware.cpp
gfx/2d/FilterNodeSoftware.h
mfbt/RefPtr.h
--- a/gfx/2d/FilterNodeSoftware.cpp
+++ b/gfx/2d/FilterNodeSoftware.cpp
@@ -529,32 +529,32 @@ FilterNodeSoftware::Create(FilterType aT
       break;
     case FilterType::PREMULTIPLY:
       filter = new FilterNodePremultiplySoftware();
       break;
     case FilterType::UNPREMULTIPLY:
       filter = new FilterNodeUnpremultiplySoftware();
       break;
     case FilterType::POINT_DIFFUSE:
-      filter = new FilterNodeLightingSoftware<PointLightSoftware, DiffuseLightingSoftware>();
+      filter = new FilterNodeLightingSoftware<PointLightSoftware, DiffuseLightingSoftware>("FilterNodeLightingSoftware<PointLight, DiffuseLighting>");
       break;
     case FilterType::POINT_SPECULAR:
-      filter = new FilterNodeLightingSoftware<PointLightSoftware, SpecularLightingSoftware>();
+      filter = new FilterNodeLightingSoftware<PointLightSoftware, SpecularLightingSoftware>("FilterNodeLightingSoftware<PointLight, SpecularLighting>");
       break;
     case FilterType::SPOT_DIFFUSE:
-      filter = new FilterNodeLightingSoftware<SpotLightSoftware, DiffuseLightingSoftware>();
+      filter = new FilterNodeLightingSoftware<SpotLightSoftware, DiffuseLightingSoftware>("FilterNodeLightingSoftware<SpotLight, DiffuseLighting>");
       break;
     case FilterType::SPOT_SPECULAR:
-      filter = new FilterNodeLightingSoftware<SpotLightSoftware, SpecularLightingSoftware>();
+      filter = new FilterNodeLightingSoftware<SpotLightSoftware, SpecularLightingSoftware>("FilterNodeLightingSoftware<SpotLight, SpecularLighting>");
       break;
     case FilterType::DISTANT_DIFFUSE:
-      filter = new FilterNodeLightingSoftware<DistantLightSoftware, DiffuseLightingSoftware>();
+      filter = new FilterNodeLightingSoftware<DistantLightSoftware, DiffuseLightingSoftware>("FilterNodeLightingSoftware<DistantLight, DiffuseLighting>");
       break;
     case FilterType::DISTANT_SPECULAR:
-      filter = new FilterNodeLightingSoftware<DistantLightSoftware, SpecularLightingSoftware>();
+      filter = new FilterNodeLightingSoftware<DistantLightSoftware, SpecularLightingSoftware>("FilterNodeLightingSoftware<DistantLight, SpecularLighting>");
       break;
   }
   return filter;
 }
 
 void
 FilterNodeSoftware::Draw(DrawTarget* aDrawTarget,
                          const Rect &aSourceRect,
@@ -3054,18 +3054,21 @@ DistantLightSoftware::SetAttribute(uint3
 
 static inline Point3D Normalized(const Point3D &vec) {
   Point3D copy(vec);
   copy.Normalize();
   return copy;
 }
 
 template<typename LightType, typename LightingType>
-FilterNodeLightingSoftware<LightType, LightingType>::FilterNodeLightingSoftware()
+FilterNodeLightingSoftware<LightType, LightingType>::FilterNodeLightingSoftware(const char* aTypeName)
  : mSurfaceScale(0)
+#if defined(MOZILLA_INTERNAL_API) && (defined(DEBUG) || defined(FORCE_BUILD_REFCNT_LOGGING))
+ , mTypeName(aTypeName)
+#endif
 {}
 
 template<typename LightType, typename LightingType>
 int32_t
 FilterNodeLightingSoftware<LightType, LightingType>::InputIndex(uint32_t aInputEnumIndex)
 {
   switch (aInputEnumIndex) {
     case IN_LIGHTING_IN: return 0;
--- a/gfx/2d/FilterNodeSoftware.h
+++ b/gfx/2d/FilterNodeSoftware.h
@@ -678,18 +678,22 @@ protected:
   virtual int32_t InputIndex(uint32_t aInputEnumIndex) MOZ_OVERRIDE;
   virtual void RequestFromInputsForRect(const IntRect &aRect) MOZ_OVERRIDE;
 };
 
 template<typename LightType, typename LightingType>
 class FilterNodeLightingSoftware : public FilterNodeSoftware
 {
 public:
-  MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeLightingSoftware)
-  FilterNodeLightingSoftware();
+#if defined(MOZILLA_INTERNAL_API) && (defined(DEBUG) || defined(FORCE_BUILD_REFCNT_LOGGING))
+  // Helpers for refcounted
+  virtual const char* typeName() const MOZ_OVERRIDE { return mTypeName; }
+  virtual size_t typeSize() const MOZ_OVERRIDE { return sizeof(*this); }
+#endif
+  explicit FilterNodeLightingSoftware(const char* aTypeName);
   virtual const char* GetName() MOZ_OVERRIDE { return "Lighting"; }
   using FilterNodeSoftware::SetAttribute;
   virtual void SetAttribute(uint32_t aIndex, Float) MOZ_OVERRIDE;
   virtual void SetAttribute(uint32_t aIndex, const Size &) MOZ_OVERRIDE;
   virtual void SetAttribute(uint32_t aIndex, const Point3D &) MOZ_OVERRIDE;
   virtual void SetAttribute(uint32_t aIndex, const Color &) MOZ_OVERRIDE;
 
 protected:
@@ -704,14 +708,17 @@ private:
                                            CoordType aKernelUnitLengthX,
                                            CoordType aKernelUnitLengthY);
 
   LightType mLight;
   LightingType mLighting;
   Float mSurfaceScale;
   Size mKernelUnitLength;
   Color mColor;
+#if defined(MOZILLA_INTERNAL_API) && (defined(DEBUG) || defined(FORCE_BUILD_REFCNT_LOGGING))
+  const char* mTypeName;
+#endif
 };
 
 }
 }
 
 #endif // _MOZILLA_GFX_FILTERNODESOFTWARE_H_
--- a/mfbt/RefPtr.h
+++ b/mfbt/RefPtr.h
@@ -96,21 +96,28 @@ class RefCounted
       MOZ_ASSERT(refCnt > 0);
       return refCnt == 1;
     }
 
   private:
     mutable typename Conditional<Atomicity == AtomicRefCount, Atomic<MozRefCountType>, MozRefCountType>::Type refCnt;
 };
 
+#if defined(MOZILLA_INTERNAL_API) && (defined(DEBUG) || defined(FORCE_BUILD_REFCNT_LOGGING))
 #define MOZ_DECLARE_REFCOUNTED_TYPENAME(T) \
-  const char* typeName() const { return #T; }
+  const char* typeName() const { return #T; } \
+  size_t typeSize() const { return sizeof(*this); }
 
 #define MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(T) \
-  virtual const char* typeName() const { return #T; }
+  virtual const char* typeName() const { return #T; } \
+  virtual size_t typeSize() const { return sizeof(*this); }
+#else
+#define MOZ_DECLARE_REFCOUNTED_TYPENAME(T)
+#define MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(T)
+#endif
 
 }
 
 template<typename T>
 class RefCounted : public detail::RefCounted<T, detail::NonAtomicRefCount>
 {
   public:
     ~RefCounted() {