Chromium Code Reviews| Index: tests/PictureTest.cpp |
| diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp |
| index c71e66309aa71cde7b567276950fdf306c582fba..c66d26d69fd2ae0d0db658aa126fa8fc73f7f3d1 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 MakeConvexPath() { |
|
mtklein
2016/05/25 13:26:49
static functions are usually named like make_conve
f(malita)
2016/05/25 14:42:49
Done.
|
| + SkPath path; |
| + path.lineTo(100, 0); |
| + path.lineTo(50, 100); |
| + path.close(); |
| + |
| + return path; |
| +} |
| + |
| +static SkPath MakeConcavePath() { |
| + 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 = MakeConvexPath(); |
| + const SkPath concaveClip = MakeConcavePath(); |
| + |
| + 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 = MakeConcavePath(); |
| + 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 = MakeConvexPath(); |
| + const SkPath concaveClip = MakeConcavePath(); |
| + 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 |