aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@google.com>2018-01-27 17:30:04 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-01-27 17:30:15 +0000
commit88d90714fad0fed2739fb8c5f90fe814c8a274ef (patch)
tree85d26395c1fbcdd21ca0e2029b022862ca09fe79 /tests
parentfc20008819f39e1504aa572e28c56e83e14bff79 (diff)
Revert "hide picture virtuals (no public callers)"
This reverts commit 8005bff7e631a269f0dfaae93ff9963dc0e5ff39. Reason for revert: hwui, flutter, and headless blink in G3 all still using these. Original change's description: > hide picture virtuals (no public callers) > > This prepares the way for a clean impl of a "placeholder" picture that never unrolls > > Bug: skia: > Change-Id: I3b5785c5c94432b54e9a7dc280b2a6e716592473 > Reviewed-on: https://skia-review.googlesource.com/100260 > Commit-Queue: Mike Reed <reed@google.com> > Reviewed-by: Mike Klein <mtklein@chromium.org> TBR=mtklein@chromium.org,mtklein@google.com,reed@google.com Change-Id: I385789dd420588ea9a9390c8a44c6ecb96c7f358 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia: Reviewed-on: https://skia-review.googlesource.com/100880 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Mike Klein <mtklein@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/ImageTest.cpp2
-rw-r--r--tests/PictureTest.cpp25
-rw-r--r--tests/SerializationTest.cpp3
3 files changed, 26 insertions, 4 deletions
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp
index 3efb72e919..6cc0fee4d9 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -233,6 +233,7 @@ DEF_TEST(Image_Serialize_Encoding_Failure, reporter) {
canvas->drawImage(image, 0, 0);
sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
REPORTER_ASSERT(reporter, picture);
+ REPORTER_ASSERT(reporter, picture->approximateOpCount() > 0);
bool was_called = false;
SkSerialProcs procs;
@@ -249,6 +250,7 @@ DEF_TEST(Image_Serialize_Encoding_Failure, reporter) {
auto deserialized = SkPicture::MakeFromData(data->data(), data->size());
REPORTER_ASSERT(reporter, deserialized);
+ REPORTER_ASSERT(reporter, deserialized->approximateOpCount() > 0);
}
// Test that a draw that only partially covers the drawing surface isn't
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp
index 4eeec35497..714338f9d1 100644
--- a/tests/PictureTest.cpp
+++ b/tests/PictureTest.cpp
@@ -19,7 +19,7 @@
#include "SkMD5.h"
#include "SkMiniRecorder.h"
#include "SkPaint.h"
-#include "SkPicturePriv.h"
+#include "SkPicture.h"
#include "SkPictureRecorder.h"
#include "SkPixelRef.h"
#include "SkRectPriv.h"
@@ -446,7 +446,7 @@ static void test_cull_rect_reset(skiatest::Reporter* reporter) {
canvas->drawRect(bounds, paint);
canvas->drawRect(bounds, paint);
sk_sp<SkPicture> p(recorder.finishRecordingAsPictureWithCull(bounds));
- const SkBigPicture* picture = SkPicturePriv::AsBigPicture(p.get());
+ const SkBigPicture* picture = p->asSkBigPicture();
REPORTER_ASSERT(reporter, picture);
SkRect finalCullRect = picture->cullRect();
@@ -813,3 +813,24 @@ DEF_TEST(Picture_UpdatedCull_2, r) {
REPORTER_ASSERT(r, pic->cullRect() == SkRectPriv::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/SerializationTest.cpp b/tests/SerializationTest.cpp
index b9c8a378ff..2543870667 100644
--- a/tests/SerializationTest.cpp
+++ b/tests/SerializationTest.cpp
@@ -17,7 +17,6 @@
#include "SkMatrixPriv.h"
#include "SkOSFile.h"
#include "SkReadBuffer.h"
-#include "SkPicturePriv.h"
#include "SkPictureRecorder.h"
#include "SkShaderBase.h"
#include "SkTableColorFilter.h"
@@ -543,7 +542,7 @@ DEF_TEST(Serialization, reporter) {
// Serialize picture
SkBinaryWriteBuffer writer;
- SkPicturePriv::Flatten(writer, pict.get());
+ pict->flatten(writer);
size_t size = writer.bytesWritten();
SkAutoTMalloc<unsigned char> data(size);
writer.writeToMemory(static_cast<void*>(data.get()));