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

Unified Diff: tests/PictureTest.cpp

Issue 253443003: Add snapshot entry point to SkPictureRecorder (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 8 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
« include/core/SkPictureRecorder.h ('K') | « include/core/SkPictureRecorder.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
===================================================================
--- tests/PictureTest.cpp (revision 14346)
+++ tests/PictureTest.cpp (working copy)
@@ -701,6 +701,38 @@
canvas->save();
}
+// Test out SkPictureRecorder::snapshot
+static void test_snapshot(skiatest::Reporter* reporter) {
+ SkPictureRecorder recorder;
+
+ // Calling snapshot when not recording will return NULL
+ REPORTER_ASSERT(reporter, NULL == recorder.snapshot());
+
+ SkCanvas* canvas = recorder.beginRecording(10, 10, NULL, 0);
+
+ SkRect r = SkRect::MakeWH(5, 5);
+ SkPaint p;
+
+ canvas->drawRect(r, p);
+
+ SkAutoTUnref<SkPicture> snapshot(recorder.snapshot());
+ REPORTER_ASSERT(reporter, !snapshot->willPlayBackBitmaps());
+
+ SkBitmap bm;
+ make_bm(&bm, 10, 10, SK_ColorRED, true);
+
+ r.offset(5.0f, 5.0f);
+ canvas->drawBitmapRectToRect(bm, NULL, r);
+
+ SkAutoTUnref<SkPicture> final(recorder.endRecording());
+ REPORTER_ASSERT(reporter, final->willPlayBackBitmaps());
+
+ REPORTER_ASSERT(reporter, snapshot->uniqueID() != final->uniqueID());
+
+ // The snapshot shouldn't pick up any operations added after it was made
+ REPORTER_ASSERT(reporter, !snapshot->willPlayBackBitmaps());
+}
+
static void test_unbalanced_save_restores(skiatest::Reporter* reporter) {
SkCanvas testCanvas(100, 100);
set_canvas_to_save_count_4(&testCanvas);
@@ -1195,6 +1227,7 @@
#else
test_bad_bitmap();
#endif
+ test_snapshot(reporter);
test_unbalanced_save_restores(reporter);
test_peephole();
test_gatherpixelrefs(reporter);
« include/core/SkPictureRecorder.h ('K') | « include/core/SkPictureRecorder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698