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

Unified Diff: src/core/SkPictureRecord.cpp

Issue 1837913003: Add support for serializing/deserializing of SkDrawable (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase 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.h ('k') | src/core/SkPictureRecorder.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPictureRecord.cpp
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp
index afde01bbfb00907d12c1eb9edb665f5ebbc42ca9..4a6ece17f25a8ce864601ffd706cdf2ebb4aa42a 100644
--- a/src/core/SkPictureRecord.cpp
+++ b/src/core/SkPictureRecord.cpp
@@ -33,6 +33,7 @@ SkPictureRecord::SkPictureRecord(const SkISize& dimensions, uint32_t flags)
SkPictureRecord::~SkPictureRecord() {
fImageRefs.unrefAll();
fPictureRefs.unrefAll();
+ fDrawableRefs.unrefAll();
fTextBlobRefs.unrefAll();
}
@@ -637,6 +638,23 @@ void SkPictureRecord::onDrawPicture(const SkPicture* picture, const SkMatrix* ma
this->validate(initialOffset, size);
}
+void SkPictureRecord::onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) {
+ // op + drawable index
+ size_t size = 2 * kUInt32Size;
+ size_t initialOffset;
+
+ if (nullptr == matrix) {
+ initialOffset = this->addDraw(DRAW_DRAWABLE, &size);
+ this->addDrawable(drawable);
+ } else {
+ size += matrix->writeToMemory(nullptr); // matrix
+ initialOffset = this->addDraw(DRAW_DRAWABLE_MATRIX, &size);
+ this->addMatrix(*matrix);
+ this->addDrawable(drawable);
+ }
+ this->validate(initialOffset, size);
+}
+
void SkPictureRecord::onDrawVertices(VertexMode vmode, int vertexCount,
const SkPoint vertices[], const SkPoint texs[],
const SkColor colors[], SkXfermode* xfer,
@@ -918,6 +936,17 @@ void SkPictureRecord::addPicture(const SkPicture* picture) {
this->addInt(index + 1);
}
+void SkPictureRecord::addDrawable(SkDrawable* drawable) {
+ int index = fDrawableRefs.find(drawable);
+ if (index < 0) { // not found
+ index = fDrawableRefs.count();
+ *fDrawableRefs.append() = drawable;
+ drawable->ref();
+ }
+ // follow the convention of recording a 1-based index
+ this->addInt(index + 1);
+}
+
void SkPictureRecord::addPoint(const SkPoint& point) {
fWriter.writePoint(point);
}
« no previous file with comments | « src/core/SkPictureRecord.h ('k') | src/core/SkPictureRecorder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698