aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/BlurTest.cpp
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2016-08-10 12:00:09 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-08-10 12:00:09 -0700
commitf5a83e818483ef910ffd107df8f98b5ee24671f5 (patch)
tree0cf2910d3ecd52613dcdb3b050e4528b456eba52 /tests/BlurTest.cpp
parent69aaa5a49a10454d573cbd8c5d980029d78ae459 (diff)
Create blurred RRect mask on GPU (rather than uploading it)
This CL doesn't try to resolve any of the larger issues. It just moves the computation of the blurred RRect to the gpu and sets up to start using vertex attributes for a nine patch draw (i.e., returning the texture coordinates) All blurred rrects using the "analytic" path will change slightly with this CL. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2222083004 Committed: https://skia.googlesource.com/skia/+/75ccdc77a70ec2083141bf9ba98eb2f01ece2479 Committed: https://skia.googlesource.com/skia/+/94b5c5a41160e0f55e267fc3d830df65736fac50 Review-Url: https://codereview.chromium.org/2222083004
Diffstat (limited to 'tests/BlurTest.cpp')
-rw-r--r--tests/BlurTest.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/BlurTest.cpp b/tests/BlurTest.cpp
index 6ccb0471aa..32e2930171 100644
--- a/tests/BlurTest.cpp
+++ b/tests/BlurTest.cpp
@@ -574,4 +574,66 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SmallBoxBlurBug, reporter, ctxInfo) {
#endif
+
+DEF_TEST(BlurredRRectNinePatchComputation, reporter) {
+ const SkRect r = SkRect::MakeXYWH(10, 10, 100, 100);
+
+ bool ninePatchable;
+ SkRRect rrectToDraw;
+ SkISize size;
+ SkScalar xs[4], ys[4];
+ int numXs, numYs;
+
+ // not nine-patchable
+ {
+ SkVector radii[4] = { { 100, 100 }, { 0, 0 }, { 100, 100 }, { 0, 0 } };
+
+ SkRRect rr;
+ rr.setRectRadii(r, radii);
+
+ ninePatchable = SkBlurMaskFilter::ComputeBlurredRRectParams(rr, 3.0f, &rrectToDraw, &size,
+ xs, &numXs, ys, &numYs);
+ REPORTER_ASSERT(reporter, !ninePatchable);
+ }
+
+ // simple circular
+ {
+ SkRRect rr;
+ rr.setRectXY(r, 10, 10);
+
+ ninePatchable = SkBlurMaskFilter::ComputeBlurredRRectParams(rr, 3.0f, &rrectToDraw, &size,
+ xs, &numXs, ys, &numYs);
+ REPORTER_ASSERT(reporter, ninePatchable);
+ REPORTER_ASSERT(reporter, SkScalarNearlyEqual(SkIntToScalar(size.fWidth), 57.0f));
+ REPORTER_ASSERT(reporter, SkScalarNearlyEqual(SkIntToScalar(size.fHeight), 57.0));
+ REPORTER_ASSERT(reporter, 4 == numXs && 4 == numYs);
+ for (int i = 0; i < numXs; ++i) {
+ REPORTER_ASSERT(reporter, xs[i] >= 0.0f && xs[i] <= 1.0f);
+ }
+ for (int i = 0; i < numYs; ++i) {
+ REPORTER_ASSERT(reporter, ys[i] >= 0.0f && ys[i] <= 1.0f);
+ }
+ }
+
+ // simple elliptical
+ {
+ SkRRect rr;
+ rr.setRectXY(r, 2, 10);
+
+ ninePatchable = SkBlurMaskFilter::ComputeBlurredRRectParams(rr, 3.0f, &rrectToDraw, &size,
+ xs, &numXs, ys, &numYs);
+ REPORTER_ASSERT(reporter, ninePatchable);
+ REPORTER_ASSERT(reporter, SkScalarNearlyEqual(SkIntToScalar(size.fWidth), 41.0f));
+ REPORTER_ASSERT(reporter, SkScalarNearlyEqual(SkIntToScalar(size.fHeight), 57.0));
+ REPORTER_ASSERT(reporter, 4 == numXs && 4 == numYs);
+ for (int i = 0; i < numXs; ++i) {
+ REPORTER_ASSERT(reporter, xs[i] >= 0.0f && xs[i] <= 1.0f);
+ }
+ for (int i = 0; i < numYs; ++i) {
+ REPORTER_ASSERT(reporter, ys[i] >= 0.0f && ys[i] <= 1.0f);
+ }
+ }
+
+}
+
///////////////////////////////////////////////////////////////////////////////////////////