diff options
author | Mike Reed <reed@google.com> | 2017-12-20 14:12:07 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-12-21 12:36:30 +0000 |
commit | 47fdf6c85ee8151c14529e5322d63636c36ecdb8 (patch) | |
tree | 34529464c15c50efa305107199189687907ee759 /src/utils | |
parent | e3edf9274485f49d9f335052cb31812743e15634 (diff) |
add serialprocs to MultiDocument, hide redundant methods
Bug: skia:
Change-Id: I6521e93af79439bd8c1d2f5130a68492044a2ee9
Reviewed-on: https://skia-review.googlesource.com/87788
Reviewed-by: Wei Li <weili@chromium.org>
Reviewed-by: Hal Canary <halcanary@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/SkMultiPictureDocument.cpp | 19 | ||||
-rw-r--r-- | src/utils/SkMultiPictureDocument.h | 8 |
2 files changed, 18 insertions, 9 deletions
diff --git a/src/utils/SkMultiPictureDocument.cpp b/src/utils/SkMultiPictureDocument.cpp index 4ff2d079e3..b3e84dc74e 100644 --- a/src/utils/SkMultiPictureDocument.cpp +++ b/src/utils/SkMultiPictureDocument.cpp @@ -10,6 +10,7 @@ #include "SkNWayCanvas.h" #include "SkPicture.h" #include "SkPictureRecorder.h" +#include "SkSerialProcs.h" #include "SkStream.h" #include "SkTArray.h" @@ -45,12 +46,15 @@ static SkSize join(const SkTArray<SkSize>& sizes) { } struct MultiPictureDocument final : public SkDocument { + const SkSerialProcs fProcs; SkPictureRecorder fPictureRecorder; SkSize fCurrentPageSize; SkTArray<sk_sp<SkPicture>> fPages; SkTArray<SkSize> fSizes; - MultiPictureDocument(SkWStream* s, void (*d)(SkWStream*, bool)) - : SkDocument(s, d) {} + MultiPictureDocument(SkWStream* s, void (*d)(SkWStream*, bool), const SkSerialProcs* procs) + : SkDocument(s, d) + , fProcs(procs ? *procs : SkSerialProcs()) + {} ~MultiPictureDocument() override { this->close(); } SkCanvas* onBeginPage(SkScalar w, SkScalar h) override { @@ -77,7 +81,7 @@ struct MultiPictureDocument final : public SkDocument { c->drawAnnotation(SkRect::MakeEmpty(), kEndPage, nullptr); } sk_sp<SkPicture> p = fPictureRecorder.finishRecordingAsPicture(); - p->serialize(wStream); + p->serialize(wStream, &fProcs); fPages.reset(); fSizes.reset(); return; @@ -89,8 +93,8 @@ struct MultiPictureDocument final : public SkDocument { }; } -sk_sp<SkDocument> SkMakeMultiPictureDocument(SkWStream* wStream) { - return sk_make_sp<MultiPictureDocument>(wStream, nullptr); +sk_sp<SkDocument> SkMakeMultiPictureDocument(SkWStream* wStream, const SkSerialProcs* procs) { + return sk_make_sp<MultiPictureDocument>(wStream, nullptr, procs); } //////////////////////////////////////////////////////////////////////////////// @@ -171,7 +175,8 @@ struct PagerCanvas : public SkNWayCanvas { bool SkMultiPictureDocumentRead(SkStreamSeekable* stream, SkDocumentPage* dstArray, - int dstArrayCount) { + int dstArrayCount, + const SkDeserialProcs* procs) { if (!SkMultiPictureDocumentReadPageSizes(stream, dstArray, dstArrayCount)) { return false; } @@ -181,7 +186,7 @@ bool SkMultiPictureDocumentRead(SkStreamSeekable* stream, SkTMax(joined.height(), dstArray[i].fSize.height())}; } - auto picture = SkPicture::MakeFromStream(stream); + auto picture = SkPicture::MakeFromStream(stream, procs); PagerCanvas canvas(joined.toCeil(), dstArray, dstArrayCount); // Must call playback(), not drawPicture() to reach diff --git a/src/utils/SkMultiPictureDocument.h b/src/utils/SkMultiPictureDocument.h index 0ca8c2de72..7d50683572 100644 --- a/src/utils/SkMultiPictureDocument.h +++ b/src/utils/SkMultiPictureDocument.h @@ -4,17 +4,20 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ + #ifndef SkMultiPictureDocument_DEFINED #define SkMultiPictureDocument_DEFINED #include "SkDocument.h" +struct SkDeserialProcs; +struct SkSerialProcs; class SkStreamSeekable; /** * Writes into a file format that is similar to SkPicture::serialize() */ -SK_API sk_sp<SkDocument> SkMakeMultiPictureDocument(SkWStream* dst); +SK_API sk_sp<SkDocument> SkMakeMultiPictureDocument(SkWStream* dst, const SkSerialProcs* = nullptr); struct SkDocumentPage { sk_sp<SkPicture> fPicture; @@ -33,6 +36,7 @@ SK_API int SkMultiPictureDocumentReadPageCount(SkStreamSeekable* src); */ SK_API bool SkMultiPictureDocumentRead(SkStreamSeekable* src, SkDocumentPage* dstArray, - int dstArrayCount); + int dstArrayCount, + const SkDeserialProcs* = nullptr); #endif // SkMultiPictureDocument_DEFINED |