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

Unified Diff: src/gpu/GrOvalRenderer.cpp

Issue 2283003003: Use stroked rrects for Android shadow sample (Closed)
Patch Set: Ubuntu error Created 4 years, 4 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 | « src/effects/SkGaussianEdgeShader.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrOvalRenderer.cpp
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index e5eb665a3d479b6cdecbb7949db0ad04f8266aea..b8c3d3eeb8fc3f9972db37d41284c0959985d8b5 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -1526,7 +1526,7 @@ private:
}
// Setup geometry processor
- SkAutoTUnref<GrGeometryProcessor> gp(new CircleGeometryProcessor(kStroke_RRectType == fType,
+ SkAutoTUnref<GrGeometryProcessor> gp(new CircleGeometryProcessor(kFill_RRectType != fType,
false, false,
false, localMatrix));
@@ -1612,73 +1612,77 @@ private:
verts++;
}
// Add the additional vertices for overstroked rrects.
- // Effectively this is an additional rrect, drawn inside out,
- // with outerRadius == -innerRadius. This will give us correct AA in the center.
+ // Effectively this is an additional stroked rrect, with its
+ // outer radius = outerRadius - innerRadius, and inner radius = 0.
+ // This will give us correct AA in the center and the correct
+ // distance to the outer edge.
//
- // Note that args.fInnerRadius is negative in this case.
- // Also, the offset is a constant vector pointing to the right, which guarantees
- // that the distance value along the inner rectangle is constant, which
- // is what we want to get nice anti-aliasing.
+ // Also, the outer offset is a constant vector pointing to the right, which
+ // guarantees that the distance value along the outer rectangle is constant.
if (kOverstroke_RRectType == fType) {
+ SkScalar overstrokeOuterRadius = outerRadius - args.fInnerRadius;
+ // this is the normalized distance from the outer rectangle of this
+ // geometry to the outer edge
+ SkScalar maxOffset = -args.fInnerRadius/overstrokeOuterRadius;
+
verts->fPos = SkPoint::Make(bounds.fLeft + outerRadius, yCoords[1]);
verts->fColor = color;
- verts->fOffset = SkPoint::Make(0, 0);
- verts->fOuterRadius = -args.fInnerRadius;
- verts->fInnerRadius = innerRadius;
+ verts->fOffset = SkPoint::Make(maxOffset, 0);
+ verts->fOuterRadius = overstrokeOuterRadius;
+ verts->fInnerRadius = 0;
verts++;
verts->fPos = SkPoint::Make(bounds.fRight - outerRadius, yCoords[1]);
verts->fColor = color;
- verts->fOffset = SkPoint::Make(0, 0);
- verts->fOuterRadius = -args.fInnerRadius;
- verts->fInnerRadius = innerRadius;
+ verts->fOffset = SkPoint::Make(maxOffset, 0);
+ verts->fOuterRadius = overstrokeOuterRadius;
+ verts->fInnerRadius = 0;
verts++;
- SkScalar inset = outerRadius - args.fInnerRadius;
- verts->fPos = SkPoint::Make(bounds.fLeft + inset,
- bounds.fTop + inset);
+ verts->fPos = SkPoint::Make(bounds.fLeft + overstrokeOuterRadius,
+ bounds.fTop + overstrokeOuterRadius);
verts->fColor = color;
- verts->fOffset = SkPoint::Make(1, 0);
- verts->fOuterRadius = -args.fInnerRadius;
- verts->fInnerRadius = innerRadius;
+ verts->fOffset = SkPoint::Make(0, 0);
+ verts->fOuterRadius = overstrokeOuterRadius;
+ verts->fInnerRadius = 0;
verts++;
- verts->fPos = SkPoint::Make(bounds.fRight - inset,
- bounds.fTop + inset);
+ verts->fPos = SkPoint::Make(bounds.fRight - overstrokeOuterRadius,
+ bounds.fTop + overstrokeOuterRadius);
verts->fColor = color;
- verts->fOffset = SkPoint::Make(1, 0);
- verts->fOuterRadius = -args.fInnerRadius;
- verts->fInnerRadius = innerRadius;
+ verts->fOffset = SkPoint::Make(0, 0);
+ verts->fOuterRadius = overstrokeOuterRadius;
+ verts->fInnerRadius = 0;
verts++;
- verts->fPos = SkPoint::Make(bounds.fLeft + inset,
- bounds.fBottom - inset);
+ verts->fPos = SkPoint::Make(bounds.fLeft + overstrokeOuterRadius,
+ bounds.fBottom - overstrokeOuterRadius);
verts->fColor = color;
- verts->fOffset = SkPoint::Make(1, 0);
- verts->fOuterRadius = -args.fInnerRadius;
- verts->fInnerRadius = innerRadius;
+ verts->fOffset = SkPoint::Make(0, 0);
+ verts->fOuterRadius = overstrokeOuterRadius;
+ verts->fInnerRadius = 0;
verts++;
- verts->fPos = SkPoint::Make(bounds.fRight - inset,
- bounds.fBottom - inset);
+ verts->fPos = SkPoint::Make(bounds.fRight - overstrokeOuterRadius,
+ bounds.fBottom - overstrokeOuterRadius);
verts->fColor = color;
- verts->fOffset = SkPoint::Make(1, 0);
- verts->fOuterRadius = -args.fInnerRadius;
- verts->fInnerRadius = innerRadius;
+ verts->fOffset = SkPoint::Make(0, 0);
+ verts->fOuterRadius = overstrokeOuterRadius;
+ verts->fInnerRadius = 0;
verts++;
verts->fPos = SkPoint::Make(bounds.fLeft + outerRadius, yCoords[2]);
verts->fColor = color;
- verts->fOffset = SkPoint::Make(0, 0);
- verts->fOuterRadius = -args.fInnerRadius;
- verts->fInnerRadius = innerRadius;
+ verts->fOffset = SkPoint::Make(maxOffset, 0);
+ verts->fOuterRadius = overstrokeOuterRadius;
+ verts->fInnerRadius = 0;
verts++;
verts->fPos = SkPoint::Make(bounds.fRight - outerRadius, yCoords[2]);
verts->fColor = color;
- verts->fOffset = SkPoint::Make(0, 0);
- verts->fOuterRadius = -args.fInnerRadius;
- verts->fInnerRadius = innerRadius;
+ verts->fOffset = SkPoint::Make(maxOffset, 0);
+ verts->fOuterRadius = overstrokeOuterRadius;
+ verts->fInnerRadius = 0;
verts++;
}
}
« no previous file with comments | « src/effects/SkGaussianEdgeShader.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698