Expanded distribution of instance counting

http://codereview.appspot.com/6300114/



git-svn-id: http://skia.googlecode.com/svn/trunk@4291 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/bench/RefCntBench.cpp b/bench/RefCntBench.cpp
index f21317a..965eb26 100644
--- a/bench/RefCntBench.cpp
+++ b/bench/RefCntBench.cpp
@@ -40,10 +40,17 @@
 
 class PlacedRefCnt : public SkRefCnt {
 public:
+    SK_DECLARE_INST_COUNT(PlacedRefCnt)
+
     PlacedRefCnt() : SkRefCnt() { }
     void operator delete(void *p) { }
+
+private:
+    typedef SkRefCnt INHERITED;
 };
 
+SK_DEFINE_INST_COUNT(PlacedRefCnt)
+
 class RefCntBench_Heap : public SkBenchmark {
 public:
     RefCntBench_Heap(void* param) : INHERITED(param) {
diff --git a/bench/SkBenchmark.cpp b/bench/SkBenchmark.cpp
index a69402b..19bbf59 100644
--- a/bench/SkBenchmark.cpp
+++ b/bench/SkBenchmark.cpp
@@ -9,6 +9,8 @@
 #include "SkPaint.h"
 #include "SkParse.h"
 
+SK_DEFINE_INST_COUNT(SkBenchmark)
+
 template BenchRegistry* BenchRegistry::gHead;
 
 SkBenchmark::SkBenchmark(void* defineDict) {
diff --git a/bench/SkBenchmark.h b/bench/SkBenchmark.h
index 5019b23..1d6fb41 100644
--- a/bench/SkBenchmark.h
+++ b/bench/SkBenchmark.h
@@ -33,6 +33,8 @@
 
 class SkBenchmark : public SkRefCnt {
 public:
+    SK_DECLARE_INST_COUNT(SkBenchmark)
+
     SkBenchmark(void* defineDict);
 
     const char* getName();
@@ -88,6 +90,8 @@
     SkTriState::State  fDither;
     bool    fHasStrokeWidth;
     SkScalar strokeWidth;
+
+    typedef SkRefCnt INHERITED;
 };
 
 typedef SkTRegistry<SkBenchmark*, void*> BenchRegistry;
diff --git a/include/core/SkAdvancedTypefaceMetrics.h b/include/core/SkAdvancedTypefaceMetrics.h
index 5ffdb45..d326379 100755
--- a/include/core/SkAdvancedTypefaceMetrics.h
+++ b/include/core/SkAdvancedTypefaceMetrics.h
@@ -26,6 +26,8 @@
 
 class SkAdvancedTypefaceMetrics : public SkRefCnt {
 public:
+    SK_DECLARE_INST_COUNT(SkAdvancedTypefaceMetrics)
+
     SkString fFontName;
 
     enum FontType {
@@ -112,6 +114,9 @@
     // The mapping from glyph to Unicode, only populated if
     // kToUnicode_PerGlyphInfo is passed to GetAdvancedTypefaceMetrics.
     SkTDArray<SkUnichar> fGlyphToUnicode;
+
+private:
+    typedef SkRefCnt INHERITED;
 };
 
 namespace skia_advanced_typeface_metrics_utils {
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h
index 514357f..8515b46 100644
--- a/include/core/SkBitmap.h
+++ b/include/core/SkBitmap.h
@@ -558,6 +558,8 @@
 
     class Allocator : public SkRefCnt {
     public:
+        SK_DECLARE_INST_COUNT(Allocator)
+
         /** Allocate the pixel memory for the bitmap, given its dimensions and
             config. Return true on success, where success means either setPixels
             or setPixelRef was called. The pixels need not be locked when this
@@ -566,6 +568,8 @@
             colortable should be left unchanged.
         */
         virtual bool allocPixelRef(SkBitmap*, SkColorTable*) = 0;
+    private:
+        typedef SkRefCnt INHERITED;
     };
 
     /** Subclass of Allocator that returns a pixelref that allocates its pixel
diff --git a/include/core/SkBounder.h b/include/core/SkBounder.h
index 5bac358..08cef2d 100644
--- a/include/core/SkBounder.h
+++ b/include/core/SkBounder.h
@@ -84,6 +84,8 @@
     friend class SkDrawIter;
     friend struct Draw1Glyph;
     friend class SkMaskFilter;
+
+    typedef SkRefCnt INHERITED;
 };
 
 #endif
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index d942783..fc95f9a 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -44,6 +44,8 @@
 */
 class SK_API SkCanvas : public SkRefCnt {
 public:
+    SK_DECLARE_INST_COUNT(SkCanvas)
+
     SkCanvas();
 
     /** Construct a canvas with the specified device to draw into.
@@ -1058,6 +1060,8 @@
 #else
     void validateClip() const {}
 #endif
+
+    typedef SkRefCnt INHERITED;
 };
 
 /** Stack helper class to automatically call restoreToCount() on the canvas
diff --git a/include/core/SkData.h b/include/core/SkData.h
index 76b4457..8bbe3c8 100644
--- a/include/core/SkData.h
+++ b/include/core/SkData.h
@@ -20,6 +20,8 @@
  */
 class SkData : public SkRefCnt {
 public:
+    SK_DECLARE_INST_COUNT(SkData)
+
     /**
      *  Returns the number of bytes stored.
      */
@@ -91,6 +93,8 @@
 
     SkData(const void* ptr, size_t size, ReleaseProc, void* context);
     ~SkData();
+
+    typedef SkRefCnt INHERITED;
 };
 
 /**
diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h
index b4d44bf..688ce8e 100644
--- a/include/core/SkDevice.h
+++ b/include/core/SkDevice.h
@@ -27,6 +27,8 @@
 
 class SK_API SkDevice : public SkRefCnt {
 public:
+    SK_DECLARE_INST_COUNT(SkDevice)
+
     /**
      *  Construct a new device with the specified bitmap as its backend. It is
      *  valid for the bitmap to have no pixels associated with it. In that case,
@@ -387,6 +389,8 @@
     SkBitmap    fBitmap;
     SkIPoint    fOrigin;
     SkMetaData* fMetaData;
+
+    typedef SkRefCnt INHERITED;
 };
 
 #endif
diff --git a/include/core/SkDeviceProfile.h b/include/core/SkDeviceProfile.h
index 46b9781..49214c5 100644
--- a/include/core/SkDeviceProfile.h
+++ b/include/core/SkDeviceProfile.h
@@ -12,6 +12,8 @@
 
 class SkDeviceProfile : public SkRefCnt {
 public:
+    SK_DECLARE_INST_COUNT(SkDeviceProfile)
+
     enum LCDConfig {
         kNone_LCDConfig,   // disables LCD text rendering, uses A8 instead
         kRGB_Horizontal_LCDConfig,
@@ -89,6 +91,8 @@
     float           fContrastScale;
     LCDConfig       fLCDConfig;
     FontHintLevel   fFontHintLevel;
+
+    typedef SkRefCnt INHERITED;
 };
 
 #endif
diff --git a/include/core/SkDrawFilter.h b/include/core/SkDrawFilter.h
index 303b80e..39b1717 100644
--- a/include/core/SkDrawFilter.h
+++ b/include/core/SkDrawFilter.h
@@ -38,6 +38,9 @@
      *  The implementation may modify the paint as they wish.
      */
     virtual void filter(SkPaint*, Type) = 0;
+
+private:
+    typedef SkRefCnt INHERITED;
 };
 
 #endif
diff --git a/include/core/SkFlattenable.h b/include/core/SkFlattenable.h
index 5701967..e6c56a3 100644
--- a/include/core/SkFlattenable.h
+++ b/include/core/SkFlattenable.h
@@ -68,6 +68,8 @@
  */
 class SK_API SkFlattenable : public SkRefCnt {
 public:
+    SK_DECLARE_INST_COUNT(SkFlattenable)
+
     typedef SkFlattenable* (*Factory)(SkFlattenableReadBuffer&);
     
     SkFlattenable() {}
@@ -104,6 +106,8 @@
 
     friend class SkGraphics;
     friend class SkFlattenableWriteBuffer;
+
+    typedef SkRefCnt INHERITED;
 };
 
 // helpers for matrix and region
diff --git a/include/core/SkInstCnt.h b/include/core/SkInstCnt.h
index e5c44db..087d5a7 100644
--- a/include/core/SkInstCnt.h
+++ b/include/core/SkInstCnt.h
@@ -31,7 +31,7 @@
 #define SK_DECLARE_INST_COUNT_INTERNAL(className, initStep)                 \
     class SkInstanceCountHelper {                                           \
     public:                                                                 \
-        typedef void (*PFCheckInstCnt)();                                   \
+        typedef void (*PFCheckInstCnt)(int level);                          \
         SkInstanceCountHelper() {                                           \
             if (!gInited) {                                                 \
                 initStep                                                    \
@@ -57,13 +57,14 @@
         return SkInstanceCountHelper::gInstanceCount;                       \
     }                                                                       \
                                                                             \
-    static void CheckInstanceCount() {                                      \
+    static void CheckInstanceCount(int level = 0) {                         \
         if (0 != SkInstanceCountHelper::gInstanceCount) {                   \
-            SkDebugf("Leaked %s objects: %d\n", #className,                 \
+            SkDebugf("%*c Leaked %s objects: %d\n",                         \
+                     4*level, ' ', #className,                              \
                      SkInstanceCountHelper::gInstanceCount);                \
         }                                                                   \
-        for (int i = 0; i < SkInstanceCountHelper::gChildren.count(); ++i) { \
-            (*SkInstanceCountHelper::gChildren[i])();                       \
+        for (int i = 0; i < SkInstanceCountHelper::gChildren.count(); ++i) {\
+            (*SkInstanceCountHelper::gChildren[i])(level+1);                \
         }                                                                   \
     }                                                                       \
                                                                             \
diff --git a/include/core/SkPicture.h b/include/core/SkPicture.h
index 21a4fcc..51ed0d7 100644
--- a/include/core/SkPicture.h
+++ b/include/core/SkPicture.h
@@ -26,6 +26,8 @@
 */
 class SK_API SkPicture : public SkRefCnt {
 public:
+    SK_DECLARE_INST_COUNT(SkPicture)
+
     /** The constructor prepares the picture to record.
         @param width the width of the virtual device the picture records.
         @param height the height of the virtual device the picture records.
@@ -130,6 +132,8 @@
 
     friend class SkFlatPicture;
     friend class SkPicturePlayback;
+
+    typedef SkRefCnt INHERITED;
 };
 
 class SkAutoPictureRecord : SkNoncopyable {
diff --git a/include/core/SkPtrRecorder.h b/include/core/SkPtrRecorder.h
index 2df84b2..360471f 100644
--- a/include/core/SkPtrRecorder.h
+++ b/include/core/SkPtrRecorder.h
@@ -21,6 +21,8 @@
  */
 class SkPtrSet : public SkRefCnt {
 public:
+    SK_DECLARE_INST_COUNT(SkPtrSet)
+
     /**
      *  Search for the specified ptr in the set. If it is found, return its
      *  32bit ID [1..N], or if not found, return 0. Always returns 0 for NULL.
diff --git a/include/core/SkStream.h b/include/core/SkStream.h
index 67512d7..58f5443 100644
--- a/include/core/SkStream.h
+++ b/include/core/SkStream.h
@@ -17,6 +17,8 @@
 
 class SK_API SkStream : public SkRefCnt {
 public:
+    SK_DECLARE_INST_COUNT(SkStream)
+
     virtual ~SkStream();
     /** Called to rewind to the beginning of the stream. If this cannot be
         done, return false.
@@ -63,6 +65,9 @@
     bool     readBool() { return this->readU8() != 0; }
     SkScalar readScalar();
     size_t   readPackedUInt();
+
+private:
+    typedef SkRefCnt INHERITED;
 };
 
 class SK_API SkWStream : SkNoncopyable {
diff --git a/include/core/SkWeakRefCnt.h b/include/core/SkWeakRefCnt.h
index 50760e2..a407623 100644
--- a/include/core/SkWeakRefCnt.h
+++ b/include/core/SkWeakRefCnt.h
@@ -150,6 +150,8 @@
 
     /* Invariant: fWeakCnt = #weak + (fRefCnt > 0 ? 1 : 0) */
     mutable int32_t fWeakCnt;
+
+    typedef SkRefCnt INHERITED;
 };
 
 #endif
diff --git a/include/gpu/GrCustomStage.h b/include/gpu/GrCustomStage.h
index 5eea9f4..1c2cc9f 100644
--- a/include/gpu/GrCustomStage.h
+++ b/include/gpu/GrCustomStage.h
@@ -22,6 +22,8 @@
 class GrCustomStage : public GrRefCnt {
 
 public:
+    SK_DECLARE_INST_COUNT(GrCustomStage)
+
     typedef GrProgramStageFactory::StageKey StageKey;
 
     GrCustomStage();
diff --git a/include/gpu/gl/GrGLInterface.h b/include/gpu/gl/GrGLInterface.h
index 1827dc2..c627b90 100644
--- a/include/gpu/gl/GrGLInterface.h
+++ b/include/gpu/gl/GrGLInterface.h
@@ -119,7 +119,11 @@
         FNPTR_TYPE fPtr;
     };
 
+    typedef GrRefCnt INHERITED;
+
 public:
+    SK_DECLARE_INST_COUNT(GrGLInterface)
+
     GrGLInterface();
 
     // Validates that the GrGLInterface supports a binding. This means that
diff --git a/include/gpu/gl/SkGLContext.h b/include/gpu/gl/SkGLContext.h
index e2ac7e0..b8b6b6e 100644
--- a/include/gpu/gl/SkGLContext.h
+++ b/include/gpu/gl/SkGLContext.h
@@ -18,6 +18,8 @@
 
 class SkGLContext : public SkRefCnt {
 public:
+    SK_DECLARE_INST_COUNT(SkGLContext)
+
     SkGLContext();
     virtual ~SkGLContext();
 
@@ -54,6 +56,8 @@
     GrGLuint fColorBufferID;
     GrGLuint fDepthStencilBufferID;
     const GrGLInterface* fGL;
+
+    typedef SkRefCnt INHERITED;
 };
 
 /**
diff --git a/include/images/SkImageDecoder.h b/include/images/SkImageDecoder.h
index d0c4d21..a8ec1c6 100644
--- a/include/images/SkImageDecoder.h
+++ b/include/images/SkImageDecoder.h
@@ -56,10 +56,14 @@
     */
     class Peeker : public SkRefCnt {
     public:
+        SK_DECLARE_INST_COUNT(Peeker)
+
         /** Return true to continue decoding, or false to indicate an error, which
             will cause the decoder to not return the image.
         */
         virtual bool peek(const char tag[], const void* data, size_t length) = 0;
+    private:
+        typedef SkRefCnt INHERITED;
     };
 
     Peeker* getPeeker() const { return fPeeker; }
@@ -72,11 +76,16 @@
     */
     class Chooser : public SkRefCnt {
     public:
+        SK_DECLARE_INST_COUNT(Chooser)
+
         virtual void begin(int count) {}
         virtual void inspect(int index, SkBitmap::Config config, int width, int height) {}
         /** Return the index of the subimage you want, or -1 to choose none of them.
         */
         virtual int choose() = 0;
+
+    private:
+        typedef SkRefCnt INHERITED;
     };
 
     Chooser* getChooser() const { return fChooser; }
@@ -321,7 +330,12 @@
  */
 class SkImageDecoderFactory : public SkRefCnt {
 public:
+    SK_DECLARE_INST_COUNT(SkImageDecoderFactory)
+
     virtual SkImageDecoder* newDecoder(SkStream*) = 0;
+
+private:
+    typedef SkRefCnt INHERITED;
 };
 
 class SkDefaultImageDecoderFactory : SkImageDecoderFactory {
diff --git a/include/images/SkMovie.h b/include/images/SkMovie.h
index f52a786..cecad29 100644
--- a/include/images/SkMovie.h
+++ b/include/images/SkMovie.h
@@ -17,6 +17,8 @@
 
 class SkMovie : public SkRefCnt {
 public:
+    SK_DECLARE_INST_COUNT(SkMovie)
+
     /** Try to create a movie from the stream. If the stream format is not
         supported, return NULL.
     */
@@ -71,6 +73,8 @@
     bool        fNeedBitmap;
     
     void ensureInfo();
+
+    typedef SkRefCnt INHERITED;
 };
 
 #endif
diff --git a/include/text/SkTextLayout.h b/include/text/SkTextLayout.h
index e1e3e56..3b12334 100644
--- a/include/text/SkTextLayout.h
+++ b/include/text/SkTextLayout.h
@@ -13,6 +13,8 @@
 
 class SkTextStyle : public SkRefCnt {
 public:
+    SK_DECLARE_INST_COUNT(SkTextStyle)
+
     SkTextStyle();
     SkTextStyle(const SkTextStyle&);
     explicit SkTextStyle(const SkPaint&);
@@ -25,6 +27,8 @@
 
 private:
     SkPaint fPaint;
+
+    typedef SkRefCnt INHERITED;
 };
 
 class SkTextLayout {
diff --git a/src/core/SkAdvancedTypefaceMetrics.cpp b/src/core/SkAdvancedTypefaceMetrics.cpp
index 8af70fb..6cf80a1 100644
--- a/src/core/SkAdvancedTypefaceMetrics.cpp
+++ b/src/core/SkAdvancedTypefaceMetrics.cpp
@@ -10,6 +10,8 @@
 #include "SkAdvancedTypefaceMetrics.h"
 #include "SkTypes.h"
 
+SK_DEFINE_INST_COUNT(SkAdvancedTypefaceMetrics)
+
 #if defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID)
 #include <ft2build.h>
 #include FT_FREETYPE_H
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index a723113..9b616c6 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -20,6 +20,8 @@
 #include "SkPackBits.h"
 #include <new>
 
+SK_DEFINE_INST_COUNT(SkBitmap::Allocator)
+
 extern int32_t SkNextPixelRefGenerationID();
 
 static bool isPos32Bits(const Sk64& value) {
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index af2e066..fa9519e 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -21,6 +21,8 @@
 #include "SkTLazy.h"
 #include "SkUtils.h"
 
+SK_DEFINE_INST_COUNT(SkCanvas)
+
 //#define SK_TRACE_SAVERESTORE
 
 #ifdef SK_TRACE_SAVERESTORE
diff --git a/src/core/SkData.cpp b/src/core/SkData.cpp
index f9f4043..495da88 100644
--- a/src/core/SkData.cpp
+++ b/src/core/SkData.cpp
@@ -10,6 +10,8 @@
 
 #include "SkData.h"
 
+SK_DEFINE_INST_COUNT(SkData)
+
 SkData::SkData(const void* ptr, size_t size, ReleaseProc proc, void* context) {
     fPtr = ptr;
     fSize = size;
diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp
index b92f4e1..c5dfc66 100644
--- a/src/core/SkDevice.cpp
+++ b/src/core/SkDevice.cpp
@@ -11,6 +11,8 @@
 #include "SkMetaData.h"
 #include "SkRect.h"
 
+SK_DEFINE_INST_COUNT(SkDevice)
+
 ///////////////////////////////////////////////////////////////////////////////
 
 SkDevice::SkDevice(const SkBitmap& bitmap) : fBitmap(bitmap) {
diff --git a/src/core/SkDeviceProfile.cpp b/src/core/SkDeviceProfile.cpp
index c5abc8e..f4f242a 100644
--- a/src/core/SkDeviceProfile.cpp
+++ b/src/core/SkDeviceProfile.cpp
@@ -1,7 +1,15 @@
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
 
 
 #include "SkDeviceProfile.h"
 
+SK_DEFINE_INST_COUNT(SkDeviceProfile)
+
 #define DEFAULT_GAMMAEXP        2.2f
 #define DEFAULT_CONTRASTSCALE   0.5f
 #define DEFAULT_LCDCONFIG       SkDeviceProfile::kNone_LCDConfig
diff --git a/src/core/SkFlattenable.cpp b/src/core/SkFlattenable.cpp
index b8001f0..0232f75 100644
--- a/src/core/SkFlattenable.cpp
+++ b/src/core/SkFlattenable.cpp
@@ -8,6 +8,8 @@
 #include "SkFlattenable.h"
 #include "SkTypeface.h"
 
+SK_DEFINE_INST_COUNT(SkFlattenable)
+
 ///////////////////////////////////////////////////////////////////////////////
 
 void SkFlattenable::flatten(SkFlattenableWriteBuffer&) const
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp
index 44307e0..10790d2 100644
--- a/src/core/SkPicture.cpp
+++ b/src/core/SkPicture.cpp
@@ -23,6 +23,8 @@
 #include "SkReader32.h"
 #include "SkWriter32.h"
 
+SK_DEFINE_INST_COUNT(SkPicture)
+
 #define DUMP_BUFFER_SIZE 65536
 
 //#define ENABLE_TIME_DRAW    // dumps milliseconds for each draw
diff --git a/src/core/SkPtrRecorder.cpp b/src/core/SkPtrRecorder.cpp
index e509464..4d1165b 100644
--- a/src/core/SkPtrRecorder.cpp
+++ b/src/core/SkPtrRecorder.cpp
@@ -8,6 +8,8 @@
 #include "SkPtrRecorder.h"
 #include "SkTSearch.h"
 
+SK_DEFINE_INST_COUNT(SkPtrSet)
+
 void SkPtrSet::reset() {
     Pair* p = fList.begin();
     Pair* stop = fList.end();
diff --git a/src/core/SkStream.cpp b/src/core/SkStream.cpp
index 8b71244..45eb183 100644
--- a/src/core/SkStream.cpp
+++ b/src/core/SkStream.cpp
@@ -13,6 +13,8 @@
 #include "SkString.h"
 #include "SkOSFile.h"
 
+SK_DEFINE_INST_COUNT(SkStream)
+
 SkStream::~SkStream() {}
 
 const char* SkStream::getFileName()
diff --git a/src/gpu/GrCustomStage.cpp b/src/gpu/GrCustomStage.cpp
index c7d0844..c0ec330 100644
--- a/src/gpu/GrCustomStage.cpp
+++ b/src/gpu/GrCustomStage.cpp
@@ -8,6 +8,8 @@
 #include "GrContext.h"
 #include "GrCustomStage.h"
 
+SK_DEFINE_INST_COUNT(GrCustomStage)
+
 int32_t GrProgramStageFactory::fCurrStageClassID =
                                     GrProgramStageFactory::kIllegalStageClassID;
 
diff --git a/src/gpu/gl/GrGLInterface.cpp b/src/gpu/gl/GrGLInterface.cpp
index abd4366..02e9337 100644
--- a/src/gpu/gl/GrGLInterface.cpp
+++ b/src/gpu/gl/GrGLInterface.cpp
@@ -11,6 +11,8 @@
 
 #include <stdio.h>
 
+SK_DEFINE_INST_COUNT(GrGLInterface)
+
 #if GR_GL_PER_GL_FUNC_CALLBACK
 namespace {
 void GrGLDefaultInterfaceCallback(const GrGLInterface*) {}
diff --git a/src/gpu/gl/SkGLContext.cpp b/src/gpu/gl/SkGLContext.cpp
index 3252b56..f67e68c 100644
--- a/src/gpu/gl/SkGLContext.cpp
+++ b/src/gpu/gl/SkGLContext.cpp
@@ -8,6 +8,8 @@
 #include "gl/SkGLContext.h"
 #include "gl/GrGLUtil.h"
 
+SK_DEFINE_INST_COUNT(SkGLContext)
+
 SkGLContext::SkGLContext()
     : fFBO(0)
     , fColorBufferID(0)
diff --git a/src/images/SkImageDecoder.cpp b/src/images/SkImageDecoder.cpp
index c076f84..2980896 100644
--- a/src/images/SkImageDecoder.cpp
+++ b/src/images/SkImageDecoder.cpp
@@ -13,6 +13,10 @@
 #include "SkStream.h"
 #include "SkTemplates.h"
 
+SK_DEFINE_INST_COUNT(SkImageDecoder::Peeker)
+SK_DEFINE_INST_COUNT(SkImageDecoder::Chooser)
+SK_DEFINE_INST_COUNT(SkImageDecoderFactory)
+
 static SkBitmap::Config gDeviceConfig = SkBitmap::kNo_Config;
 
 SkBitmap::Config SkImageDecoder::GetDeviceConfig()
diff --git a/src/images/SkMovie.cpp b/src/images/SkMovie.cpp
index 81820a5..978cd16 100644
--- a/src/images/SkMovie.cpp
+++ b/src/images/SkMovie.cpp
@@ -9,6 +9,8 @@
 #include "SkCanvas.h"
 #include "SkPaint.h"
 
+SK_DEFINE_INST_COUNT(SkMovie)
+
 // We should never see this in normal operation since our time values are
 // 0-based. So we use it as a sentinal.
 #define UNINITIALIZED_MSEC ((SkMSec)-1)
diff --git a/src/text/SkTextLayout.cpp b/src/text/SkTextLayout.cpp
index fda4b2f..4d87ffe 100644
--- a/src/text/SkTextLayout.cpp
+++ b/src/text/SkTextLayout.cpp
@@ -7,6 +7,8 @@
  */
 #include "SkTextLayout.h"
 
+SK_DEFINE_INST_COUNT(SkTextStyle)
+
 SkTextStyle::SkTextStyle() {
     fPaint.setAntiAlias(true);
 }