diff options
author | mtklein <mtklein@google.com> | 2016-04-27 09:29:34 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-27 09:29:34 -0700 |
commit | 569b02151f399628b0c0c0ca825dfe7b6e2795e1 (patch) | |
tree | 8c10668cf5feee18fbe7fa3e691449753fe875f0 /src/core/SkPictureRecorder.cpp | |
parent | d636950e8ecba89c0021ce4e76037c67aa6ee2cd (diff) |
Revert of Enable flattening of SkRecordedDrawable (patchset #8 id:140001 of https://codereview.chromium.org/1913843002/ )
Reason for revert:
Release mode bots appear to be crashing while loading .skp files in nanobench.
Original issue's description:
> Enable flattening of SkRecordedDrawable
>
> BUG=skia:
> GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1913843002
>
> Committed: https://skia.googlesource.com/skia/+/d636950e8ecba89c0021ce4e76037c67aa6ee2cd
TBR=djsollen@google.com,reed@google.com,msarett@google.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Review-Url: https://codereview.chromium.org/1923393002
Diffstat (limited to 'src/core/SkPictureRecorder.cpp')
-rw-r--r-- | src/core/SkPictureRecorder.cpp | 61 |
1 files changed, 60 insertions, 1 deletions
diff --git a/src/core/SkPictureRecorder.cpp b/src/core/SkPictureRecorder.cpp index a157d0dfe0..b6bb34d5b4 100644 --- a/src/core/SkPictureRecorder.cpp +++ b/src/core/SkPictureRecorder.cpp @@ -14,7 +14,6 @@ #include "SkRecord.h" #include "SkRecordDraw.h" #include "SkRecordOpts.h" -#include "SkRecordedDrawable.h" #include "SkRecorder.h" #include "SkTypes.h" @@ -118,6 +117,66 @@ void SkPictureRecorder::partialReplay(SkCanvas* canvas) const { SkRecordDraw(*fRecord, canvas, nullptr, drawables, drawableCount, nullptr/*bbh*/, nullptr/*callback*/); } +/////////////////////////////////////////////////////////////////////////////////////////////////// + +class SkRecordedDrawable : public SkDrawable { + SkAutoTUnref<SkRecord> fRecord; + SkAutoTUnref<SkBBoxHierarchy> fBBH; + SkAutoTDelete<SkDrawableList> fDrawableList; + const SkRect fBounds; + const bool fDoSaveLayerInfo; + +public: + SkRecordedDrawable(SkRecord* record, SkBBoxHierarchy* bbh, SkDrawableList* drawableList, + const SkRect& bounds, bool doSaveLayerInfo) + : fRecord(SkRef(record)) + , fBBH(SkSafeRef(bbh)) + , fDrawableList(drawableList) // we take ownership + , fBounds(bounds) + , fDoSaveLayerInfo(doSaveLayerInfo) + {} + +protected: + SkRect onGetBounds() override { return fBounds; } + + void onDraw(SkCanvas* canvas) override { + SkDrawable* const* drawables = nullptr; + int drawableCount = 0; + if (fDrawableList) { + drawables = fDrawableList->begin(); + drawableCount = fDrawableList->count(); + } + SkRecordDraw(*fRecord, canvas, nullptr, drawables, drawableCount, fBBH, nullptr/*callback*/); + } + + SkPicture* onNewPictureSnapshot() override { + SkBigPicture::SnapshotArray* pictList = nullptr; + if (fDrawableList) { + // TODO: should we plumb-down the BBHFactory and recordFlags from our host + // PictureRecorder? + pictList = fDrawableList->newDrawableSnapshot(); + } + + SkAutoTUnref<SkLayerInfo> saveLayerData; + if (fBBH && fDoSaveLayerInfo) { + // TODO: can we avoid work by not allocating / filling these bounds? + SkAutoTMalloc<SkRect> scratchBounds(fRecord->count()); + saveLayerData.reset(new SkLayerInfo); + + SkRecordComputeLayers(fBounds, *fRecord, scratchBounds, pictList, saveLayerData); + } + + size_t subPictureBytes = 0; + for (int i = 0; pictList && i < pictList->count(); i++) { + subPictureBytes += SkPictureUtils::ApproximateBytesUsed(pictList->begin()[i]); + } + // SkBigPicture will take ownership of a ref on both fRecord and fBBH. + // We're not willing to give up our ownership, so we must ref them for SkPicture. + return new SkBigPicture(fBounds, SkRef(fRecord.get()), pictList, SkSafeRef(fBBH.get()), + saveLayerData.release(), subPictureBytes); + } +}; + sk_sp<SkDrawable> SkPictureRecorder::finishRecordingAsDrawable() { fActivelyRecording = false; fRecorder->flushMiniRecorder(); |