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

Unified Diff: src/core/SkPicture.cpp

Issue 2341693004: add helpers for using SkData with picture serialization (Closed)
Patch Set: update sampleview Created 4 years, 3 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 | « samplecode/GMSampleView.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPicture.cpp
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp
index 5d6986631b5ae894542fad6afd3b7aff0d492b82..5409eb34651947441c7353c82e3bfab26b4047b4 100644
--- a/src/core/SkPicture.cpp
+++ b/src/core/SkPicture.cpp
@@ -176,6 +176,20 @@ sk_sp<SkPicture> SkPicture::MakeFromStream(SkStream* stream) {
return MakeFromStream(stream, &factory);
}
+sk_sp<SkPicture> SkPicture::MakeFromData(const void* data, size_t size,
+ SkImageDeserializer* factory) {
+ SkMemoryStream stream(data, size);
+ return MakeFromStream(&stream, factory, nullptr);
+}
+
+sk_sp<SkPicture> SkPicture::MakeFromData(const SkData* data, SkImageDeserializer* factory) {
+ if (!data) {
+ return nullptr;
+ }
+ SkMemoryStream stream(data->data(), data->size());
+ return MakeFromStream(&stream, factory, nullptr);
+}
+
sk_sp<SkPicture> SkPicture::MakeFromStream(SkStream* stream, SkImageDeserializer* factory,
SkTypefacePlayback* typefaces) {
SkPictInfo info;
@@ -209,6 +223,12 @@ void SkPicture::serialize(SkWStream* stream, SkPixelSerializer* pixelSerializer)
this->serialize(stream, pixelSerializer, nullptr);
}
+sk_sp<SkData> SkPicture::serialize(SkPixelSerializer* pixelSerializer) const {
+ SkDynamicMemoryWStream stream;
+ this->serialize(&stream, pixelSerializer, nullptr);
+ return stream.detachAsData();
+}
+
void SkPicture::serialize(SkWStream* stream,
SkPixelSerializer* pixelSerializer,
SkRefCntSet* typefaceSet) const {
« no previous file with comments | « samplecode/GMSampleView.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698