aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrOvalRenderer.cpp
diff options
context:
space:
mode:
authorGravatar jvanverth <jvanverth@google.com>2016-08-29 07:17:47 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-08-29 07:17:47 -0700
commita4f1af8f9778462184c2bef91de1b1827568c08b (patch)
tree15431f3725abb5c2d3ed87b345736c66d382c276 /src/gpu/GrOvalRenderer.cpp
parenta28e263d42760370c9ff0b269b31a78d6701fb44 (diff)
Use stroked rrects for Android shadow sample
Changes the Android shadow sample to use stroked roundrects when we can (mainly if stroked geometry area < fill geometry area). Also changes the setup for the overstroke geometry so that it computes the correct distance to the outer edge. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2283003003 Review-Url: https://codereview.chromium.org/2283003003
Diffstat (limited to 'src/gpu/GrOvalRenderer.cpp')
-rw-r--r--src/gpu/GrOvalRenderer.cpp84
1 files changed, 44 insertions, 40 deletions
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index e5eb665a3d..b8c3d3eeb8 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++;
}
}