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

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

Issue 1087203004: Store pointers to GrGlyph directly in BitmapTextBlob (Closed) Base URL: https://skia.googlesource.com/skia.git@atdfopt2
Patch Set: adding comment Created 5 years, 8 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
« no previous file with comments | « src/gpu/GrBatchFontCache.h ('k') | src/gpu/GrTextBlobCache.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 2015 Google Inc. 2 * Copyright 2015 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 "GrBatchFontCache.h" 8 #include "GrBatchFontCache.h"
9 #include "GrFontAtlasSizes.h" 9 #include "GrFontAtlasSizes.h"
10 #include "GrGpu.h" 10 #include "GrGpu.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 : fContext(context) 67 : fContext(context)
68 , fPreserveStrike(NULL) { 68 , fPreserveStrike(NULL) {
69 for (int i = 0; i < kMaskFormatCount; ++i) { 69 for (int i = 0; i < kMaskFormatCount; ++i) {
70 fAtlases[i] = NULL; 70 fAtlases[i] = NULL;
71 } 71 }
72 } 72 }
73 73
74 GrBatchFontCache::~GrBatchFontCache() { 74 GrBatchFontCache::~GrBatchFontCache() {
75 SkTDynamicHash<GrBatchTextStrike, GrFontDescKey>::Iter iter(&fCache); 75 SkTDynamicHash<GrBatchTextStrike, GrFontDescKey>::Iter iter(&fCache);
76 while (!iter.done()) { 76 while (!iter.done()) {
77 SkDELETE(&(*iter)); 77 (*iter).unref();
78 ++iter; 78 ++iter;
79 } 79 }
80 for (int i = 0; i < kMaskFormatCount; ++i) { 80 for (int i = 0; i < kMaskFormatCount; ++i) {
81 SkDELETE(fAtlases[i]); 81 SkDELETE(fAtlases[i]);
82 } 82 }
83 } 83 }
84 84
85 void GrBatchFontCache::freeAll() { 85 void GrBatchFontCache::freeAll() {
86 SkTDynamicHash<GrBatchTextStrike, GrFontDescKey>::Iter iter(&fCache); 86 SkTDynamicHash<GrBatchTextStrike, GrFontDescKey>::Iter iter(&fCache);
87 while (!iter.done()) { 87 while (!iter.done()) {
88 SkDELETE(&(*iter)); 88 (*iter).unref();
89 ++iter; 89 ++iter;
90 } 90 }
91 fCache.rewind(); 91 fCache.rewind();
92 for (int i = 0; i < kMaskFormatCount; ++i) { 92 for (int i = 0; i < kMaskFormatCount; ++i) {
93 SkDELETE(fAtlases[i]); 93 SkDELETE(fAtlases[i]);
94 fAtlases[i] = NULL; 94 fAtlases[i] = NULL;
95 } 95 }
96 } 96 }
97 97
98 GrPixelConfig GrBatchFontCache::getPixelConfig(GrMaskFormat format) const { 98 GrPixelConfig GrBatchFontCache::getPixelConfig(GrMaskFormat format) const {
(...skipping 12 matching lines...) Expand all
111 111
112 SkTDynamicHash<GrBatchTextStrike, GrFontDescKey>::Iter iter(&fontCache->fCac he); 112 SkTDynamicHash<GrBatchTextStrike, GrFontDescKey>::Iter iter(&fontCache->fCac he);
113 for (; !iter.done(); ++iter) { 113 for (; !iter.done(); ++iter) {
114 GrBatchTextStrike* strike = &*iter; 114 GrBatchTextStrike* strike = &*iter;
115 strike->removeID(id); 115 strike->removeID(id);
116 116
117 // clear out any empty strikes. We will preserve the strike whose call to addToAtlas 117 // clear out any empty strikes. We will preserve the strike whose call to addToAtlas
118 // triggered the eviction 118 // triggered the eviction
119 if (strike != fontCache->fPreserveStrike && 0 == strike->fAtlasedGlyphs) { 119 if (strike != fontCache->fPreserveStrike && 0 == strike->fAtlasedGlyphs) {
120 fontCache->fCache.remove(*(strike->fFontScalerKey)); 120 fontCache->fCache.remove(*(strike->fFontScalerKey));
121 SkDELETE(strike); 121 strike->fIsAbandoned = true;
122 strike->unref();
122 } 123 }
123 } 124 }
124 } 125 }
125 126
126 void GrBatchFontCache::dump() const { 127 void GrBatchFontCache::dump() const {
127 static int gDumpCount = 0; 128 static int gDumpCount = 0;
128 for (int i = 0; i < kMaskFormatCount; ++i) { 129 for (int i = 0; i < kMaskFormatCount; ++i) {
129 if (fAtlases[i]) { 130 if (fAtlases[i]) {
130 GrTexture* texture = fAtlases[i]->getTexture(); 131 GrTexture* texture = fAtlases[i]->getTexture();
131 if (texture) { 132 if (texture) {
(...skipping 16 matching lines...) Expand all
148 The text strike is specific to a given font/style/matrix setup, which is 149 The text strike is specific to a given font/style/matrix setup, which is
149 represented by the GrHostFontScaler object we are given in getGlyph(). 150 represented by the GrHostFontScaler object we are given in getGlyph().
150 151
151 We map a 32bit glyphID to a GrGlyph record, which in turn points to a 152 We map a 32bit glyphID to a GrGlyph record, which in turn points to a
152 atlas and a position within that texture. 153 atlas and a position within that texture.
153 */ 154 */
154 155
155 GrBatchTextStrike::GrBatchTextStrike(GrBatchFontCache* cache, const GrFontDescKe y* key) 156 GrBatchTextStrike::GrBatchTextStrike(GrBatchFontCache* cache, const GrFontDescKe y* key)
156 : fFontScalerKey(SkRef(key)) 157 : fFontScalerKey(SkRef(key))
157 , fPool(9/*start allocations at 512 bytes*/) 158 , fPool(9/*start allocations at 512 bytes*/)
158 , fAtlasedGlyphs(0) { 159 , fAtlasedGlyphs(0)
160 , fIsAbandoned(false) {
159 161
160 fBatchFontCache = cache; // no need to ref, it won't go away before we d o 162 fBatchFontCache = cache; // no need to ref, it won't go away before we d o
161 } 163 }
162 164
163 GrBatchTextStrike::~GrBatchTextStrike() { 165 GrBatchTextStrike::~GrBatchTextStrike() {
164 SkTDynamicHash<GrGlyph, GrGlyph::PackedID>::Iter iter(&fCache); 166 SkTDynamicHash<GrGlyph, GrGlyph::PackedID>::Iter iter(&fCache);
165 while (!iter.done()) { 167 while (!iter.done()) {
166 (*iter).free(); 168 (*iter).free();
167 ++iter; 169 ++iter;
168 } 170 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 } 250 }
249 251
250 bool success = fBatchFontCache->addToAtlas(this, &glyph->fID, batchTarget, g lyph->fMaskFormat, 252 bool success = fBatchFontCache->addToAtlas(this, &glyph->fID, batchTarget, g lyph->fMaskFormat,
251 glyph->width(), glyph->height(), 253 glyph->width(), glyph->height(),
252 storage.get(), &glyph->fAtlasLoca tion); 254 storage.get(), &glyph->fAtlasLoca tion);
253 if (success) { 255 if (success) {
254 fAtlasedGlyphs++; 256 fAtlasedGlyphs++;
255 } 257 }
256 return success; 258 return success;
257 } 259 }
OLDNEW
« no previous file with comments | « src/gpu/GrBatchFontCache.h ('k') | src/gpu/GrTextBlobCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698