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

Unified Diff: src/core/SkPictureRecorder.cpp

Issue 1913843002: Enable flattening of SkRecordedDrawable (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Consider registering SkRecordedDrawable without the global registry 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
Index: src/core/SkPictureRecorder.cpp
diff --git a/src/core/SkPictureRecorder.cpp b/src/core/SkPictureRecorder.cpp
index b6bb34d5b451d3ef87d7d169fff71d36f1ac0789..1ea912f9157218c18eb19a68b9717bce60b36139 100644
--- a/src/core/SkPictureRecorder.cpp
+++ b/src/core/SkPictureRecorder.cpp
@@ -9,6 +9,8 @@
#include "SkData.h"
#include "SkDrawable.h"
#include "SkLayerInfo.h"
+#include "SkPictureData.h"
+#include "SkPictureRecord.h"
#include "SkPictureRecorder.h"
#include "SkPictureUtils.h"
#include "SkRecord.h"
@@ -16,6 +18,7 @@
#include "SkRecordOpts.h"
#include "SkRecorder.h"
#include "SkTypes.h"
+#include "SkWriteBuffer.h"
SkPictureRecorder::SkPictureRecorder() {
fActivelyRecording = false;
@@ -175,6 +178,39 @@ protected:
return new SkBigPicture(fBounds, SkRef(fRecord.get()), pictList, SkSafeRef(fBBH.get()),
saveLayerData.release(), subPictureBytes);
}
+
+ void flatten(SkWriteBuffer& buffer) const {
+ // Write the bounds.
+ buffer.writeRect(fBounds);
+
+ // Create an SkPictureRecord to record the draw commands.
+ SkPictInfo info;
+ SkPictureRecord pictureRecord(SkISize::Make(fBounds.width(), fBounds.height()), 0);
+
+ // If the query contains the whole picture, don't bother with the bounding box hierarchy.
+ SkRect clipBounds;
+ pictureRecord.getClipBounds(&clipBounds);
+ SkBBoxHierarchy* bbh;
+ if (clipBounds.contains(fBounds)) {
+ bbh = nullptr;
+ } else {
+ bbh = fBBH.get();
+ }
+
+ // Record the draw commands.
+ pictureRecord.beginRecording();
+ SkRecordDraw(*fRecord, &pictureRecord, nullptr, fDrawableList->begin(),
+ fDrawableList->count(), bbh, nullptr);
+ pictureRecord.endRecording();
+
+ // Flatten the recorded commands and drawables.
+ SkPictureData pictureData(pictureRecord, info, false);
+ pictureData.flatten(buffer);
+ }
+
+ const char* getTypeName() const override {
+ return "SkRecordedDrawable";
+ }
};
sk_sp<SkDrawable> SkPictureRecorder::finishRecordingAsDrawable() {
« no previous file with comments | « src/core/SkPictureRecord.cpp ('k') | src/core/SkReadBuffer.h » ('j') | src/core/SkReadBuffer.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698