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

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

Issue 224903012: Don't try to render color fonts using distance fields (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add comments; windows compile error Created 6 years, 8 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/core/SkScalerContext.h ('k') | src/gpu/GrTextStrike.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 2013 Google Inc. 2 * Copyright 2013 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 "GrDistanceFieldTextContext.h" 8 #include "GrDistanceFieldTextContext.h"
9 #include "GrAtlas.h" 9 #include "GrAtlas.h"
10 #include "GrDrawTarget.h" 10 #include "GrDrawTarget.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 fVertices = NULL; 49 fVertices = NULL;
50 fMaxVertices = 0; 50 fMaxVertices = 0;
51 } 51 }
52 52
53 GrDistanceFieldTextContext::~GrDistanceFieldTextContext() { 53 GrDistanceFieldTextContext::~GrDistanceFieldTextContext() {
54 this->flushGlyphs(); 54 this->flushGlyphs();
55 } 55 }
56 56
57 bool GrDistanceFieldTextContext::canDraw(const SkPaint& paint) { 57 bool GrDistanceFieldTextContext::canDraw(const SkPaint& paint) {
58 return (kForceDistanceFieldFonts || paint.isDistanceFieldTextTEMP()) && 58 if (!kForceDistanceFieldFonts && !paint.isDistanceFieldTextTEMP()) {
59 !paint.getRasterizer() && !paint.getMaskFilter() && 59 return false;
60 paint.getStyle() == SkPaint::kFill_Style && 60 }
61 fContext->getTextTarget()->caps()->shaderDerivativeSupport() && 61
62 !SkDraw::ShouldDrawTextAsPaths(paint, fContext->getMatrix()); 62 // rasterizers and mask filters modify alpha, which doesn't
63 // translate well to distance
64 if (paint.getRasterizer() || paint.getMaskFilter() ||
65 !fContext->getTextTarget()->caps()->shaderDerivativeSupport()) {
66 return false;
67 }
68
69 // TODO: add some stroking support
70 if (paint.getStyle() != SkPaint::kFill_Style) {
71 return false;
72 }
73
74 // TODO: choose an appropriate maximum scale for distance fields and
75 // enable perspective
76 if (SkDraw::ShouldDrawTextAsPaths(paint, fContext->getMatrix())) {
77 return false;
78 }
79
80 // distance fields cannot represent color fonts
81 SkScalerContext::Rec rec;
82 SkScalerContext::MakeRec(paint, &fDeviceProperties, NULL, &rec);
83 return rec.getFormat() != SkMask::kARGB32_Format;
63 } 84 }
64 85
65 static inline GrColor skcolor_to_grcolor_nopremultiply(SkColor c) { 86 static inline GrColor skcolor_to_grcolor_nopremultiply(SkColor c) {
66 unsigned r = SkColorGetR(c); 87 unsigned r = SkColorGetR(c);
67 unsigned g = SkColorGetG(c); 88 unsigned g = SkColorGetG(c);
68 unsigned b = SkColorGetB(c); 89 unsigned b = SkColorGetB(c);
69 return GrColorPackRGBA(r, g, b, 0xff); 90 return GrColorPackRGBA(r, g, b, 0xff);
70 } 91 }
71 92
72 void GrDistanceFieldTextContext::flushGlyphs() { 93 void GrDistanceFieldTextContext::flushGlyphs() {
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 SkScalarToFixed(y) - (glyph.fAdvanceY >> a lignShift) 493 SkScalarToFixed(y) - (glyph.fAdvanceY >> a lignShift)
473 + SK_FixedHalf, //d1g.fHalfSampleY, 494 + SK_FixedHalf, //d1g.fHalfSampleY,
474 fontScaler); 495 fontScaler);
475 } 496 }
476 pos += scalarsPerPosition; 497 pos += scalarsPerPosition;
477 } 498 }
478 } 499 }
479 500
480 this->finish(); 501 this->finish();
481 } 502 }
OLDNEW
« no previous file with comments | « src/core/SkScalerContext.h ('k') | src/gpu/GrTextStrike.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698