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

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

Issue 1467133003: Remove unecessary GetGlyphIdMetrics call (Closed) Base URL: https://skia.googlesource.com/skia.git@temptext
Patch Set: added comment Created 5 years 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/batches/GrAtlasTextBatch.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 "GrContext.h" 9 #include "GrContext.h"
10 #include "GrGpu.h" 10 #include "GrGpu.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 while (!iter.done()) { 189 while (!iter.done()) {
190 if (id == (*iter).fID) { 190 if (id == (*iter).fID) {
191 (*iter).fID = GrBatchAtlas::kInvalidAtlasID; 191 (*iter).fID = GrBatchAtlas::kInvalidAtlasID;
192 fAtlasedGlyphs--; 192 fAtlasedGlyphs--;
193 SkASSERT(fAtlasedGlyphs >= 0); 193 SkASSERT(fAtlasedGlyphs >= 0);
194 } 194 }
195 ++iter; 195 ++iter;
196 } 196 }
197 } 197 }
198 198
199 bool GrBatchTextStrike::addGlyphToAtlas(GrDrawBatch::Target* target, GrGlyph* gl yph, 199 bool GrBatchTextStrike::addGlyphToAtlas(GrDrawBatch::Target* target,
200 GrFontScaler* scaler, const SkGlyph& skG lyph, 200 GrGlyph* glyph,
201 GrFontScaler* scaler,
201 GrMaskFormat expectedMaskFormat) { 202 GrMaskFormat expectedMaskFormat) {
202 SkASSERT(glyph); 203 SkASSERT(glyph);
203 SkASSERT(scaler); 204 SkASSERT(scaler);
204 SkASSERT(fCache.find(glyph->fPackedID)); 205 SkASSERT(fCache.find(glyph->fPackedID));
205 206
206 SkAutoUnref ar(SkSafeRef(scaler)); 207 SkAutoUnref ar(SkSafeRef(scaler));
207 208
208 int bytesPerPixel = GrMaskFormatBytesPerPixel(expectedMaskFormat); 209 int bytesPerPixel = GrMaskFormatBytesPerPixel(expectedMaskFormat);
209 210
210 size_t size = glyph->fBounds.area() * bytesPerPixel; 211 size_t size = glyph->fBounds.area() * bytesPerPixel;
211 SkAutoSMalloc<1024> storage(size); 212 SkAutoSMalloc<1024> storage(size);
212 213
214 const SkGlyph& skGlyph = scaler->grToSkGlyph(glyph->fPackedID);
213 if (GrGlyph::kDistance_MaskStyle == GrGlyph::UnpackMaskStyle(glyph->fPackedI D)) { 215 if (GrGlyph::kDistance_MaskStyle == GrGlyph::UnpackMaskStyle(glyph->fPackedI D)) {
214 if (!scaler->getPackedGlyphDFImage(skGlyph, glyph->width(), glyph->heigh t(), 216 if (!scaler->getPackedGlyphDFImage(skGlyph, glyph->width(), glyph->heigh t(),
215 storage.get())) { 217 storage.get())) {
216 return false; 218 return false;
217 } 219 }
218 } else { 220 } else {
219 if (!scaler->getPackedGlyphImage(skGlyph, glyph->width(), glyph->height( ), 221 if (!scaler->getPackedGlyphImage(skGlyph, glyph->width(), glyph->height( ),
220 glyph->width() * bytesPerPixel, expecte dMaskFormat, 222 glyph->width() * bytesPerPixel, expecte dMaskFormat,
221 storage.get())) { 223 storage.get())) {
222 return false; 224 return false;
223 } 225 }
224 } 226 }
225 227
226 bool success = fBatchFontCache->addToAtlas(this, &glyph->fID, target, expect edMaskFormat, 228 bool success = fBatchFontCache->addToAtlas(this, &glyph->fID, target, expect edMaskFormat,
227 glyph->width(), glyph->height(), 229 glyph->width(), glyph->height(),
228 storage.get(), &glyph->fAtlasLoca tion); 230 storage.get(), &glyph->fAtlasLoca tion);
229 if (success) { 231 if (success) {
230 SkASSERT(GrBatchAtlas::kInvalidAtlasID != glyph->fID); 232 SkASSERT(GrBatchAtlas::kInvalidAtlasID != glyph->fID);
231 fAtlasedGlyphs++; 233 fAtlasedGlyphs++;
232 } 234 }
233 return success; 235 return success;
234 } 236 }
OLDNEW
« no previous file with comments | « src/gpu/GrBatchFontCache.h ('k') | src/gpu/batches/GrAtlasTextBatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698