Fix clipping of ovals on top & right
authorrobertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 22 Jun 2012 13:14:29 +0000 (13:14 +0000)
committerrobertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 22 Jun 2012 13:14:29 +0000 (13:14 +0000)
http://codereview.appspot.com/6294091/

git-svn-id: http://skia.googlecode.com/svn/trunk@4303 2bbb7eff-a529-9590-31e7-b0007b416f81

src/gpu/GrContext.cpp

index fc2b143..0fada64 100644 (file)
@@ -1126,10 +1126,13 @@ void GrContext::drawOval(const GrPaint& paint,
 
     CircleVertex* verts = reinterpret_cast<CircleVertex*>(geo.vertices());
 
-    SkScalar L = center.fX - outerRadius;
-    SkScalar R = center.fX + outerRadius;
-    SkScalar T = center.fY - outerRadius;
-    SkScalar B = center.fY + outerRadius;
+    // The fragment shader will extend the radius out half a pixel
+    // to antialias. Expand the drawn rect here so all the pixels
+    // will be captured.
+    SkScalar L = center.fX - outerRadius - SkFloatToScalar(0.5f);
+    SkScalar R = center.fX + outerRadius + SkFloatToScalar(0.5f);
+    SkScalar T = center.fY - outerRadius - SkFloatToScalar(0.5f);
+    SkScalar B = center.fY + outerRadius + SkFloatToScalar(0.5f);
 
     verts[0].fPos = SkPoint::Make(L, T);
     verts[1].fPos = SkPoint::Make(R, T);