aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar brianosman <brianosman@google.com>2016-02-12 10:20:00 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-12 10:20:01 -0800
commitc6052ac41a704cc64f16c49780a8fd05c7f550d4 (patch)
tree436d4c35f3ef406bfde05f7a03fa1fb807b08425 /src
parentde8e54ccfd54db927b53cb86213ed7020a59d1e1 (diff)
Put back the 0.5 bias in the shader. Only adjust the radii for the geometry, not the radii constants.
After working through this with Jim, this is more mathematically correct, and also accounts for the inner radius. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1692683003 Review URL: https://codereview.chromium.org/1692683003
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrOvalRenderer.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index bc85f94228..5779f8ac4c 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -297,7 +297,7 @@ public:
// avoid calling inversesqrt on zero.
fragBuilder->codeAppend("grad_dot = max(grad_dot, 1.0e-4);");
fragBuilder->codeAppend("float invlen = inversesqrt(grad_dot);");
- fragBuilder->codeAppend("float edgeAlpha = clamp(-test*invlen, 0.0, 1.0);");
+ fragBuilder->codeAppend("float edgeAlpha = clamp(0.5-test*invlen, 0.0, 1.0);");
// for inner curve
if (ee.isStroked()) {
@@ -1081,8 +1081,8 @@ static GrDrawBatch* create_ellipse_batch(GrColor color,
// We've extended the outer x radius out half a pixel to antialias.
// This will also expand the rect so all the pixels will be captured.
// TODO: Consider if we should use sqrt(2)/2 instead
- xRadius += SK_ScalarHalf;
- yRadius += SK_ScalarHalf;
+ SkScalar geoXRadius = xRadius + SK_ScalarHalf;
+ SkScalar geoYRadius = yRadius + SK_ScalarHalf;
EllipseBatch::Geometry geometry;
geometry.fViewMatrix = viewMatrix;
@@ -1092,8 +1092,8 @@ static GrDrawBatch* create_ellipse_batch(GrColor color,
geometry.fInnerXRadius = innerXRadius;
geometry.fInnerYRadius = innerYRadius;
geometry.fStroke = isStrokeOnly && innerXRadius > 0 && innerYRadius > 0;
- geometry.fDevBounds = SkRect::MakeLTRB(center.fX - xRadius, center.fY - yRadius,
- center.fX + xRadius, center.fY + yRadius);
+ geometry.fDevBounds = SkRect::MakeLTRB(center.fX - geoXRadius, center.fY - geoYRadius,
+ center.fX + geoXRadius, center.fY + geoYRadius);
return EllipseBatch::Create(geometry);
}