more SkInstCnt plumbing

fix some typeface leaks



git-svn-id: http://skia.googlecode.com/svn/trunk@4348 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
reed@google.com 2012-06-26 19:24:50 +00:00
parent 73e19fb1ba
commit 563a3b4102
6 changed files with 30 additions and 8 deletions

View 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;
};
///////////////////////////////////////////////////////////////////////////////

View 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:

View 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; }

View File

@ -13,6 +13,8 @@
#include "SkColorFilter.h"
#include "SkDrawFilter.h"
SK_DEFINE_INST_COUNT(SkDeferredCanvas::DeviceContext)
namespace {
bool isPaintOpaque(const SkPaint* paint,

View 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),

View 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))