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

Side by Side Diff: src/gpu/GrTextStrike.cpp

Issue 22850006: Replace uses of GrAssert by SkASSERT. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 7 years, 4 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 | « src/gpu/GrTextContext.cpp ('k') | src/gpu/GrTextStrike_impl.h » ('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 2010 Google Inc. 2 * Copyright 2010 Google Inc.
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 "GrAtlas.h" 8 #include "GrAtlas.h"
9 #include "GrGpu.h" 9 #include "GrGpu.h"
10 #include "GrRectanizer.h" 10 #include "GrRectanizer.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 fAtlasMgr = SkNEW_ARGS(GrAtlasMgr, (fGpu)); 43 fAtlasMgr = SkNEW_ARGS(GrAtlasMgr, (fGpu));
44 } 44 }
45 GrTextStrike* strike = SkNEW_ARGS(GrTextStrike, 45 GrTextStrike* strike = SkNEW_ARGS(GrTextStrike,
46 (this, scaler->getKey(), 46 (this, scaler->getKey(),
47 scaler->getMaskFormat(), fAtlasMgr)); 47 scaler->getMaskFormat(), fAtlasMgr));
48 fCache.insert(key, strike); 48 fCache.insert(key, strike);
49 49
50 if (fHead) { 50 if (fHead) {
51 fHead->fPrev = strike; 51 fHead->fPrev = strike;
52 } else { 52 } else {
53 GrAssert(NULL == fTail); 53 SkASSERT(NULL == fTail);
54 fTail = strike; 54 fTail = strike;
55 } 55 }
56 strike->fPrev = NULL; 56 strike->fPrev = NULL;
57 strike->fNext = fHead; 57 strike->fNext = fHead;
58 fHead = strike; 58 fHead = strike;
59 59
60 return strike; 60 return strike;
61 } 61 }
62 62
63 void GrFontCache::freeAll() { 63 void GrFontCache::freeAll() {
(...skipping 11 matching lines...) Expand all
75 if (strike == preserveStrike) { 75 if (strike == preserveStrike) {
76 strike = strike->fPrev; 76 strike = strike->fPrev;
77 continue; 77 continue;
78 } 78 }
79 GrTextStrike* strikeToPurge = strike; 79 GrTextStrike* strikeToPurge = strike;
80 strike = strikeToPurge->fPrev; 80 strike = strikeToPurge->fPrev;
81 if (purge) { 81 if (purge) {
82 // keep purging if we won't free up any atlases with this strike. 82 // keep purging if we won't free up any atlases with this strike.
83 purge = (NULL == strikeToPurge->fAtlas); 83 purge = (NULL == strikeToPurge->fAtlas);
84 int index = fCache.slowFindIndex(strikeToPurge); 84 int index = fCache.slowFindIndex(strikeToPurge);
85 GrAssert(index >= 0); 85 SkASSERT(index >= 0);
86 fCache.removeAt(index, strikeToPurge->fFontScalerKey->getHash()); 86 fCache.removeAt(index, strikeToPurge->fFontScalerKey->getHash());
87 this->detachStrikeFromList(strikeToPurge); 87 this->detachStrikeFromList(strikeToPurge);
88 delete strikeToPurge; 88 delete strikeToPurge;
89 } 89 }
90 } 90 }
91 #if FONT_CACHE_STATS 91 #if FONT_CACHE_STATS
92 ++g_PurgeCount; 92 ++g_PurgeCount;
93 #endif 93 #endif
94 } 94 }
95 95
96 void GrFontCache::freeAtlasExceptFor(GrTextStrike* preserveStrike) { 96 void GrFontCache::freeAtlasExceptFor(GrTextStrike* preserveStrike) {
97 GrTextStrike* strike = fTail; 97 GrTextStrike* strike = fTail;
98 while (strike) { 98 while (strike) {
99 if (strike == preserveStrike) { 99 if (strike == preserveStrike) {
100 strike = strike->fPrev; 100 strike = strike->fPrev;
101 continue; 101 continue;
102 } 102 }
103 GrTextStrike* strikeToPurge = strike; 103 GrTextStrike* strikeToPurge = strike;
104 strike = strikeToPurge->fPrev; 104 strike = strikeToPurge->fPrev;
105 if (strikeToPurge->removeUnusedAtlases()) { 105 if (strikeToPurge->removeUnusedAtlases()) {
106 if (NULL == strikeToPurge->fAtlas) { 106 if (NULL == strikeToPurge->fAtlas) {
107 int index = fCache.slowFindIndex(strikeToPurge); 107 int index = fCache.slowFindIndex(strikeToPurge);
108 GrAssert(index >= 0); 108 SkASSERT(index >= 0);
109 fCache.removeAt(index, strikeToPurge->fFontScalerKey->getHash()) ; 109 fCache.removeAt(index, strikeToPurge->fFontScalerKey->getHash()) ;
110 this->detachStrikeFromList(strikeToPurge); 110 this->detachStrikeFromList(strikeToPurge);
111 delete strikeToPurge; 111 delete strikeToPurge;
112 } 112 }
113 break; 113 break;
114 } 114 }
115 } 115 }
116 } 116 }
117 117
118 #if GR_DEBUG 118 #if GR_DEBUG
119 void GrFontCache::validate() const { 119 void GrFontCache::validate() const {
120 int count = fCache.count(); 120 int count = fCache.count();
121 if (0 == count) { 121 if (0 == count) {
122 GrAssert(!fHead); 122 SkASSERT(!fHead);
123 GrAssert(!fTail); 123 SkASSERT(!fTail);
124 } else if (1 == count) { 124 } else if (1 == count) {
125 GrAssert(fHead == fTail); 125 SkASSERT(fHead == fTail);
126 } else { 126 } else {
127 GrAssert(fHead != fTail); 127 SkASSERT(fHead != fTail);
128 } 128 }
129 129
130 int count2 = 0; 130 int count2 = 0;
131 const GrTextStrike* strike = fHead; 131 const GrTextStrike* strike = fHead;
132 while (strike) { 132 while (strike) {
133 count2 += 1; 133 count2 += 1;
134 strike = strike->fNext; 134 strike = strike->fNext;
135 } 135 }
136 GrAssert(count == count2); 136 SkASSERT(count == count2);
137 137
138 count2 = 0; 138 count2 = 0;
139 strike = fTail; 139 strike = fTail;
140 while (strike) { 140 while (strike) {
141 count2 += 1; 141 count2 += 1;
142 strike = strike->fPrev; 142 strike = strike->fPrev;
143 } 143 }
144 GrAssert(count == count2); 144 SkASSERT(count == count2);
145 } 145 }
146 #endif 146 #endif
147 147
148 /////////////////////////////////////////////////////////////////////////////// 148 ///////////////////////////////////////////////////////////////////////////////
149 149
150 #if GR_DEBUG 150 #if GR_DEBUG
151 static int gCounter; 151 static int gCounter;
152 #endif 152 #endif
153 153
154 /* 154 /*
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 return GrAtlas::RemoveUnusedAtlases(fAtlasMgr, &fAtlas); 216 return GrAtlas::RemoveUnusedAtlases(fAtlasMgr, &fAtlas);
217 } 217 }
218 218
219 bool GrTextStrike::getGlyphAtlas(GrGlyph* glyph, GrFontScaler* scaler, 219 bool GrTextStrike::getGlyphAtlas(GrGlyph* glyph, GrFontScaler* scaler,
220 GrDrawTarget::DrawToken currentDrawToken) { 220 GrDrawTarget::DrawToken currentDrawToken) {
221 #if 0 // testing hack to force us to flush our cache often 221 #if 0 // testing hack to force us to flush our cache often
222 static int gCounter; 222 static int gCounter;
223 if ((++gCounter % 10) == 0) return false; 223 if ((++gCounter % 10) == 0) return false;
224 #endif 224 #endif
225 225
226 GrAssert(glyph); 226 SkASSERT(glyph);
227 GrAssert(scaler); 227 SkASSERT(scaler);
228 GrAssert(fCache.contains(glyph)); 228 SkASSERT(fCache.contains(glyph));
229 if (glyph->fAtlas) { 229 if (glyph->fAtlas) {
230 glyph->fAtlas->setDrawToken(currentDrawToken); 230 glyph->fAtlas->setDrawToken(currentDrawToken);
231 return true; 231 return true;
232 } 232 }
233 233
234 GrAutoRef ar(scaler); 234 GrAutoRef ar(scaler);
235 235
236 int bytesPerPixel = GrMaskFormatBytesPerPixel(fMaskFormat); 236 int bytesPerPixel = GrMaskFormatBytesPerPixel(fMaskFormat);
237 size_t size = glyph->fBounds.area() * bytesPerPixel; 237 size_t size = glyph->fBounds.area() * bytesPerPixel;
238 SkAutoSMalloc<1024> storage(size); 238 SkAutoSMalloc<1024> storage(size);
239 if (!scaler->getPackedGlyphImage(glyph->fPackedID, glyph->width(), 239 if (!scaler->getPackedGlyphImage(glyph->fPackedID, glyph->width(),
240 glyph->height(), 240 glyph->height(),
241 glyph->width() * bytesPerPixel, 241 glyph->width() * bytesPerPixel,
242 storage.get())) { 242 storage.get())) {
243 return false; 243 return false;
244 } 244 }
245 245
246 GrAtlas* atlas = fAtlasMgr->addToAtlas(&fAtlas, glyph->width(), 246 GrAtlas* atlas = fAtlasMgr->addToAtlas(&fAtlas, glyph->width(),
247 glyph->height(), storage.get(), 247 glyph->height(), storage.get(),
248 fMaskFormat, 248 fMaskFormat,
249 &glyph->fAtlasLocation); 249 &glyph->fAtlasLocation);
250 if (NULL == atlas) { 250 if (NULL == atlas) {
251 return false; 251 return false;
252 } 252 }
253 253
254 glyph->fAtlas = atlas; 254 glyph->fAtlas = atlas;
255 atlas->setDrawToken(currentDrawToken); 255 atlas->setDrawToken(currentDrawToken);
256 return true; 256 return true;
257 } 257 }
OLDNEW
« no previous file with comments | « src/gpu/GrTextContext.cpp ('k') | src/gpu/GrTextStrike_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698