aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2018-01-26 09:49:48 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-01-28 00:18:37 +0000
commitfbe6620284a5df423f00ef5b935a24f0682cba29 (patch)
tree5446b5d72fdf9aa6d67696d4e4d7f389ae99628b /tests
parentd3c1b84a6e26d9f6acd09c221048c4f5ddbd9bbb (diff)
add SkPicture::MakePlaceholder()
Bug: skia:7536 Change-Id: I6ca7c680ef4fd69419254dc7f1af27343dbb8e89 Reviewed-on: https://skia-review.googlesource.com/99664 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/PictureTest.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp
index 714338f9d1..7acce49943 100644
--- a/tests/PictureTest.cpp
+++ b/tests/PictureTest.cpp
@@ -834,3 +834,22 @@ DEF_TEST(Picture_RecordsFlush, r) {
auto back = SkPicture::MakeFromData(skp->data(), skp->size());
REPORTER_ASSERT(r, back->approximateOpCount() == pic->approximateOpCount());
}
+
+DEF_TEST(Placeholder, r) {
+ SkRect cull = { 0,0, 10,20 };
+
+ // Each placeholder is unique.
+ sk_sp<SkPicture> p1 = SkPicture::MakePlaceholder(cull),
+ p2 = SkPicture::MakePlaceholder(cull);
+ REPORTER_ASSERT(r, p1->cullRect() == p2->cullRect());
+ REPORTER_ASSERT(r, p1->cullRect() == cull);
+ REPORTER_ASSERT(r, p1->uniqueID() != p2->uniqueID());
+
+ // Placeholders are never unrolled by SkCanvas (while other small pictures may be).
+ SkPictureRecorder recorder;
+ SkCanvas* canvas = recorder.beginRecording(cull);
+ canvas->drawPicture(p1);
+ canvas->drawPicture(p2);
+ sk_sp<SkPicture> pic = recorder.finishRecordingAsPicture();
+ REPORTER_ASSERT(r, pic->approximateOpCount() == 2);
+}