diff options
author | vjiaoblack <vjiaoblack@google.com> | 2016-06-30 12:20:54 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-06-30 12:20:54 -0700 |
commit | 977996dd0e0c6e6686a980a23e97e6fb5da1a592 (patch) | |
tree | 5b62d80f120ea4e605ad3bd3cee85d119b84a8ac /src/gpu | |
parent | 42eafa4bc00354b132ad114d22ed6b95d8849891 (diff) |
Fix bug where ovals' AA exceed bounds by .5 pixel
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2106953009
Review-Url: https://codereview.chromium.org/2106953009
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrOvalRenderer.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp index cef08f431e..3f73c6bf89 100644 --- a/src/gpu/GrOvalRenderer.cpp +++ b/src/gpu/GrOvalRenderer.cpp @@ -819,28 +819,32 @@ private: const SkRect& bounds = geom.fDevBounds; + // fOffsets are expanded from xyRadii to include the half-pixel antialiasing width. + SkScalar xMaxOffset = xRadius + SK_ScalarHalf; + SkScalar yMaxOffset = yRadius + SK_ScalarHalf; + // The inner radius in the vertex data must be specified in normalized space. 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(-xMaxOffset, -yMaxOffset); 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(-xMaxOffset, yMaxOffset); 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(xMaxOffset, yMaxOffset); 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(xMaxOffset, -yMaxOffset); verts[3].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip); verts[3].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip); @@ -938,12 +942,6 @@ 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; - EllipseBatch::Geometry geometry; geometry.fColor = color; geometry.fXRadius = xRadius; @@ -953,6 +951,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); } |