diff options
author | Mike Klein <mtklein@chromium.org> | 2017-08-14 10:39:28 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-08-14 15:29:05 +0000 |
commit | 7cc49d65fc5788f72458efc8fc4156cde4cca15a (patch) | |
tree | 00ef007c014f88c0949231653cd1b97290e829af /tests | |
parent | 0db0779199ee74074c39c6ea4e870ea9b231622b (diff) |
Record SkCanvas::flush().
We can record multiple frames in an .skp by recording SkCanvas::flush().
This should make SkPictures, SkLiteDL, and .skp files all record flush().
Change-Id: I6cf6e0e4ef993530d9f92fa168a53702ffce7d5e
Reviewed-on: https://skia-review.googlesource.com/34081
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/PictureTest.cpp | 22 | ||||
-rw-r--r-- | tests/SkLiteDLTest.cpp | 11 |
2 files changed, 33 insertions, 0 deletions
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp index d407fc0848..799405e558 100644 --- a/tests/PictureTest.cpp +++ b/tests/PictureTest.cpp @@ -1171,3 +1171,25 @@ DEF_TEST(Picture_UpdatedCull_2, r) { pic = recorder.finishRecordingAsPicture(); REPORTER_ASSERT(r, pic->cullRect() == SkRect::MakeLargest()); } + +DEF_TEST(Picture_RecordsFlush, r) { + SkPictureRecorder recorder; + + auto canvas = recorder.beginRecording(SkRect::MakeWH(100,100)); + for (int i = 0; i < 10; i++) { + canvas->clear(0); + for (int j = 0; j < 10; j++) { + canvas->drawRect(SkRect::MakeXYWH(i*10,j*10,10,10), SkPaint()); + } + canvas->flush(); + } + + // Did we record the flushes? + auto pic = recorder.finishRecordingAsPicture(); + REPORTER_ASSERT(r, pic->approximateOpCount() == 120); // 10 clears, 100 draws, 10 flushes + + // Do we serialize and deserialize flushes? + auto skp = pic->serialize(); + auto back = SkPicture::MakeFromData(skp->data(), skp->size()); + REPORTER_ASSERT(r, back->approximateOpCount() == pic->approximateOpCount()); +} diff --git a/tests/SkLiteDLTest.cpp b/tests/SkLiteDLTest.cpp index 514464aaf9..d719c0bb76 100644 --- a/tests/SkLiteDLTest.cpp +++ b/tests/SkLiteDLTest.cpp @@ -51,3 +51,14 @@ DEF_TEST(SkLiteRecorder, r) { c->drawRect(SkRect{0,0,9,9}, SkPaint{}); c->restore(); } + +DEF_TEST(SkLiteRecorder_RecordsFlush, r) { + SkLiteDL dl; + + SkLiteRecorder canvas; + canvas.reset(&dl, {0,0,100,100}); + + REPORTER_ASSERT(r, dl.empty()); + canvas.flush(); + REPORTER_ASSERT(r, !dl.empty()); +} |