Chromium Code Reviews| Index: include/core/SkStream.h |
| diff --git a/include/core/SkStream.h b/include/core/SkStream.h |
| index 4bfaeda58793d7b25aa58319a52c8cc92503a14e..553c52fafb1383984c82b5d35521c046fa3606a9 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> makeCopy() const { return fData; } |
|
msarett
2016/09/12 13:32:07
This is somewhat misleading...
reed1
2016/09/12 13:59:51
Done.
|
| + 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 makeCopy()->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> makeCopy() 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 makeCopy()->release(); |
| + } |
| +#endif |
| /** Reset, returning a reader stream with the current content. */ |
| SkStreamAsset* detachAsStream(); |