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

Unified Diff: src/gpu/GrOvalRenderer.cpp

Issue 2106953009: Fix bug where ovals' AA exceed bounds by .5 pixel (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: In addition to the past change, also outset/expand relevant variables/bounds Created 4 years, 6 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrOvalRenderer.cpp
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index cef08f431e3a4f047737d6d845c66e58b8f2cf3a..c0957b7079babcda390c6a44d380001b082e2e3f 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -820,27 +820,28 @@ private:
const SkRect& bounds = geom.fDevBounds;
// The inner radius in the vertex data must be specified in normalized space.
+ // fOffsets are expanded from xxRadii to include the half-pixel antialiasing width.
verts[0].fPos = SkPoint::Make(bounds.fLeft, bounds.fTop);
verts[0].fColor = color;
- verts[0].fOffset = SkPoint::Make(-xRadius, -yRadius);
+ verts[0].fOffset = SkPoint::Make(-xRadius - SK_ScalarHalf, -yRadius - SK_ScalarHalf);
jvanverth1 2016/06/30 18:00:06 I suggest creating two variables, like xMaxOffset
vjiaoblack 2016/06/30 18:41:17 Done.
verts[0].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip);
verts[0].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip);
verts[1].fPos = SkPoint::Make(bounds.fLeft, bounds.fBottom);
verts[1].fColor = color;
- verts[1].fOffset = SkPoint::Make(-xRadius, yRadius);
+ verts[1].fOffset = SkPoint::Make(-xRadius - SK_ScalarHalf, yRadius + SK_ScalarHalf);
verts[1].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip);
verts[1].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip);
verts[2].fPos = SkPoint::Make(bounds.fRight, bounds.fBottom);
verts[2].fColor = color;
- verts[2].fOffset = SkPoint::Make(xRadius, yRadius);
+ verts[2].fOffset = SkPoint::Make(xRadius + SK_ScalarHalf, yRadius + SK_ScalarHalf);
verts[2].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip);
verts[2].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip);
verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fTop);
verts[3].fColor = color;
- verts[3].fOffset = SkPoint::Make(xRadius, -yRadius);
+ verts[3].fOffset = SkPoint::Make(xRadius + SK_ScalarHalf, -yRadius - SK_ScalarHalf);
verts[3].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip);
verts[3].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip);
@@ -938,11 +939,11 @@ static GrDrawBatch* create_ellipse_batch(GrColor color,
yRadius += scaledStroke.fY;
}
- // 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;
+ // We've extended the outer x radius out half a pixel to antialias.
jvanverth1 2016/06/30 18:00:06 I would delete all these lines.
vjiaoblack 2016/06/30 18:41:17 Done.
+ // 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;
EllipseBatch::Geometry geometry;
geometry.fColor = color;
@@ -953,6 +954,9 @@ static GrDrawBatch* create_ellipse_batch(GrColor color,
geometry.fDevBounds = SkRect::MakeLTRB(center.fX - xRadius, center.fY - yRadius,
center.fX + xRadius, center.fY + yRadius);
+ // outset bounds to include half-pixel width antialiasing.
+ geometry.fDevBounds.outset(SK_ScalarHalf, SK_ScalarHalf);
+
return new EllipseBatch(geometry, viewMatrix,
isStrokeOnly && innerXRadius > 0 && innerYRadius > 0);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698