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

Unified Diff: include/core/SkStream.h

Issue 2333713002: change SkStreams to work with sk_sp<SkData> instead of SkData* (Closed)
Patch Set: fix xpsdevice 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 | « include/codec/SkCodec.h ('k') | public.bzl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkStream.h
diff --git a/include/core/SkStream.h b/include/core/SkStream.h
index 4bfaeda58793d7b25aa58319a52c8cc92503a14e..48ac577070b289a7ef31016b68c302fd32a5f6e8 100644
--- a/include/core/SkStream.h
+++ b/include/core/SkStream.h
@@ -291,11 +291,13 @@ public:
/** If copyData is true, the stream makes a private copy of the data. */
SkMemoryStream(const void* data, size_t length, bool copyData = false);
+#ifdef SK_SUPPORT_LEGACY_STREAM_DATA
/** Use the specified data as the memory for this stream.
* The stream will call ref() on the data (assuming it is not NULL).
* DEPRECATED
*/
SkMemoryStream(SkData*);
+#endif
/** Creates the stream to read from the specified data */
SkMemoryStream(sk_sp<SkData>);
@@ -312,17 +314,24 @@ public:
*/
void setMemoryOwned(const void* data, size_t length);
+ sk_sp<SkData> asData() const { return fData; }
+ void setData(sk_sp<SkData>);
+#ifdef SK_SUPPORT_LEGACY_STREAM_DATA
/** Return the stream's data in a SkData.
* The caller must call unref() when it is finished using the data.
*/
- SkData* copyToData() const;
+ SkData* copyToData() const { return asData().release(); }
/**
* Use the specified data as the memory for this stream.
* The stream will call ref() on the data (assuming it is not NULL).
* The function returns the data parameter as a convenience.
*/
- SkData* setData(SkData*);
+ SkData* setData(SkData* data) {
+ this->setData(sk_ref_sp(data));
+ return data;
+ }
+#endif
void skipToAlign4();
const void* getAtPos();
@@ -404,11 +413,18 @@ public:
void copyTo(void* dst) const;
void writeToStream(SkWStream* dst) const;
+ sk_sp<SkData> snapshotAsData() const;
+ // Return the contents as SkData, and then reset the stream.
+ sk_sp<SkData> detachAsData();
+#ifdef SK_SUPPORT_LEGACY_STREAM_DATA
/**
* Return a copy of the data written so far. This call is responsible for
* calling unref() when they are finished with the data.
*/
- SkData* copyToData() const;
+ SkData* copyToData() const {
+ return snapshotAsData().release();
+ }
+#endif
/** Reset, returning a reader stream with the current content. */
SkStreamAsset* detachAsStream();
« no previous file with comments | « include/codec/SkCodec.h ('k') | public.bzl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698