more SkInstCnt plumbing
authorreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 26 Jun 2012 19:24:50 +0000 (19:24 +0000)
committerreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 26 Jun 2012 19:24:50 +0000 (19:24 +0000)
fix some typeface leaks

git-svn-id: http://skia.googlecode.com/svn/trunk@4348 2bbb7eff-a529-9590-31e7-b0007b416f81

gm/verttext2.cpp
include/utils/SkDeferredCanvas.h
include/utils/SkDumpCanvas.h
src/utils/SkDeferredCanvas.cpp
src/utils/SkDumpCanvas.cpp
src/views/SkView.cpp

index 9ffefec247f5a28ea207375ce5a60290137994bf..8491dc342b3c335af711838a134df325c9105b60 100644 (file)
@@ -21,8 +21,13 @@ public:
     VertText2GM() {
         const int pointSize = 24;
         textHeight = SkIntToScalar(pointSize);
-        prop = SkTypeface::CreateFromName("Helvetica", SkTypeface::kNormal);
-        mono = SkTypeface::CreateFromName("Courier New", SkTypeface::kNormal);
+        fProp = SkTypeface::CreateFromName("Helvetica", SkTypeface::kNormal);
+        fMono = SkTypeface::CreateFromName("Courier New", SkTypeface::kNormal);
+    }
+
+    virtual ~VertText2GM() {
+        SkSafeUnref(fProp);
+        SkSafeUnref(fMono);
     }
 
 protected:
@@ -47,13 +52,13 @@ protected:
             canvas->drawLine(0, SkIntToScalar(470),
                     SkIntToScalar(110), SkIntToScalar(470), paint);
             drawText(canvas, SkString("Proportional / Top Aligned"),
-                     prop,  SkPaint::kLeft_Align);
+                     fProp,  SkPaint::kLeft_Align);
             drawText(canvas, SkString("<   Proportional / Centered   >"),
-                     prop,  SkPaint::kCenter_Align);
+                     fProp,  SkPaint::kCenter_Align);
             drawText(canvas, SkString("Monospaced / Top Aligned"),
-                     mono, SkPaint::kLeft_Align);
+                     fMono, SkPaint::kLeft_Align);
             drawText(canvas, SkString("<    Monospaced / Centered    >"),
-                     mono, SkPaint::kCenter_Align);
+                     fMono, SkPaint::kCenter_Align);
             canvas->rotate(SkIntToScalar(-15));
             canvas->translate(textHeight * 4, SkIntToScalar(50));
             if (i > 0) {
@@ -81,8 +86,8 @@ protected:
 private:
     typedef GM INHERITED;
     SkScalar y, textHeight;
-    SkTypeface* prop;
-    SkTypeface* mono;
+    SkTypeface* fProp;
+    SkTypeface* fMono;
 };
 
 ///////////////////////////////////////////////////////////////////////////////
index 87797ac4caed314073c5493d5ad06e5f403b4fc4..dd2c1f0c4a4f12a73d9b0001ea024443340c5a82 100644 (file)
@@ -141,7 +141,12 @@ private:
 public:
     class DeviceContext : public SkRefCnt {
     public:
+        SK_DECLARE_INST_COUNT(DeviceContext)
+
         virtual void prepareForDraw() {}
+        
+    private:
+        typedef SkRefCnt INHERITED;
     };
 
 public:
index de2af04af1516b65f692201704a6d08c1cb7c150..36c27caebf9da90a8a381c19a2152c0c82c49217 100644 (file)
@@ -49,8 +49,13 @@ public:
      */
     class Dumper : public SkRefCnt {
     public:
+        SK_DECLARE_INST_COUNT(Dumper)
+
         virtual void dump(SkDumpCanvas*, SkDumpCanvas::Verb, const char str[],
                           const SkPaint*) = 0;
+        
+    private:
+        typedef SkRefCnt INHERITED;
     };
 
     Dumper* getDumper() const { return fDumper; }
index ac2b3cce1a53bbe6f2747df960e6f29d2e4398bf..096120a962c5c130431424c6cd2c323a74a81b97 100644 (file)
@@ -13,6 +13,8 @@
 #include "SkColorFilter.h"
 #include "SkDrawFilter.h"
 
+SK_DEFINE_INST_COUNT(SkDeferredCanvas::DeviceContext)
+
 namespace {
 
 bool isPaintOpaque(const SkPaint* paint, 
index 8a9ab7a28b1a1e5cd61e448f6ca6a31c87e132d8..57ee799ea4c199d029774f3f56297ac25fcc76b7 100644 (file)
@@ -19,6 +19,8 @@
 #include "SkPathEffect.h"
 #include "SkMaskFilter.h"
 
+SK_DEFINE_INST_COUNT(SkDumpCanvas::Dumper)
+
 static void toString(const SkRect& r, SkString* str) {
     str->printf("[%g,%g %g:%g]",
                 SkScalarToFloat(r.fLeft), SkScalarToFloat(r.fTop),
index 855d6a98e88a5c645ed028413d5bf31a310634a0..fb9df340db0cb71fd040d6e26e5ddfefd02cc8ad 100644 (file)
@@ -8,6 +8,9 @@
 #include "SkView.h"
 #include "SkCanvas.h"
 
+SK_DEFINE_INST_COUNT(SkViewFactory)
+SK_DEFINE_INST_COUNT(SkViewRegister)
+
 ////////////////////////////////////////////////////////////////////////
 
 SkView::SkView(uint32_t flags) : fFlags(SkToU8(flags))