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

Unified Diff: src/gpu/GrOvalRenderer.cpp

Issue 13165012: Simplify the circle outset code and add comment relating it to the shader code. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 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
===================================================================
--- src/gpu/GrOvalRenderer.cpp (revision 8459)
+++ src/gpu/GrOvalRenderer.cpp (working copy)
@@ -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);
« 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