Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Unified Diff: src/core/SkPictureRecorder.cpp

Issue 1913843002: Enable flattening of SkRecordedDrawable (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix backward compatibility Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkPictureRecord.cpp ('k') | src/core/SkRecordedDrawable.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPictureRecorder.cpp
diff --git a/src/core/SkPictureRecorder.cpp b/src/core/SkPictureRecorder.cpp
index b6bb34d5b451d3ef87d7d169fff71d36f1ac0789..a157d0dfe0a5bd76b4159a853498d6f560e3e9ea 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();
« no previous file with comments | « src/core/SkPictureRecord.cpp ('k') | src/core/SkRecordedDrawable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698