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

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

Issue 1988833003: Remove GrFontDescKey. (Closed) Base URL: https://chromium.googlesource.com/skia.git@fontscaler
Patch Set: spelling fix Created 4 years, 7 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/text/GrBatchFontCache.h ('k') | src/gpu/text/GrFontScaler.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 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 "GrContext.h" 9 #include "GrContext.h"
10 #include "GrGpu.h" 10 #include "GrGpu.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 fAtlasConfigs[kARGB_GrMaskFormat].fWidth = 1024; 63 fAtlasConfigs[kARGB_GrMaskFormat].fWidth = 1024;
64 fAtlasConfigs[kARGB_GrMaskFormat].fHeight = 2048; 64 fAtlasConfigs[kARGB_GrMaskFormat].fHeight = 2048;
65 fAtlasConfigs[kARGB_GrMaskFormat].fLog2Width = 10; 65 fAtlasConfigs[kARGB_GrMaskFormat].fLog2Width = 10;
66 fAtlasConfigs[kARGB_GrMaskFormat].fLog2Height = 11; 66 fAtlasConfigs[kARGB_GrMaskFormat].fLog2Height = 11;
67 fAtlasConfigs[kARGB_GrMaskFormat].fPlotWidth = 256; 67 fAtlasConfigs[kARGB_GrMaskFormat].fPlotWidth = 256;
68 fAtlasConfigs[kARGB_GrMaskFormat].fPlotHeight = 256; 68 fAtlasConfigs[kARGB_GrMaskFormat].fPlotHeight = 256;
69 } 69 }
70 70
71 GrBatchFontCache::~GrBatchFontCache() { 71 GrBatchFontCache::~GrBatchFontCache() {
72 SkTDynamicHash<GrBatchTextStrike, GrFontDescKey>::Iter iter(&fCache); 72 StrikeHash::Iter iter(&fCache);
73 while (!iter.done()) { 73 while (!iter.done()) {
74 (*iter).fIsAbandoned = true; 74 (*iter).fIsAbandoned = true;
75 (*iter).unref(); 75 (*iter).unref();
76 ++iter; 76 ++iter;
77 } 77 }
78 for (int i = 0; i < kMaskFormatCount; ++i) { 78 for (int i = 0; i < kMaskFormatCount; ++i) {
79 delete fAtlases[i]; 79 delete fAtlases[i];
80 } 80 }
81 } 81 }
82 82
83 void GrBatchFontCache::freeAll() { 83 void GrBatchFontCache::freeAll() {
84 SkTDynamicHash<GrBatchTextStrike, GrFontDescKey>::Iter iter(&fCache); 84 StrikeHash::Iter iter(&fCache);
85 while (!iter.done()) { 85 while (!iter.done()) {
86 (*iter).fIsAbandoned = true; 86 (*iter).fIsAbandoned = true;
87 (*iter).unref(); 87 (*iter).unref();
88 ++iter; 88 ++iter;
89 } 89 }
90 fCache.rewind(); 90 fCache.rewind();
91 for (int i = 0; i < kMaskFormatCount; ++i) { 91 for (int i = 0; i < kMaskFormatCount; ++i) {
92 delete fAtlases[i]; 92 delete fAtlases[i];
93 fAtlases[i] = nullptr; 93 fAtlases[i] = nullptr;
94 } 94 }
95 } 95 }
96 96
97 void GrBatchFontCache::HandleEviction(GrBatchAtlas::AtlasID id, void* ptr) { 97 void GrBatchFontCache::HandleEviction(GrBatchAtlas::AtlasID id, void* ptr) {
98 GrBatchFontCache* fontCache = reinterpret_cast<GrBatchFontCache*>(ptr); 98 GrBatchFontCache* fontCache = reinterpret_cast<GrBatchFontCache*>(ptr);
99 99
100 SkTDynamicHash<GrBatchTextStrike, GrFontDescKey>::Iter iter(&fontCache->fCac he); 100 StrikeHash::Iter iter(&fontCache->fCache);
101 for (; !iter.done(); ++iter) { 101 for (; !iter.done(); ++iter) {
102 GrBatchTextStrike* strike = &*iter; 102 GrBatchTextStrike* strike = &*iter;
103 strike->removeID(id); 103 strike->removeID(id);
104 104
105 // clear out any empty strikes. We will preserve the strike whose call to addToAtlas 105 // clear out any empty strikes. We will preserve the strike whose call to addToAtlas
106 // triggered the eviction 106 // triggered the eviction
107 if (strike != fontCache->fPreserveStrike && 0 == strike->fAtlasedGlyphs) { 107 if (strike != fontCache->fPreserveStrike && 0 == strike->fAtlasedGlyphs) {
108 fontCache->fCache.remove(*(strike->fFontScalerKey)); 108 fontCache->fCache.remove(GrBatchTextStrike::GetKey(*strike));
109 strike->fIsAbandoned = true; 109 strike->fIsAbandoned = true;
110 strike->unref(); 110 strike->unref();
111 } 111 }
112 } 112 }
113 } 113 }
114 114
115 void GrBatchFontCache::dump() const { 115 void GrBatchFontCache::dump() const {
116 static int gDumpCount = 0; 116 static int gDumpCount = 0;
117 for (int i = 0; i < kMaskFormatCount; ++i) { 117 for (int i = 0; i < kMaskFormatCount; ++i) {
118 if (fAtlases[i]) { 118 if (fAtlases[i]) {
(...skipping 27 matching lines...) Expand all
146 /////////////////////////////////////////////////////////////////////////////// 146 ///////////////////////////////////////////////////////////////////////////////
147 147
148 /* 148 /*
149 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
150 represented by the GrHostFontScaler object we are given in getGlyph(). 150 represented by the GrHostFontScaler object we are given in getGlyph().
151 151
152 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
153 atlas and a position within that texture. 153 atlas and a position within that texture.
154 */ 154 */
155 155
156 GrBatchTextStrike::GrBatchTextStrike(GrBatchFontCache* cache, const GrFontDescKe y* key) 156 GrBatchTextStrike::GrBatchTextStrike(GrBatchFontCache* owner, const SkDescriptor & key)
157 : fFontScalerKey(SkRef(key)) 157 : fFontScalerKey(key)
158 , fPool(9/*start allocations at 512 bytes*/) 158 , fPool(9/*start allocations at 512 bytes*/)
159 , fBatchFontCache(owner) // no need to ref, it won't go away before we do
159 , fAtlasedGlyphs(0) 160 , fAtlasedGlyphs(0)
160 , fIsAbandoned(false) { 161 , fIsAbandoned(false) {}
161
162 fBatchFontCache = cache; // no need to ref, it won't go away before we d o
163 }
164 162
165 GrBatchTextStrike::~GrBatchTextStrike() { 163 GrBatchTextStrike::~GrBatchTextStrike() {
166 SkTDynamicHash<GrGlyph, GrGlyph::PackedID>::Iter iter(&fCache); 164 SkTDynamicHash<GrGlyph, GrGlyph::PackedID>::Iter iter(&fCache);
167 while (!iter.done()) { 165 while (!iter.done()) {
168 (*iter).reset(); 166 (*iter).reset();
169 ++iter; 167 ++iter;
170 } 168 }
171 } 169 }
172 170
173 GrGlyph* GrBatchTextStrike::generateGlyph(const SkGlyph& skGlyph, GrGlyph::Packe dID packed, 171 GrGlyph* GrBatchTextStrike::generateGlyph(const SkGlyph& skGlyph, GrGlyph::Packe dID packed,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 229
232 bool success = fBatchFontCache->addToAtlas(this, &glyph->fID, target, expect edMaskFormat, 230 bool success = fBatchFontCache->addToAtlas(this, &glyph->fID, target, expect edMaskFormat,
233 glyph->width(), glyph->height(), 231 glyph->width(), glyph->height(),
234 storage.get(), &glyph->fAtlasLoca tion); 232 storage.get(), &glyph->fAtlasLoca tion);
235 if (success) { 233 if (success) {
236 SkASSERT(GrBatchAtlas::kInvalidAtlasID != glyph->fID); 234 SkASSERT(GrBatchAtlas::kInvalidAtlasID != glyph->fID);
237 fAtlasedGlyphs++; 235 fAtlasedGlyphs++;
238 } 236 }
239 return success; 237 return success;
240 } 238 }
OLDNEW
« no previous file with comments | « src/gpu/text/GrBatchFontCache.h ('k') | src/gpu/text/GrFontScaler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698