diff options
author | reed <reed@google.com> | 2014-11-18 11:08:05 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-11-18 11:08:05 -0800 |
commit | 6be2aa9a251bf6022570a03140f956655b3ef1da (patch) | |
tree | 52ccd2b4fd1fde02617f08ee03d30faee917c38f /src/core/SkPicture.cpp | |
parent | ad3a8846f8963e03faa6de647502e1c553161ecb (diff) |
wip for drawables
Idea:
1. in its mutable recording state, keep a table of drawables on the side, and store an index in the record list.
2. In "immediate-mode" draw, just call the clients drawable directly (need access to our private list to turn the stored index into a proc)
3. when we "snap", we replace the list of drawables with a list of (sub) pictures, and then during playback of the snapped picture, we invoke a private drawable which just calls "drawPicture" on the index'd subpicture.
Review URL: https://codereview.chromium.org/727363003
Diffstat (limited to 'src/core/SkPicture.cpp')
-rw-r--r-- | src/core/SkPicture.cpp | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp index e2514c67d6..4c97cb71b9 100644 --- a/src/core/SkPicture.cpp +++ b/src/core/SkPicture.cpp @@ -257,6 +257,21 @@ bool SkPicture::Analysis::suitableForGpuRasterization(const char** reason, /////////////////////////////////////////////////////////////////////////////// +int SkPicture::drawableCount() const { + if (fDrawablePicts.get()) { + return SkToInt(fDrawablePicts->size() / sizeof(SkPicture*)); + } else { + return 0; + } +} + +SkPicture const* const* SkPicture::drawablePicts() const { + if (fDrawablePicts) { + return reinterpret_cast<SkPicture* const*>(fDrawablePicts->data()); + } + return NULL; +} + SkPicture::~SkPicture() { this->callDeletionListeners(); } @@ -294,7 +309,8 @@ void SkPicture::playback(SkCanvas* canvas, SkDrawPictureCallback* callback) cons (void)canvas->getClipBounds(&clipBounds); const bool useBBH = !clipBounds.contains(this->cullRect()); - SkRecordDraw(*fRecord, canvas, useBBH ? fBBH.get() : NULL, callback); + SkRecordDraw(*fRecord, canvas, this->drawablePicts(), this->drawableCount(), + useBBH ? fBBH.get() : NULL, callback); } /////////////////////////////////////////////////////////////////////////////// @@ -444,19 +460,20 @@ void SkPicture::createHeader(SkPictInfo* info) const { } // This for compatibility with serialization code only. This is not cheap. -SkPictureData* SkPicture::Backport(const SkRecord& src, const SkPictInfo& info) { +SkPictureData* SkPicture::Backport(const SkRecord& src, const SkPictInfo& info, + SkPicture const* const drawablePicts[], int drawableCount) { SkPictureRecord rec(SkISize::Make(info.fCullRect.width(), info.fCullRect.height()), 0/*flags*/); rec.beginRecording(); - SkRecordDraw(src, &rec, NULL/*bbh*/, NULL/*callback*/); + SkRecordDraw(src, &rec, drawablePicts, drawableCount, NULL/*bbh*/, NULL/*callback*/); rec.endRecording(); return SkNEW_ARGS(SkPictureData, (rec, info, false/*deep copy ops?*/)); } - void SkPicture::serialize(SkWStream* stream, EncodeBitmap encoder) const { SkPictInfo info; this->createHeader(&info); - SkAutoTDelete<SkPictureData> data(Backport(*fRecord, info)); + SkAutoTDelete<SkPictureData> data(Backport(*fRecord, info, this->drawablePicts(), + this->drawableCount())); stream->write(&info, sizeof(info)); if (data) { @@ -470,7 +487,8 @@ void SkPicture::serialize(SkWStream* stream, EncodeBitmap encoder) const { void SkPicture::flatten(SkWriteBuffer& buffer) const { SkPictInfo info; this->createHeader(&info); - SkAutoTDelete<SkPictureData> data(Backport(*fRecord, info)); + SkAutoTDelete<SkPictureData> data(Backport(*fRecord, info, this->drawablePicts(), + this->drawableCount())); buffer.writeByteArray(&info.fMagic, sizeof(info.fMagic)); buffer.writeUInt(info.fVersion); @@ -512,11 +530,13 @@ uint32_t SkPicture::uniqueID() const { return fUniqueID; } -SkPicture::SkPicture(SkScalar width, SkScalar height, SkRecord* record, SkBBoxHierarchy* bbh) +SkPicture::SkPicture(SkScalar width, SkScalar height, SkRecord* record, SkData* drawablePicts, + SkBBoxHierarchy* bbh) : fCullWidth(width) , fCullHeight(height) , fRecord(record) , fBBH(SkSafeRef(bbh)) + , fDrawablePicts(SkSafeRef(drawablePicts)) , fAnalysis(*fRecord) { this->needsNewGenID(); } |