Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: src/core/SkFontHost.cpp

Issue 18461007: Fix two leaks & improve leak tracking (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/ports/SkFontMgr.h ('k') | src/doc/SkDocument.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2009 The Android Open Source Project 2 * Copyright 2009 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkFontLCDConfig.h" 8 #include "SkFontLCDConfig.h"
9 9
10 static SkFontLCDConfig::LCDOrientation gLCDOrientation = SkFontLCDConfig::kHoriz ontal_LCDOrientation; 10 static SkFontLCDConfig::LCDOrientation gLCDOrientation = SkFontLCDConfig::kHoriz ontal_LCDOrientation;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 SkFontStyle::SkFontStyle(int weight, int width, Slant slant) { 62 SkFontStyle::SkFontStyle(int weight, int width, Slant slant) {
63 fUnion.fU32 = 0; 63 fUnion.fU32 = 0;
64 fUnion.fR.fWeight = SkPin32(weight, kThin_Weight, kBlack_Weight); 64 fUnion.fR.fWeight = SkPin32(weight, kThin_Weight, kBlack_Weight);
65 fUnion.fR.fWidth = SkPin32(width, kUltraCondensed_Width, kUltaExpanded_Width ); 65 fUnion.fR.fWidth = SkPin32(width, kUltraCondensed_Width, kUltaExpanded_Width );
66 fUnion.fR.fSlant = SkPin32(slant, kUpright_Slant, kItalic_Slant); 66 fUnion.fR.fSlant = SkPin32(slant, kUpright_Slant, kItalic_Slant);
67 } 67 }
68 68
69 #include "SkFontMgr.h" 69 #include "SkFontMgr.h"
70 70
71
72 SK_DEFINE_INST_COUNT(SkFontStyleSet)
73
71 class SkEmptyFontStyleSet : public SkFontStyleSet { 74 class SkEmptyFontStyleSet : public SkFontStyleSet {
72 public: 75 public:
73 virtual int count() SK_OVERRIDE { return 0; } 76 virtual int count() SK_OVERRIDE { return 0; }
74 virtual void getStyle(int, SkFontStyle*, SkString*) SK_OVERRIDE { 77 virtual void getStyle(int, SkFontStyle*, SkString*) SK_OVERRIDE {
75 SkASSERT(!"SkFontStyleSet::getStyle called on empty set"); 78 SkASSERT(!"SkFontStyleSet::getStyle called on empty set");
76 } 79 }
77 virtual SkTypeface* createTypeface(int index) SK_OVERRIDE { 80 virtual SkTypeface* createTypeface(int index) SK_OVERRIDE {
78 SkASSERT(!"SkFontStyleSet::createTypeface called on empty set"); 81 SkASSERT(!"SkFontStyleSet::createTypeface called on empty set");
79 return NULL; 82 return NULL;
80 } 83 }
81 virtual SkTypeface* matchStyle(const SkFontStyle&) SK_OVERRIDE { 84 virtual SkTypeface* matchStyle(const SkFontStyle&) SK_OVERRIDE {
82 return NULL; 85 return NULL;
83 } 86 }
84 }; 87 };
85 88
86 SkFontStyleSet* SkFontStyleSet::CreateEmpty() { 89 SkFontStyleSet* SkFontStyleSet::CreateEmpty() {
87 return SkNEW(SkEmptyFontStyleSet); 90 return SkNEW(SkEmptyFontStyleSet);
88 } 91 }
89 92
90 /////////////////////////////////////////////////////////////////////////////// 93 ///////////////////////////////////////////////////////////////////////////////
91 94
95 SK_DEFINE_INST_COUNT(SkFontMgr)
96
92 class SkEmptyFontMgr : public SkFontMgr { 97 class SkEmptyFontMgr : public SkFontMgr {
93 protected: 98 protected:
94 virtual int onCountFamilies() SK_OVERRIDE { 99 virtual int onCountFamilies() SK_OVERRIDE {
95 return 0; 100 return 0;
96 } 101 }
97 virtual void onGetFamilyName(int index, SkString* familyName) SK_OVERRIDE { 102 virtual void onGetFamilyName(int index, SkString* familyName) SK_OVERRIDE {
98 SkASSERT(!"onGetFamilyName called with bad index"); 103 SkASSERT(!"onGetFamilyName called with bad index");
99 } 104 }
100 virtual SkFontStyleSet* onCreateStyleSet(int index) SK_OVERRIDE { 105 virtual SkFontStyleSet* onCreateStyleSet(int index) SK_OVERRIDE {
101 SkASSERT(!"onCreateStyleSet called with bad index"); 106 SkASSERT(!"onCreateStyleSet called with bad index");
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 static SkFontMgr* gFM; 178 static SkFontMgr* gFM;
174 if (NULL == gFM) { 179 if (NULL == gFM) {
175 gFM = SkFontMgr::Factory(); 180 gFM = SkFontMgr::Factory();
176 // we never want to return NULL 181 // we never want to return NULL
177 if (NULL == gFM) { 182 if (NULL == gFM) {
178 gFM = SkNEW(SkEmptyFontMgr); 183 gFM = SkNEW(SkEmptyFontMgr);
179 } 184 }
180 } 185 }
181 return SkRef(gFM); 186 return SkRef(gFM);
182 } 187 }
OLDNEW
« no previous file with comments | « include/ports/SkFontMgr.h ('k') | src/doc/SkDocument.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698