aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-04-08 20:14:32 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-04-08 20:14:32 +0000
commiteefd8a01fc984e15ca108cb2951c52b3ea17d6b8 (patch)
tree84a81c77c29ac19da9b976b93a7a936a8edff169 /src
parent066a28d2c19c5d09a7a8f27543a8c171c5816cf5 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/core/SkScalerContext.h4
-rwxr-xr-xsrc/gpu/GrDistanceFieldTextContext.cpp31
-rw-r--r--src/gpu/GrTextStrike.cpp19
3 files changed, 31 insertions, 23 deletions
diff --git a/src/core/SkScalerContext.h b/src/core/SkScalerContext.h
index 63b1f186f1..f18d217f62 100644
--- a/src/core/SkScalerContext.h
+++ b/src/core/SkScalerContext.h
@@ -192,8 +192,8 @@ public:
SkFontID findTypefaceIdForChar(SkUnichar uni);
#endif
- static inline void MakeRec(const SkPaint&, const SkDeviceProperties* deviceProperties,
- const SkMatrix*, Rec* rec);
+ static void MakeRec(const SkPaint&, const SkDeviceProperties* deviceProperties,
+ const SkMatrix*, Rec* rec);
static inline void PostMakeRec(const SkPaint&, Rec*);
static SkMaskGamma::PreBlend GetMaskPreBlend(const Rec& rec);
diff --git a/src/gpu/GrDistanceFieldTextContext.cpp b/src/gpu/GrDistanceFieldTextContext.cpp
index 675c146d60..1739c530dc 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) {
diff --git a/src/gpu/GrTextStrike.cpp b/src/gpu/GrTextStrike.cpp
index 8c2fa0bdd2..65ead0f0bb 100644
--- a/src/gpu/GrTextStrike.cpp
+++ b/src/gpu/GrTextStrike.cpp
@@ -332,22 +332,9 @@ bool GrTextStrike::addGlyphToAtlas(GrGlyph* glyph, GrFontScaler* scaler) {
(unsigned char*)storage.get(),
width, height, DISTANCE_FIELD_RANGE);
} else {
- // TODO: Fix color emoji
- // for now, copy glyph into distance field storage
- // this is not correct, but it won't crash
- sk_bzero(dfStorage.get(), dfSize);
- unsigned char* ptr = (unsigned char*) storage.get();
- unsigned char* dfPtr = (unsigned char*) dfStorage.get();
- size_t dfStride = dfWidth*bytesPerPixel;
- dfPtr += DISTANCE_FIELD_RANGE*dfStride;
- dfPtr += DISTANCE_FIELD_RANGE*bytesPerPixel;
-
- for (int i = 0; i < height; ++i) {
- memcpy(dfPtr, ptr, stride);
-
- dfPtr += dfStride;
- ptr += stride;
- }
+ // distance fields should only be used to represent alpha masks
+ SkASSERT(false);
+ return false;
}
// copy to atlas