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

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

Issue 1184153004: Bump up point where we switch to distance fields for large glyphs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 6 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 | « no previous file | no next file » | 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 #include "GrAtlasTextContext.h" 7 #include "GrAtlasTextContext.h"
8 8
9 #include "GrBatch.h" 9 #include "GrBatch.h"
10 #include "GrBatchFontCache.h" 10 #include "GrBatchFontCache.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 static const size_t kGrayTextVASize = sizeof(SkPoint) + sizeof(GrColor) + sizeof (SkIPoint16); 49 static const size_t kGrayTextVASize = sizeof(SkPoint) + sizeof(GrColor) + sizeof (SkIPoint16);
50 50
51 static const int kMinDFFontSize = 18; 51 static const int kMinDFFontSize = 18;
52 static const int kSmallDFFontSize = 32; 52 static const int kSmallDFFontSize = 32;
53 static const int kSmallDFFontLimit = 32; 53 static const int kSmallDFFontLimit = 32;
54 static const int kMediumDFFontSize = 72; 54 static const int kMediumDFFontSize = 72;
55 static const int kMediumDFFontLimit = 72; 55 static const int kMediumDFFontLimit = 72;
56 static const int kLargeDFFontSize = 162; 56 static const int kLargeDFFontSize = 162;
57 static const int kLargeDFFontLimit = 2 * kLargeDFFontSize; 57 static const int kLargeDFFontLimit = 2 * kLargeDFFontSize;
58 58
59 static const int kLargeGlyphLimit = 192;
60
59 SkDEBUGCODE(static const int kExpectedDistanceAdjustTableSize = 8;) 61 SkDEBUGCODE(static const int kExpectedDistanceAdjustTableSize = 8;)
60 static const int kDistanceAdjustLumShift = 5; 62 static const int kDistanceAdjustLumShift = 5;
61 63
62 static const int kVerticesPerGlyph = 4; 64 static const int kVerticesPerGlyph = 4;
63 static const int kIndicesPerGlyph = 6; 65 static const int kIndicesPerGlyph = 6;
64 66
65 static size_t get_vertex_stride(GrMaskFormat maskFormat) { 67 static size_t get_vertex_stride(GrMaskFormat maskFormat) {
66 switch (maskFormat) { 68 switch (maskFormat) {
67 case kA8_GrMaskFormat: 69 case kA8_GrMaskFormat:
68 return kGrayTextVASize; 70 return kGrayTextVASize;
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 448
447 SkScalar maxScale = viewMatrix.getMaxScale(); 449 SkScalar maxScale = viewMatrix.getMaxScale();
448 SkScalar scaledTextSize = maxScale*skPaint.getTextSize(); 450 SkScalar scaledTextSize = maxScale*skPaint.getTextSize();
449 // Hinted text looks far better at small resolutions 451 // Hinted text looks far better at small resolutions
450 // Scaling up beyond 2x yields undesireable artifacts 452 // Scaling up beyond 2x yields undesireable artifacts
451 if (scaledTextSize < kMinDFFontSize || scaledTextSize > kLargeDFFontLimit) { 453 if (scaledTextSize < kMinDFFontSize || scaledTextSize > kLargeDFFontLimit) {
452 return false; 454 return false;
453 } 455 }
454 456
455 if (!fEnableDFRendering && !skPaint.isDistanceFieldTextTEMP() && 457 if (!fEnableDFRendering && !skPaint.isDistanceFieldTextTEMP() &&
456 scaledTextSize < kLargeDFFontSize) { 458 scaledTextSize < kLargeGlyphLimit) {
457 return false; 459 return false;
458 } 460 }
459 461
460 // rasterizers and mask filters modify alpha, which doesn't 462 // rasterizers and mask filters modify alpha, which doesn't
461 // translate well to distance 463 // translate well to distance
462 if (skPaint.getRasterizer() || skPaint.getMaskFilter() || 464 if (skPaint.getRasterizer() || skPaint.getMaskFilter() ||
463 !fContext->caps()->shaderCaps()->shaderDerivativeSupport()) { 465 !fContext->caps()->shaderCaps()->shaderDerivativeSupport()) {
464 return false; 466 return false;
465 } 467 }
466 468
(...skipping 1817 matching lines...) Expand 10 before | Expand all | Expand 10 after
2284 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat rix, text, 2286 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat rix, text,
2285 static_cast<size_t>(textLen), 0, 0, noClip)); 2287 static_cast<size_t>(textLen), 0, 0, noClip));
2286 2288
2287 SkScalar transX = static_cast<SkScalar>(random->nextU()); 2289 SkScalar transX = static_cast<SkScalar>(random->nextU());
2288 SkScalar transY = static_cast<SkScalar>(random->nextU()); 2290 SkScalar transY = static_cast<SkScalar>(random->nextU());
2289 const GrAtlasTextContext::BitmapTextBlob::Run::SubRunInfo& info = blob->fRun s[0].fSubRunInfo[0]; 2291 const GrAtlasTextContext::BitmapTextBlob::Run::SubRunInfo& info = blob->fRun s[0].fSubRunInfo[0];
2290 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t ransY, skPaint); 2292 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t ransY, skPaint);
2291 } 2293 }
2292 2294
2293 #endif 2295 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698