aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PictureTest.cpp
diff options
context:
space:
mode:
authorGravatar fmalita <fmalita@chromium.org>2016-05-25 11:31:04 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-05-25 11:31:04 -0700
commitb5fc58e1de6c2428f786034262a2ecdc8388d21d (patch)
treea3c81e24d8118339a5ca9590797c12317582d886 /tests/PictureTest.cpp
parentf34cd632d777e8f8be2ec1f4f3a0c363a7a6214d (diff)
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
Diffstat (limited to 'tests/PictureTest.cpp')
-rw-r--r--tests/PictureTest.cpp63
1 files changed, 63 insertions, 0 deletions
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