aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/SerialProcsTest.cpp
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2017-12-13 15:16:43 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-12-13 15:16:53 +0000
commit2a3009931d7bb0f5ca31490c4cf19eef205e4e7a (patch)
tree0e560343dccf1aef830d0eb24ac35e3790f54f9f /tests/SerialProcsTest.cpp
parent76d917cef19aabfdc1247336f58237800bd71875 (diff)
Revert "impl SkSerial picture procs"
This reverts commit c8226728541fdd6434a7f1b97678246202b0edc5. Reason for revert: broke old skps Original change's description: > impl SkSerial picture procs > > The picture serialization code is a bit of a mess, with duplicated functions for streams and buffers. > Could not see how to fix that and land this at the same time, but I will try to circle back and > simplify if possible afterwards. > > Bug: skia: > Change-Id: I9053fdc476c60f483df013d021e248258181c199 > Reviewed-on: https://skia-review.googlesource.com/83943 > Reviewed-by: Florin Malita <fmalita@chromium.org> > Commit-Queue: Mike Reed <reed@google.com> TBR=mtklein@google.com,fmalita@chromium.org,reed@google.com Change-Id: I68ae019a286691b65cc373cb29c941d6620fd34a No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia: Reviewed-on: https://skia-review.googlesource.com/84460 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'tests/SerialProcsTest.cpp')
-rw-r--r--tests/SerialProcsTest.cpp96
1 files changed, 0 insertions, 96 deletions
diff --git a/tests/SerialProcsTest.cpp b/tests/SerialProcsTest.cpp
index 0d13c035ec..d975abb5db 100644
--- a/tests/SerialProcsTest.cpp
+++ b/tests/SerialProcsTest.cpp
@@ -9,7 +9,6 @@
#include "Resources.h"
#include "sk_tool_utils.h"
#include "SkCanvas.h"
-#include "SkImageSource.h"
#include "SkPicture.h"
#include "SkPictureRecorder.h"
#include "SkSerialProcs.h"
@@ -82,98 +81,3 @@ DEF_TEST(serial_procs_image, reporter) {
}
}
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-static sk_sp<SkPicture> make_pic(const std::function<void(SkCanvas*)>& drawer) {
- SkPictureRecorder rec;
- drawer(rec.beginRecording(128, 128));
- return rec.finishRecordingAsPicture();
-}
-
-static SkSerialProcs makes(SkSerialPictureProc proc, void* ctx = nullptr) {
- SkSerialProcs procs;
- procs.fPictureProc = proc;
- procs.fPictureCtx = ctx;
- return procs;
-}
-
-static SkDeserialProcs maked(SkDeserialPictureProc proc, const void* ctx = nullptr) {
- SkDeserialProcs procs;
- procs.fPictureProc = proc;
- procs.fPictureCtx = const_cast<void*>(ctx);
- return procs;
-}
-
-// packages the picture's point in the skdata, and records it in the ctx as an array
-struct Context {
- SkTDArray<SkPicture*> fArray;
- SkPicture* fSkipMe = nullptr;
-};
-
-static sk_sp<SkData> array_serial_proc(SkPicture* pic, void* ctx) {
- Context* c = (Context*)ctx;
- if (c->fSkipMe == pic) {
- return nullptr;
- }
- *c->fArray.append() = pic;
- return SkData::MakeWithCopy(&pic, sizeof(pic));
-}
-
-static sk_sp<SkPicture> array_deserial_proc(const void* data, size_t size, void* ctx) {
- SkASSERT(sizeof(SkPicture*) == size);
-
- Context* c = (Context*)ctx;
- SkPicture* pic;
- memcpy(&pic, data, size);
-
- int index = c->fArray.find(pic);
- SkASSERT(index >= 0);
- c->fArray.removeShuffle(index);
-
- return sk_ref_sp(pic);
-}
-
-static void test_pictures(skiatest::Reporter* reporter, sk_sp<SkPicture> p0, int count,
- bool skipRoot) {
- Context ctx;
- if (skipRoot) {
- ctx.fSkipMe = p0.get();
- }
-
- auto d0 = p0->serialize(makes(array_serial_proc, &ctx));
- REPORTER_ASSERT(reporter, ctx.fArray.count() == count);
- p0 = SkPicture::MakeFromData(d0.get(), maked(array_deserial_proc, &ctx));
- REPORTER_ASSERT(reporter, ctx.fArray.count() == 0);
-}
-
-DEF_TEST(serial_procs_picture, reporter) {
-
- auto p1 = make_pic([](SkCanvas* c) {
- // need to be large enough that drawPictures doesn't "unroll" us
- for (int i = 0; i < 20; ++i) {
- c->drawColor(SK_ColorRED);
- }
- });
-
- // now use custom serialization
- auto p0 = make_pic([](SkCanvas* c) { c->drawColor(SK_ColorBLUE); });
- test_pictures(reporter, p0, 1, false);
-
- // test inside effect
- p0 = make_pic([p1](SkCanvas* c) {
- SkPaint paint;
- SkShader::TileMode tm = SkShader::kClamp_TileMode;
- paint.setShader(SkShader::MakePictureShader(p1, tm, tm, nullptr, nullptr));
- c->drawPaint(paint);
- });
- test_pictures(reporter, p0, 1, true);
-
- // test nested picture
- p0 = make_pic([p1](SkCanvas* c) {
- c->drawColor(SK_ColorRED);
- c->drawPicture(p1);
- c->drawColor(SK_ColorBLUE);
- });
- test_pictures(reporter, p0, 1, true);
-}
-