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

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

Issue 1011403005: Revert of Ensure that we use different glyph entries for regular and df text. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 (GrGlyph::kDistance_MaskStyle == GrGlyph::UnpackMaskStyle(packed)) { 261 if (fUseDistanceField) {
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 bool useDistanceField = 293 int pad = fUseDistanceField ? 2 * SK_DistanceFieldPad : 0;
294 (GrGlyph::kDistance_MaskStyle == GrGlyph::UnpackMaskStyle (glyph->fPackedID));
295 int pad = useDistanceField ? 2 * SK_DistanceFieldPad : 0;
296 int plotWidth = (kA8_GrMaskFormat == glyph->fMaskFormat) ? GR_FONT_ATLAS_A8_ PLOT_WIDTH 294 int plotWidth = (kA8_GrMaskFormat == glyph->fMaskFormat) ? GR_FONT_ATLAS_A8_ PLOT_WIDTH
297 : GR_FONT_ATLAS_PLO T_WIDTH; 295 : GR_FONT_ATLAS_PLO T_WIDTH;
298 if (width + pad > plotWidth) { 296 if (width + pad > plotWidth) {
299 return true; 297 return true;
300 } 298 }
301 if (height + pad > GR_FONT_ATLAS_PLOT_HEIGHT) { 299 if (height + pad > GR_FONT_ATLAS_PLOT_HEIGHT) {
302 return true; 300 return true;
303 } 301 }
304 302
305 return false; 303 return false;
(...skipping 10 matching lines...) Expand all
316 SkASSERT(fCache.find(glyph->fPackedID)); 314 SkASSERT(fCache.find(glyph->fPackedID));
317 SkASSERT(NULL == glyph->fPlot); 315 SkASSERT(NULL == glyph->fPlot);
318 316
319 SkAutoUnref ar(SkSafeRef(scaler)); 317 SkAutoUnref ar(SkSafeRef(scaler));
320 318
321 int bytesPerPixel = GrMaskFormatBytesPerPixel(glyph->fMaskFormat); 319 int bytesPerPixel = GrMaskFormatBytesPerPixel(glyph->fMaskFormat);
322 320
323 size_t size = glyph->fBounds.area() * bytesPerPixel; 321 size_t size = glyph->fBounds.area() * bytesPerPixel;
324 GrAutoMalloc<1024> storage(size); 322 GrAutoMalloc<1024> storage(size);
325 323
326 if (GrGlyph::kDistance_MaskStyle == GrGlyph::UnpackMaskStyle(glyph->fPackedI D)) { 324 if (fUseDistanceField) {
327 if (!scaler->getPackedGlyphDFImage(glyph->fPackedID, glyph->width(), 325 if (!scaler->getPackedGlyphDFImage(glyph->fPackedID, glyph->width(),
328 glyph->height(), 326 glyph->height(),
329 storage.get())) { 327 storage.get())) {
330 return false; 328 return false;
331 } 329 }
332 } else { 330 } else {
333 if (!scaler->getPackedGlyphImage(glyph->fPackedID, glyph->width(), 331 if (!scaler->getPackedGlyphImage(glyph->fPackedID, glyph->width(),
334 glyph->height(), 332 glyph->height(),
335 glyph->width() * bytesPerPixel, 333 glyph->width() * bytesPerPixel,
336 storage.get())) { 334 storage.get())) {
337 return false; 335 return false;
338 } 336 }
339 } 337 }
340 338
341 GrPlot* plot = fFontCache->addToAtlas(glyph->fMaskFormat, &fPlotUsage, 339 GrPlot* plot = fFontCache->addToAtlas(glyph->fMaskFormat, &fPlotUsage,
342 glyph->width(), glyph->height(), 340 glyph->width(), glyph->height(),
343 storage.get(), &glyph->fAtlasLocation) ; 341 storage.get(), &glyph->fAtlasLocation) ;
344 342
345 if (NULL == plot) { 343 if (NULL == plot) {
346 return false; 344 return false;
347 } 345 }
348 346
349 glyph->fPlot = plot; 347 glyph->fPlot = plot;
350 return true; 348 return true;
351 } 349 }
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