aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-14 21:22:38 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-14 21:22:38 +0000
commit0bed43c92623c01288812aae4f5030c56608d572 (patch)
tree1e2a2a10dbf8e65a49b732d65e2ddef44fd17a0f
parent1e7ee999d4e89c4270f27c99636b7cdb859b5d58 (diff)
Get correct text metrics for distance fields, and fix dropouts due to thin features.
BUG=skia:2173 R=robertphillips@google.com, reed@google.com Author: jvanverth@google.com Review URL: https://codereview.chromium.org/200423003 git-svn-id: http://skia.googlecode.com/svn/trunk@13815 2bbb7eff-a529-9590-31e7-b0007b416f81
-rwxr-xr-xsrc/core/SkDistanceFieldGen.cpp13
-rwxr-xr-xsrc/gpu/GrDistanceFieldTextContext.cpp2
2 files changed, 7 insertions, 8 deletions
diff --git a/src/core/SkDistanceFieldGen.cpp b/src/core/SkDistanceFieldGen.cpp
index 938b1a5a6c..44bea1b98d 100755
--- a/src/core/SkDistanceFieldGen.cpp
+++ b/src/core/SkDistanceFieldGen.cpp
@@ -28,8 +28,7 @@ enum NeighborFlags {
kNeighborFlagCount = 8
};
-// We treat an "edge" as a place where we cross from a texel >= 128 to a texel < 128,
-// or vice versa. This means we just need to check if the MSBs are different.
+// We treat an "edge" as a place where we cross from black to non-black, or vice versa.
// 'neighborFlags' is used to limit the directions in which we test to avoid indexing
// outside of the image
static bool found_edge(const unsigned char* imagePtr, int width, int neighborFlags) {
@@ -39,14 +38,14 @@ static bool found_edge(const unsigned char* imagePtr, int width, int neighborFla
SkASSERT(kNum8ConnectedNeighbors == kNeighborFlagCount);
// search for an edge
- unsigned char currVal = *imagePtr >> 7;
+ bool currVal = (*imagePtr != 0);
for (int i = 0; i < kNum8ConnectedNeighbors; ++i) {
- unsigned char checkVal;
+ bool checkVal;
if ((1 << i) & neighborFlags) {
const unsigned char* checkPtr = imagePtr + offsets[i];
- checkVal = *checkPtr >> 7;
+ checkVal = (*checkPtr != 0);
} else {
- checkVal = 0;
+ checkVal = false;
}
SkASSERT(checkVal == 0 || checkVal == 1);
SkASSERT(currVal == 0 || currVal == 1);
@@ -427,7 +426,7 @@ bool SkGenerateDistanceFieldFromImage(unsigned char* distanceField,
for (int j = 1; j < dataHeight-1; ++j) {
for (int i = 1; i < dataWidth-1; ++i) {
#if DUMP_EDGE
- unsigned char val = (currData->fAlpha >= 0.5f) ? 255 : 0;
+ unsigned char val = sk_float_round2int(255*currData->fAlpha);
if (*currEdge) {
val = 128;
}
diff --git a/src/gpu/GrDistanceFieldTextContext.cpp b/src/gpu/GrDistanceFieldTextContext.cpp
index 03d09a0331..2163e64049 100755
--- a/src/gpu/GrDistanceFieldTextContext.cpp
+++ b/src/gpu/GrDistanceFieldTextContext.cpp
@@ -308,7 +308,7 @@ inline void GrDistanceFieldTextContext::init(const GrPaint& paint, const SkPaint
fSkPaint.setTextSize(SkIntToScalar(kBaseDFFontSize));
fSkPaint.setLCDRenderText(false);
fSkPaint.setAutohinted(false);
- fSkPaint.setSubpixelText(false);
+ fSkPaint.setSubpixelText(true);
}
inline void GrDistanceFieldTextContext::finish() {