Chromium Code Reviews| 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); |
| } |