From b5fc58e1de6c2428f786034262a2ecdc8388d21d Mon Sep 17 00:00:00 2001 From: fmalita Date: Wed, 25 May 2016 11:31:04 -0700 Subject: Complex clipPath accounting Add a clipPath heuristic to SkPathCounter, and extend SkPictureGpuAnalyzer to support external clipPath() op accounting. BUG=skia:5347 R=reed@google.com,mtklein@google.com,senorblanco@chromium.org,bsalomon@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2000423005 Review-Url: https://codereview.chromium.org/2000423005 --- tests/PictureTest.cpp | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'tests/PictureTest.cpp') diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp index c71e66309a..0603eb328f 100644 --- a/tests/PictureTest.cpp +++ b/tests/PictureTest.cpp @@ -135,6 +135,25 @@ static void rand_op(SkCanvas* canvas, SkRandom& rand) { #if SK_SUPPORT_GPU +static SkPath make_convex_path() { + SkPath path; + path.lineTo(100, 0); + path.lineTo(50, 100); + path.close(); + + return path; +} + +static SkPath make_concave_path() { + SkPath path; + path.lineTo(50, 50); + path.lineTo(100, 0); + path.lineTo(50, 100); + path.close(); + + return path; +} + static void test_gpu_veto(skiatest::Reporter* reporter) { SkPictureRecorder recorder; @@ -261,6 +280,34 @@ static void test_gpu_veto(skiatest::Reporter* reporter) { // ... but only when applied to drawPoint() calls REPORTER_ASSERT(reporter, !SkPictureGpuAnalyzer(picture).suitableForGpuRasterization()); + canvas = recorder.beginRecording(100, 100); + { + const SkPath convexClip = make_convex_path(); + const SkPath concaveClip = make_concave_path(); + + for (int i = 0; i < 50; ++i) { + canvas->clipPath(convexClip); + canvas->clipPath(concaveClip); + canvas->clipPath(convexClip, SkRegion::kIntersect_Op, true); + canvas->drawRect(SkRect::MakeWH(100, 100), SkPaint()); + } + } + picture = recorder.finishRecordingAsPicture(); + // Convex clips and non-AA concave clips are fine on the GPU. + REPORTER_ASSERT(reporter, SkPictureGpuAnalyzer(picture).suitableForGpuRasterization()); + + canvas = recorder.beginRecording(100, 100); + { + const SkPath concaveClip = make_concave_path(); + for (int i = 0; i < 50; ++i) { + canvas->clipPath(concaveClip, SkRegion::kIntersect_Op, true); + canvas->drawRect(SkRect::MakeWH(100, 100), SkPaint()); + } + } + picture = recorder.finishRecordingAsPicture(); + // ... but AA concave clips are not. + REPORTER_ASSERT(reporter, !SkPictureGpuAnalyzer(picture).suitableForGpuRasterization()); + // Nest the previous picture inside a new one. canvas = recorder.beginRecording(100, 100); { @@ -1380,6 +1427,22 @@ DEF_TEST(PictureGpuAnalyzer, r) { analyzer.analyze(nestedVetoPicture.get()); REPORTER_ASSERT(r, !analyzer.suitableForGpuRasterization()); + + analyzer.reset(); + + const SkPath convexClip = make_convex_path(); + const SkPath concaveClip = make_concave_path(); + for (int i = 0; i < 50; ++i) { + analyzer.analyzeClipPath(convexClip, SkRegion::kIntersect_Op, false); + analyzer.analyzeClipPath(convexClip, SkRegion::kIntersect_Op, true); + analyzer.analyzeClipPath(concaveClip, SkRegion::kIntersect_Op, false); + } + REPORTER_ASSERT(r, analyzer.suitableForGpuRasterization()); + + for (int i = 0; i < 50; ++i) { + analyzer.analyzeClipPath(concaveClip, SkRegion::kIntersect_Op, true); + } + REPORTER_ASSERT(r, !analyzer.suitableForGpuRasterization()); } #endif // SK_SUPPORT_GPU -- cgit v1.2.3