| 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);
|
|
|