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

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

Issue 1020593003: Ensure that we use different glyph entries for regular and df text. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase Created 5 years, 9 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/GrFontCache.h ('k') | src/gpu/GrGlyph.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 "GrFontCache.h" 8 #include "GrFontCache.h"
9 #include "GrFontAtlasSizes.h" 9 #include "GrFontAtlasSizes.h"
10 #include "GrGpu.h" 10 #include "GrGpu.h"
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 251
252 #ifdef SK_DEBUG 252 #ifdef SK_DEBUG
253 gCounter -= 1; 253 gCounter -= 1;
254 // SkDebugf("~GrTextStrike %p %d\n", this, gCounter); 254 // SkDebugf("~GrTextStrike %p %d\n", this, gCounter);
255 #endif 255 #endif
256 } 256 }
257 257
258 GrGlyph* GrTextStrike::generateGlyph(GrGlyph::PackedID packed, 258 GrGlyph* GrTextStrike::generateGlyph(GrGlyph::PackedID packed,
259 GrFontScaler* scaler) { 259 GrFontScaler* scaler) {
260 SkIRect bounds; 260 SkIRect bounds;
261 if (fUseDistanceField) { 261 if (GrGlyph::kDistance_MaskStyle == GrGlyph::UnpackMaskStyle(packed)) {
262 if (!scaler->getPackedGlyphDFBounds(packed, &bounds)) { 262 if (!scaler->getPackedGlyphDFBounds(packed, &bounds)) {
263 return NULL; 263 return NULL;
264 } 264 }
265 } else { 265 } else {
266 if (!scaler->getPackedGlyphBounds(packed, &bounds)) { 266 if (!scaler->getPackedGlyphBounds(packed, &bounds)) {
267 return NULL; 267 return NULL;
268 } 268 }
269 } 269 }
270 GrMaskFormat format = scaler->getPackedGlyphMaskFormat(packed); 270 GrMaskFormat format = scaler->getPackedGlyphMaskFormat(packed);
271 271
(...skipping 11 matching lines...) Expand all
283 } 283 }
284 ++iter; 284 ++iter;
285 } 285 }
286 286
287 GrAtlas::RemovePlot(&fPlotUsage, plot); 287 GrAtlas::RemovePlot(&fPlotUsage, plot);
288 } 288 }
289 289
290 bool GrTextStrike::glyphTooLargeForAtlas(GrGlyph* glyph) { 290 bool GrTextStrike::glyphTooLargeForAtlas(GrGlyph* glyph) {
291 int width = glyph->fBounds.width(); 291 int width = glyph->fBounds.width();
292 int height = glyph->fBounds.height(); 292 int height = glyph->fBounds.height();
293 int pad = fUseDistanceField ? 2 * SK_DistanceFieldPad : 0; 293 bool useDistanceField =
294 (GrGlyph::kDistance_MaskStyle == GrGlyph::UnpackMaskStyle (glyph->fPackedID));
295 int pad = useDistanceField ? 2 * SK_DistanceFieldPad : 0;
294 int plotWidth = (kA8_GrMaskFormat == glyph->fMaskFormat) ? GR_FONT_ATLAS_A8_ PLOT_WIDTH 296 int plotWidth = (kA8_GrMaskFormat == glyph->fMaskFormat) ? GR_FONT_ATLAS_A8_ PLOT_WIDTH
295 : GR_FONT_ATLAS_PLO T_WIDTH; 297 : GR_FONT_ATLAS_PLO T_WIDTH;
296 if (width + pad > plotWidth) { 298 if (width + pad > plotWidth) {
297 return true; 299 return true;
298 } 300 }
299 if (height + pad > GR_FONT_ATLAS_PLOT_HEIGHT) { 301 if (height + pad > GR_FONT_ATLAS_PLOT_HEIGHT) {
300 return true; 302 return true;
301 } 303 }
302 304
303 return false; 305 return false;
(...skipping 10 matching lines...) Expand all
314 SkASSERT(fCache.find(glyph->fPackedID)); 316 SkASSERT(fCache.find(glyph->fPackedID));
315 SkASSERT(NULL == glyph->fPlot); 317 SkASSERT(NULL == glyph->fPlot);
316 318
317 SkAutoUnref ar(SkSafeRef(scaler)); 319 SkAutoUnref ar(SkSafeRef(scaler));
318 320
319 int bytesPerPixel = GrMaskFormatBytesPerPixel(glyph->fMaskFormat); 321 int bytesPerPixel = GrMaskFormatBytesPerPixel(glyph->fMaskFormat);
320 322
321 size_t size = glyph->fBounds.area() * bytesPerPixel; 323 size_t size = glyph->fBounds.area() * bytesPerPixel;
322 GrAutoMalloc<1024> storage(size); 324 GrAutoMalloc<1024> storage(size);
323 325
324 if (fUseDistanceField) { 326 if (GrGlyph::kDistance_MaskStyle == GrGlyph::UnpackMaskStyle(glyph->fPackedI D)) {
325 if (!scaler->getPackedGlyphDFImage(glyph->fPackedID, glyph->width(), 327 if (!scaler->getPackedGlyphDFImage(glyph->fPackedID, glyph->width(),
326 glyph->height(), 328 glyph->height(),
327 storage.get())) { 329 storage.get())) {
328 return false; 330 return false;
329 } 331 }
330 } else { 332 } else {
331 if (!scaler->getPackedGlyphImage(glyph->fPackedID, glyph->width(), 333 if (!scaler->getPackedGlyphImage(glyph->fPackedID, glyph->width(),
332 glyph->height(), 334 glyph->height(),
333 glyph->width() * bytesPerPixel, 335 glyph->width() * bytesPerPixel,
334 storage.get())) { 336 storage.get())) {
335 return false; 337 return false;
336 } 338 }
337 } 339 }
338 340
339 GrPlot* plot = fFontCache->addToAtlas(glyph->fMaskFormat, &fPlotUsage, 341 GrPlot* plot = fFontCache->addToAtlas(glyph->fMaskFormat, &fPlotUsage,
340 glyph->width(), glyph->height(), 342 glyph->width(), glyph->height(),
341 storage.get(), &glyph->fAtlasLocation) ; 343 storage.get(), &glyph->fAtlasLocation) ;
342 344
343 if (NULL == plot) { 345 if (NULL == plot) {
344 return false; 346 return false;
345 } 347 }
346 348
347 glyph->fPlot = plot; 349 glyph->fPlot = plot;
348 return true; 350 return true;
349 } 351 }
OLDNEW
« no previous file with comments | « src/gpu/GrFontCache.h ('k') | src/gpu/GrGlyph.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698