aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkPictureRecorder.cpp
diff options
context:
space:
mode:
authorGravatar msarett <msarett@google.com>2016-04-27 13:51:20 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-27 13:51:20 -0700
commit95416f477d2ca264f2fb065455e95778a2289a1d (patch)
tree41aa18dccbe6e45d771abb4256b850c1ffb09bdd /src/core/SkPictureRecorder.cpp
parent80f5ea02cf69096e00b8fe01fe54375a9387c9d9 (diff)
Enable flattening of SkRecordedDrawable
Diffstat (limited to 'src/core/SkPictureRecorder.cpp')
-rw-r--r--src/core/SkPictureRecorder.cpp61
1 files changed, 1 insertions, 60 deletions
diff --git a/src/core/SkPictureRecorder.cpp b/src/core/SkPictureRecorder.cpp
index b6bb34d5b4..a157d0dfe0 100644
--- a/src/core/SkPictureRecorder.cpp
+++ b/src/core/SkPictureRecorder.cpp
@@ -14,6 +14,7 @@
#include "SkRecord.h"
#include "SkRecordDraw.h"
#include "SkRecordOpts.h"
+#include "SkRecordedDrawable.h"
#include "SkRecorder.h"
#include "SkTypes.h"
@@ -117,66 +118,6 @@ 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();