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

Unified Diff: tests/PictureTest.cpp

Issue 1974833003: SkPictureGpuAnalyzer (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: unneeded 'explicit' 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
Index: tests/PictureTest.cpp
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp
index b7fa1d1d91d0be18b684059ee555266dbb0ae3d3..3f2e645599e0f2892b3c988f22581d17433b4906 100644
--- a/tests/PictureTest.cpp
+++ b/tests/PictureTest.cpp
@@ -20,6 +20,7 @@
#include "SkMD5.h"
#include "SkPaint.h"
#include "SkPicture.h"
+#include "SkPictureAnalyzer.h"
#include "SkPictureRecorder.h"
#include "SkPictureUtils.h"
#include "SkPixelRef.h"
@@ -158,7 +159,8 @@ static void test_gpu_veto(skiatest::Reporter* reporter) {
// path effects currently render an SkPicture undesireable for GPU rendering
const char *reason = nullptr;
- REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(nullptr, &reason));
+ REPORTER_ASSERT(reporter,
+ !SkPictureGpuAnalyzer(picture).suitableForGpuRasterization(nullptr, &reason));
REPORTER_ASSERT(reporter, reason);
canvas = recorder.beginRecording(100, 100);
@@ -181,7 +183,7 @@ static void test_gpu_veto(skiatest::Reporter* reporter) {
}
picture = recorder.finishRecordingAsPicture();
// A lot of small AA concave paths should be fine for GPU rendering
- REPORTER_ASSERT(reporter, picture->suitableForGpuRasterization(nullptr));
+ REPORTER_ASSERT(reporter, SkPictureGpuAnalyzer(picture).suitableForGpuRasterization(nullptr));
canvas = recorder.beginRecording(100, 100);
{
@@ -203,7 +205,7 @@ static void test_gpu_veto(skiatest::Reporter* reporter) {
}
picture = recorder.finishRecordingAsPicture();
// A lot of large AA concave paths currently render an SkPicture undesireable for GPU rendering
- REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(nullptr));
+ REPORTER_ASSERT(reporter, !SkPictureGpuAnalyzer(picture).suitableForGpuRasterization(nullptr));
canvas = recorder.beginRecording(100, 100);
{
@@ -227,7 +229,7 @@ static void test_gpu_veto(skiatest::Reporter* reporter) {
}
picture = recorder.finishRecordingAsPicture();
// hairline stroked AA concave paths are fine for GPU rendering
- REPORTER_ASSERT(reporter, picture->suitableForGpuRasterization(nullptr));
+ REPORTER_ASSERT(reporter, SkPictureGpuAnalyzer(picture).suitableForGpuRasterization(nullptr));
canvas = recorder.beginRecording(100, 100);
{
@@ -243,7 +245,7 @@ static void test_gpu_veto(skiatest::Reporter* reporter) {
}
picture = recorder.finishRecordingAsPicture();
// fast-path dashed effects are fine for GPU rendering ...
- REPORTER_ASSERT(reporter, picture->suitableForGpuRasterization(nullptr));
+ REPORTER_ASSERT(reporter, SkPictureGpuAnalyzer(picture).suitableForGpuRasterization(nullptr));
canvas = recorder.beginRecording(100, 100);
{
@@ -257,15 +259,15 @@ static void test_gpu_veto(skiatest::Reporter* reporter) {
}
picture = recorder.finishRecordingAsPicture();
// ... but only when applied to drawPoint() calls
- REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(nullptr));
+ REPORTER_ASSERT(reporter, !SkPictureGpuAnalyzer(picture).suitableForGpuRasterization(nullptr));
// Nest the previous picture inside a new one.
canvas = recorder.beginRecording(100, 100);
{
- canvas->drawPicture(picture.get());
+ canvas->drawPicture(picture);
}
picture = recorder.finishRecordingAsPicture();
- REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(nullptr));
+ REPORTER_ASSERT(reporter, !SkPictureGpuAnalyzer(picture).suitableForGpuRasterization(nullptr));
}
#endif
@@ -1346,3 +1348,34 @@ DEF_TEST(Picture_preserveCullRect, r) {
REPORTER_ASSERT(r, deserializedPicture->cullRect().right() == 3);
REPORTER_ASSERT(r, deserializedPicture->cullRect().bottom() == 4);
}
+
+DEF_TEST(PictureGpuAnalyzer, r) {
+ SkPictureRecorder recorder;
+
+ {
+ SkCanvas* canvas = recorder.beginRecording(10, 10);
+ SkPaint paint;
+ SkScalar intervals [] = { 10, 20 };
+ paint.setPathEffect(SkDashPathEffect::Make(intervals, 2, 25));
+
+ for (int i = 0; i < 50; ++i) {
+ canvas->drawRect(SkRect::MakeWH(10, 10), paint);
+ }
+ }
+ sk_sp<SkPicture> vetoPicture(recorder.finishRecordingAsPicture());
+
+ SkPictureGpuAnalyzer analyzer;
+ REPORTER_ASSERT(r, analyzer.suitableForGpuRasterization(nullptr));
+
+ analyzer.analyze(vetoPicture.get());
+ REPORTER_ASSERT(r, !analyzer.suitableForGpuRasterization(nullptr));
+
+ analyzer.reset();
+ REPORTER_ASSERT(r, analyzer.suitableForGpuRasterization(nullptr));
+
+ recorder.beginRecording(10, 10)->drawPicture(vetoPicture);
+ sk_sp<SkPicture> nestedVetoPicture(recorder.finishRecordingAsPicture());
+
+ analyzer.analyze(nestedVetoPicture.get());
+ REPORTER_ASSERT(r, !analyzer.suitableForGpuRasterization(nullptr));
+}

Powered by Google App Engine
This is Rietveld 408576698