Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Unified Diff: tests/PictureTest.cpp

Issue 2000423005: Complex clipPath accounting (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: review Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkPictureCommon.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PictureTest.cpp
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp
index c71e66309aa71cde7b567276950fdf306c582fba..0603eb328f7597d3a8ac1c63fa1b7f1446677b73 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
« no previous file with comments | « src/core/SkPictureCommon.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698