Simplify the circle outset code and add comment relating it to the shader code.
Review URL: https://codereview.chromium.org/13165012
git-svn-id: http://skia.googlecode.com/svn/trunk@8463 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index 7da89bd..8bc0428 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -130,19 +130,24 @@
}
}
+ // The radii are outset for two reasons. First, it allows the shader to simply perform
+ // clamp(distance-to-center - radius, 0, 1). Second, the outer radius is used to compute the
+ // verts of the bounding box that is rendered and the outset ensures the box will cover all
+ // pixels partially covered by the circle.
+ outerRadius += SK_ScalarHalf;
+ innerRadius -= SK_ScalarHalf;
+
for (int i = 0; i < 4; ++i) {
verts[i].fCenter = center;
- verts[i].fOuterRadius = outerRadius + 0.5f;
- verts[i].fInnerRadius = innerRadius - 0.5f;
+ verts[i].fOuterRadius = outerRadius;
+ verts[i].fInnerRadius = innerRadius;
}
- // We've extended the outer radius out half a pixel to antialias.
- // Expand the drawn rect here so all the pixels will be captured.
SkRect bounds = SkRect::MakeLTRB(
- center.fX - outerRadius - SK_ScalarHalf,
- center.fY - outerRadius - SK_ScalarHalf,
- center.fX + outerRadius + SK_ScalarHalf,
- center.fY + outerRadius + SK_ScalarHalf
+ center.fX - outerRadius,
+ center.fY - outerRadius,
+ center.fX + outerRadius,
+ center.fY + outerRadius
);
verts[0].fPos = SkPoint::Make(bounds.fLeft, bounds.fTop);