Don't try to render color fonts using distance fields.
Adds detection of ARGB mask format, which is only used for color fonts.
BUG=skia:2173
R=bungeman@google.com, reed@google.com, bsalomon@google.com, robertphillips@google.com
Author: jvanverth@google.com
Review URL: https://codereview.chromium.org/224903012
git-svn-id: http://skia.googlecode.com/svn/trunk@14098 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrDistanceFieldTextContext.cpp b/src/gpu/GrDistanceFieldTextContext.cpp
index 675c146..1739c53 100755
--- a/src/gpu/GrDistanceFieldTextContext.cpp
+++ b/src/gpu/GrDistanceFieldTextContext.cpp
@@ -55,11 +55,32 @@
}
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) {