From 0456e0b7b85060e9b9597ce414c4c2b19aff4f58 Mon Sep 17 00:00:00 2001 From: "robertphillips@google.com" Date: Wed, 27 Jun 2012 14:03:26 +0000 Subject: [PATCH] Added Inst counting to SkFlattenable-derived classes http://codereview.appspot.com/6355043/ git-svn-id: http://skia.googlecode.com/svn/trunk@4359 2bbb7eff-a529-9590-31e7-b0007b416f81 --- include/core/SkColorFilter.h | 2 ++ include/core/SkColorTable.h | 2 ++ include/core/SkDrawLooper.h | 2 ++ include/core/SkImageFilter.h | 2 ++ include/core/SkMaskFilter.h | 2 ++ include/core/SkPathEffect.h | 2 ++ include/core/SkPixelRef.h | 2 ++ include/core/SkRasterizer.h | 2 ++ include/core/SkShader.h | 4 +++- include/core/SkShape.h | 2 ++ include/core/SkUnitMapper.h | 5 +++++ include/core/SkXfermode.h | 2 ++ include/effects/SkLayerDrawLooper.h | 2 ++ src/core/SkColorFilter.cpp | 2 ++ src/core/SkColorTable.cpp | 2 ++ src/core/SkMaskFilter.cpp | 2 ++ src/core/SkPaint.cpp | 4 ++++ src/core/SkPathEffect.cpp | 2 ++ src/core/SkPixelRef.cpp | 2 ++ src/core/SkRasterizer.cpp | 2 ++ src/core/SkShader.cpp | 2 ++ src/core/SkShape.cpp | 2 ++ src/core/SkXfermode.cpp | 2 ++ src/effects/SkLayerDrawLooper.cpp | 2 ++ src/effects/SkLightingImageFilter.cpp | 4 ++++ src/utils/SkUnitMappers.cpp | 2 ++ 26 files changed, 60 insertions(+), 1 deletion(-) diff --git a/include/core/SkColorFilter.h b/include/core/SkColorFilter.h index 8c67054..2fc9d6e 100644 --- a/include/core/SkColorFilter.h +++ b/include/core/SkColorFilter.h @@ -16,6 +16,8 @@ class SK_API SkColorFilter : public SkFlattenable { public: + SK_DECLARE_INST_COUNT(SkColorFilter) + /** * If the filter can be represented by a source color plus Mode, this * returns true, and sets (if not NULL) the color and mode appropriately. diff --git a/include/core/SkColorTable.h b/include/core/SkColorTable.h index de6cb83..01d6ac1 100644 --- a/include/core/SkColorTable.h +++ b/include/core/SkColorTable.h @@ -20,6 +20,8 @@ */ class SkColorTable : public SkFlattenable { public: + SK_DECLARE_INST_COUNT(SkColorTable) + /** Makes a deep copy of colors. */ SkColorTable(const SkColorTable& src); diff --git a/include/core/SkDrawLooper.h b/include/core/SkDrawLooper.h index e8265db..0e99651 100644 --- a/include/core/SkDrawLooper.h +++ b/include/core/SkDrawLooper.h @@ -25,6 +25,8 @@ class SkPaint; */ class SK_API SkDrawLooper : public SkFlattenable { public: + SK_DECLARE_INST_COUNT(SkDrawLooper) + /** * Called right before something is being drawn. This will be followed by * calls to next() until next() returns false. diff --git a/include/core/SkImageFilter.h b/include/core/SkImageFilter.h index 1b282d2..c27f698 100644 --- a/include/core/SkImageFilter.h +++ b/include/core/SkImageFilter.h @@ -38,6 +38,8 @@ struct SkPoint; */ class SK_API SkImageFilter : public SkFlattenable { public: + SK_DECLARE_INST_COUNT(SkImageFilter) + class Proxy { public: virtual ~Proxy() {}; diff --git a/include/core/SkMaskFilter.h b/include/core/SkMaskFilter.h index 3422e27..6652f40 100644 --- a/include/core/SkMaskFilter.h +++ b/include/core/SkMaskFilter.h @@ -33,6 +33,8 @@ class SkRasterClip; */ class SkMaskFilter : public SkFlattenable { public: + SK_DECLARE_INST_COUNT(SkMaskFilter) + SkMaskFilter() {} /** Returns the format of the resulting mask that this subclass will return diff --git a/include/core/SkPathEffect.h b/include/core/SkPathEffect.h index 8a129fe..accdc39 100644 --- a/include/core/SkPathEffect.h +++ b/include/core/SkPathEffect.h @@ -102,6 +102,8 @@ private: */ class SK_API SkPathEffect : public SkFlattenable { public: + SK_DECLARE_INST_COUNT(SkPathEffect) + SkPathEffect() {} /** diff --git a/include/core/SkPixelRef.h b/include/core/SkPixelRef.h index 5c24d67..c8e1b2c 100644 --- a/include/core/SkPixelRef.h +++ b/include/core/SkPixelRef.h @@ -32,6 +32,8 @@ class SkGpuTexture; */ class SK_API SkPixelRef : public SkFlattenable { public: + SK_DECLARE_INST_COUNT(SkPixelRef) + explicit SkPixelRef(SkBaseMutex* mutex = NULL); /** Return the pixel memory returned from lockPixels, or null if the diff --git a/include/core/SkRasterizer.h b/include/core/SkRasterizer.h index 923028f..0791713 100644 --- a/include/core/SkRasterizer.h +++ b/include/core/SkRasterizer.h @@ -20,6 +20,8 @@ struct SkIRect; class SkRasterizer : public SkFlattenable { public: + SK_DECLARE_INST_COUNT(SkRasterizer) + SkRasterizer() {} /** Turn the path into a mask, respecting the specified local->device matrix. diff --git a/include/core/SkShader.h b/include/core/SkShader.h index 8a4e252..e842062 100644 --- a/include/core/SkShader.h +++ b/include/core/SkShader.h @@ -30,7 +30,9 @@ class SkPath; */ class SK_API SkShader : public SkFlattenable { public: - SkShader(); + SK_DECLARE_INST_COUNT(SkShader) + + SkShader(); virtual ~SkShader(); /** diff --git a/include/core/SkShape.h b/include/core/SkShape.h index 0196156..4f2bd98 100644 --- a/include/core/SkShape.h +++ b/include/core/SkShape.h @@ -16,6 +16,8 @@ class SkWStream; class SkShape : public SkFlattenable { public: + SK_DECLARE_INST_COUNT(SkShape) + SkShape(); virtual ~SkShape(); diff --git a/include/core/SkUnitMapper.h b/include/core/SkUnitMapper.h index 2bd482b..47a4dad 100644 --- a/include/core/SkUnitMapper.h +++ b/include/core/SkUnitMapper.h @@ -17,6 +17,8 @@ class SkUnitMapper : public SkFlattenable { public: + SK_DECLARE_INST_COUNT(SkUnitMapper) + SkUnitMapper() {} /** Given a value in [0..0xFFFF], return a value in the same range. @@ -25,6 +27,9 @@ public: protected: SkUnitMapper(SkFlattenableReadBuffer& rb) : SkFlattenable(rb) {} + +private: + typedef SkFlattenable INHERITED; }; #endif diff --git a/include/core/SkXfermode.h b/include/core/SkXfermode.h index 86bafea..2b7c11e 100644 --- a/include/core/SkXfermode.h +++ b/include/core/SkXfermode.h @@ -23,6 +23,8 @@ */ class SK_API SkXfermode : public SkFlattenable { public: + SK_DECLARE_INST_COUNT(SkXfermode) + SkXfermode() {} virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count, diff --git a/include/effects/SkLayerDrawLooper.h b/include/effects/SkLayerDrawLooper.h index 6cb8ef6..d00c1e5 100644 --- a/include/effects/SkLayerDrawLooper.h +++ b/include/effects/SkLayerDrawLooper.h @@ -15,6 +15,8 @@ struct SkPoint; class SK_API SkLayerDrawLooper : public SkDrawLooper { public: + SK_DECLARE_INST_COUNT(SkLayerDrawLooper) + SkLayerDrawLooper(); virtual ~SkLayerDrawLooper(); diff --git a/src/core/SkColorFilter.cpp b/src/core/SkColorFilter.cpp index b96b77e..74e1db1 100644 --- a/src/core/SkColorFilter.cpp +++ b/src/core/SkColorFilter.cpp @@ -11,6 +11,8 @@ #include "SkShader.h" #include "SkUnPreMultiply.h" +SK_DEFINE_INST_COUNT(SkColorFilter) + bool SkColorFilter::asColorMode(SkColor* color, SkXfermode::Mode* mode) { return false; } diff --git a/src/core/SkColorTable.cpp b/src/core/SkColorTable.cpp index 3797fbd..3711de5 100644 --- a/src/core/SkColorTable.cpp +++ b/src/core/SkColorTable.cpp @@ -11,6 +11,8 @@ #include "SkStream.h" #include "SkTemplates.h" +SK_DEFINE_INST_COUNT(SkColorTable) + SkColorTable::SkColorTable(int count) : f16BitCache(NULL), fFlags(0) { diff --git a/src/core/SkMaskFilter.cpp b/src/core/SkMaskFilter.cpp index 75e38ce..96e14a1 100644 --- a/src/core/SkMaskFilter.cpp +++ b/src/core/SkMaskFilter.cpp @@ -14,6 +14,8 @@ #include "SkDraw.h" #include "SkRasterClip.h" +SK_DEFINE_INST_COUNT(SkMaskFilter) + bool SkMaskFilter::filterMask(SkMask*, const SkMask&, const SkMatrix&, SkIPoint*) { return false; diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp index 8ed1ce6..cba7930 100644 --- a/src/core/SkPaint.cpp +++ b/src/core/SkPaint.cpp @@ -2159,6 +2159,8 @@ bool SkPaint::nothingToDraw() const { //////////// Move these to their own file soon. +SK_DEFINE_INST_COUNT(SkImageFilter) + bool SkImageFilter::filterImage(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm, SkBitmap* result, SkIPoint* loc) { @@ -2205,6 +2207,8 @@ bool SkImageFilter::asADilate(SkISize* radius) const { ////// +SK_DEFINE_INST_COUNT(SkDrawLooper) + bool SkDrawLooper::canComputeFastBounds(const SkPaint& paint) { SkCanvas canvas; diff --git a/src/core/SkPathEffect.cpp b/src/core/SkPathEffect.cpp index 6b95d9b..8708e7e 100644 --- a/src/core/SkPathEffect.cpp +++ b/src/core/SkPathEffect.cpp @@ -110,6 +110,8 @@ bool SkStrokeRec::applyToPath(SkPath* dst, const SkPath& src) const { /////////////////////////////////////////////////////////////////////////////// +SK_DEFINE_INST_COUNT(SkPathEffect) + void SkPathEffect::computeFastBounds(SkRect* dst, const SkRect& src) { *dst = src; } diff --git a/src/core/SkPixelRef.cpp b/src/core/SkPixelRef.cpp index 1317829..96c991c 100644 --- a/src/core/SkPixelRef.cpp +++ b/src/core/SkPixelRef.cpp @@ -9,6 +9,8 @@ #include "SkFlattenable.h" #include "SkThread.h" +SK_DEFINE_INST_COUNT(SkPixelRef) + // must be a power-of-2. undef to just use 1 mutex #define PIXELREF_MUTEX_RING_COUNT 32 diff --git a/src/core/SkRasterizer.cpp b/src/core/SkRasterizer.cpp index 0a0a959..e5625bf 100644 --- a/src/core/SkRasterizer.cpp +++ b/src/core/SkRasterizer.cpp @@ -12,6 +12,8 @@ #include "SkMaskFilter.h" #include "SkPath.h" +SK_DEFINE_INST_COUNT(SkRasterizer) + bool SkRasterizer::rasterize(const SkPath& fillPath, const SkMatrix& matrix, const SkIRect* clipBounds, SkMaskFilter* filter, SkMask* mask, SkMask::CreateMode mode) { diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp index 6953612..cd40b7f 100644 --- a/src/core/SkShader.cpp +++ b/src/core/SkShader.cpp @@ -12,6 +12,8 @@ #include "SkPaint.h" #include "SkMallocPixelRef.h" +SK_DEFINE_INST_COUNT(SkShader) + SkShader::SkShader() : fLocalMatrix(NULL) { SkDEBUGCODE(fInSession = false;) } diff --git a/src/core/SkShape.cpp b/src/core/SkShape.cpp index c386af8..146e74c 100644 --- a/src/core/SkShape.cpp +++ b/src/core/SkShape.cpp @@ -9,6 +9,8 @@ #include "SkShape.h" #include "SkMatrix.h" +SK_DEFINE_INST_COUNT(SkShape) + #if 0 static int gShapeCounter; static void inc_shape(const SkShape* s) { diff --git a/src/core/SkXfermode.cpp b/src/core/SkXfermode.cpp index bb9dc79..03f996a 100644 --- a/src/core/SkXfermode.cpp +++ b/src/core/SkXfermode.cpp @@ -10,6 +10,8 @@ #include "SkXfermode.h" #include "SkColorPriv.h" +SK_DEFINE_INST_COUNT(SkXfermode) + #define SkAlphaMulAlpha(a, b) SkMulDiv255Round(a, b) #if 0 diff --git a/src/effects/SkLayerDrawLooper.cpp b/src/effects/SkLayerDrawLooper.cpp index 250306c..3a2685c 100644 --- a/src/effects/SkLayerDrawLooper.cpp +++ b/src/effects/SkLayerDrawLooper.cpp @@ -11,6 +11,8 @@ #include "SkPaint.h" #include "SkUnPreMultiply.h" +SK_DEFINE_INST_COUNT(SkLayerDrawLooper) + SkLayerDrawLooper::LayerInfo::LayerInfo() { fFlagsMask = 0; // ignore our paint flags fPaintBits = 0; // ignore our paint fields diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp index 84cb291..25c92b7 100644 --- a/src/effects/SkLightingImageFilter.cpp +++ b/src/effects/SkLightingImageFilter.cpp @@ -271,6 +271,8 @@ private: class SkLight : public SkFlattenable { public: + SK_DECLARE_INST_COUNT(SkLight) + enum LightType { kDistant_LightType, kPoint_LightType, @@ -289,6 +291,8 @@ private: typedef SkFlattenable INHERITED; }; +SK_DEFINE_INST_COUNT(SkLight) + class SkDistantLight : public SkLight { public: SkDistantLight(const SkPoint3& direction) : fDirection(direction) { diff --git a/src/utils/SkUnitMappers.cpp b/src/utils/SkUnitMappers.cpp index 929447e..b2ab02b 100644 --- a/src/utils/SkUnitMappers.cpp +++ b/src/utils/SkUnitMappers.cpp @@ -7,6 +7,8 @@ */ #include "SkUnitMappers.h" +SK_DEFINE_INST_COUNT(SkUnitMapper) + SkDiscreteMapper::SkDiscreteMapper(int segments) { if (segments < 2) { fSegments = 0; -- 2.7.4