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

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

Issue 43383006: Clean up the GrTHashTable API. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: boo, default template arguments on a function are C++11... Created 7 years, 1 month 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/GrTextStrike.h ('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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 void GrFontCache::freeAll() { 83 void GrFontCache::freeAll() {
84 fCache.deleteAll(); 84 fCache.deleteAll();
85 for (int i = 0; i < kMaskFormatCount; ++i) { 85 for (int i = 0; i < kMaskFormatCount; ++i) {
86 delete fAtlasMgr[i]; 86 delete fAtlasMgr[i];
87 fAtlasMgr[i] = NULL; 87 fAtlasMgr[i] = NULL;
88 } 88 }
89 fHead = NULL; 89 fHead = NULL;
90 fTail = NULL; 90 fTail = NULL;
91 } 91 }
92 92
93 void GrFontCache::purgeStrike(GrTextStrike* strike) {
94 const GrFontCache::Key key(strike->fFontScalerKey);
95 fCache.remove(key, strike);
96 this->detachStrikeFromList(strike);
97 delete strike;
98 }
99
93 void GrFontCache::purgeExceptFor(GrTextStrike* preserveStrike) { 100 void GrFontCache::purgeExceptFor(GrTextStrike* preserveStrike) {
94 SkASSERT(NULL != preserveStrike); 101 SkASSERT(NULL != preserveStrike);
95 GrTextStrike* strike = fTail; 102 GrTextStrike* strike = fTail;
96 bool purge = true; 103 bool purge = true;
97 GrMaskFormat maskFormat = preserveStrike->fMaskFormat; 104 GrMaskFormat maskFormat = preserveStrike->fMaskFormat;
98 while (strike) { 105 while (strike) {
99 if (strike == preserveStrike || maskFormat != strike->fMaskFormat) { 106 if (strike == preserveStrike || maskFormat != strike->fMaskFormat) {
100 strike = strike->fPrev; 107 strike = strike->fPrev;
101 continue; 108 continue;
102 } 109 }
103 GrTextStrike* strikeToPurge = strike; 110 GrTextStrike* strikeToPurge = strike;
104 strike = strikeToPurge->fPrev; 111 strike = strikeToPurge->fPrev;
105 if (purge) { 112 if (purge) {
106 // keep purging if we won't free up any atlases with this strike. 113 // keep purging if we won't free up any atlases with this strike.
107 purge = strikeToPurge->fAtlas.isEmpty(); 114 purge = strikeToPurge->fAtlas.isEmpty();
108 int index = fCache.slowFindIndex(strikeToPurge); 115 this->purgeStrike(strikeToPurge);
109 SkASSERT(index >= 0);
110 fCache.removeAt(index, strikeToPurge->fFontScalerKey->getHash());
111 this->detachStrikeFromList(strikeToPurge);
112 delete strikeToPurge;
113 } 116 }
114 } 117 }
115 #if FONT_CACHE_STATS 118 #if FONT_CACHE_STATS
116 ++g_PurgeCount; 119 ++g_PurgeCount;
117 #endif 120 #endif
118 } 121 }
119 122
120 void GrFontCache::freePlotExceptFor(GrTextStrike* preserveStrike) { 123 void GrFontCache::freePlotExceptFor(GrTextStrike* preserveStrike) {
121 SkASSERT(NULL != preserveStrike); 124 SkASSERT(NULL != preserveStrike);
122 GrTextStrike* strike = fTail; 125 GrTextStrike* strike = fTail;
123 GrMaskFormat maskFormat = preserveStrike->fMaskFormat; 126 GrMaskFormat maskFormat = preserveStrike->fMaskFormat;
124 while (strike) { 127 while (strike) {
125 if (strike == preserveStrike || maskFormat != strike->fMaskFormat) { 128 if (strike == preserveStrike || maskFormat != strike->fMaskFormat) {
126 strike = strike->fPrev; 129 strike = strike->fPrev;
127 continue; 130 continue;
128 } 131 }
129 GrTextStrike* strikeToPurge = strike; 132 GrTextStrike* strikeToPurge = strike;
130 strike = strikeToPurge->fPrev; 133 strike = strikeToPurge->fPrev;
131 if (strikeToPurge->removeUnusedPlots()) { 134 if (strikeToPurge->removeUnusedPlots()) {
132 if (strikeToPurge->fAtlas.isEmpty()) { 135 if (strikeToPurge->fAtlas.isEmpty()) {
133 int index = fCache.slowFindIndex(strikeToPurge); 136 this->purgeStrike(strikeToPurge);
134 SkASSERT(index >= 0);
135 fCache.removeAt(index, strikeToPurge->fFontScalerKey->getHash()) ;
136 this->detachStrikeFromList(strikeToPurge);
137 delete strikeToPurge;
138 } 137 }
139 break; 138 break;
140 } 139 }
141 } 140 }
142 } 141 }
143 142
144 #ifdef SK_DEBUG 143 #ifdef SK_DEBUG
145 void GrFontCache::validate() const { 144 void GrFontCache::validate() const {
146 int count = fCache.count(); 145 int count = fCache.count();
147 if (0 == count) { 146 if (0 == count) {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 GrPlot* plot = fAtlasMgr->addToAtlas(&fAtlas, glyph->width(), 282 GrPlot* plot = fAtlasMgr->addToAtlas(&fAtlas, glyph->width(),
284 glyph->height(), storage.get(), 283 glyph->height(), storage.get(),
285 &glyph->fAtlasLocation); 284 &glyph->fAtlasLocation);
286 if (NULL == plot) { 285 if (NULL == plot) {
287 return false; 286 return false;
288 } 287 }
289 288
290 glyph->fPlot = plot; 289 glyph->fPlot = plot;
291 return true; 290 return true;
292 } 291 }
OLDNEW
« no previous file with comments | « src/gpu/GrTextStrike.h ('k') | src/gpu/GrTextStrike_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698