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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkScalerContext.h ('k') | src/gpu/GrTextStrike.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrDistanceFieldTextContext.cpp
diff --git a/src/gpu/GrDistanceFieldTextContext.cpp b/src/gpu/GrDistanceFieldTextContext.cpp
index 675c146d60dde29aa210b070f8f91fc364d9aaef..1739c530dc916ea935bca48376afbf7e788bb656 100755
--- a/src/gpu/GrDistanceFieldTextContext.cpp
+++ b/src/gpu/GrDistanceFieldTextContext.cpp
@@ -55,11 +55,32 @@ GrDistanceFieldTextContext::~GrDistanceFieldTextContext() {
}
bool GrDistanceFieldTextContext::canDraw(const SkPaint& paint) {
- return (kForceDistanceFieldFonts || paint.isDistanceFieldTextTEMP()) &&
- !paint.getRasterizer() && !paint.getMaskFilter() &&
- paint.getStyle() == SkPaint::kFill_Style &&
- fContext->getTextTarget()->caps()->shaderDerivativeSupport() &&
- !SkDraw::ShouldDrawTextAsPaths(paint, fContext->getMatrix());
+ if (!kForceDistanceFieldFonts && !paint.isDistanceFieldTextTEMP()) {
+ return false;
+ }
+
+ // rasterizers and mask filters modify alpha, which doesn't
+ // translate well to distance
+ if (paint.getRasterizer() || paint.getMaskFilter() ||
+ !fContext->getTextTarget()->caps()->shaderDerivativeSupport()) {
+ return false;
+ }
+
+ // TODO: add some stroking support
+ if (paint.getStyle() != SkPaint::kFill_Style) {
+ return false;
+ }
+
+ // TODO: choose an appropriate maximum scale for distance fields and
+ // enable perspective
+ if (SkDraw::ShouldDrawTextAsPaths(paint, fContext->getMatrix())) {
+ return false;
+ }
+
+ // distance fields cannot represent color fonts
+ SkScalerContext::Rec rec;
+ SkScalerContext::MakeRec(paint, &fDeviceProperties, NULL, &rec);
+ return rec.getFormat() != SkMask::kARGB32_Format;
}
static inline GrColor skcolor_to_grcolor_nopremultiply(SkColor c) {
« 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