| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 | 8 |
| 9 #ifndef SkPDFStream_DEFINED | 9 #ifndef SkPDFStream_DEFINED |
| 10 #define SkPDFStream_DEFINED | 10 #define SkPDFStream_DEFINED |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 public: | 22 public: |
| 23 /** Create a PDF stream. A Length entry is automatically added to the | 23 /** Create a PDF stream. A Length entry is automatically added to the |
| 24 * stream dictionary. | 24 * stream dictionary. |
| 25 * @param data The data part of the stream. Will not take ownership. | 25 * @param data The data part of the stream. Will not take ownership. |
| 26 */ | 26 */ |
| 27 explicit SkPDFStream(SkData* data) { this->setData(data); } | 27 explicit SkPDFStream(SkData* data) { this->setData(data); } |
| 28 | 28 |
| 29 /** Create a PDF stream. A Length entry is automatically added to the | 29 /** Create a PDF stream. A Length entry is automatically added to the |
| 30 * stream dictionary. | 30 * stream dictionary. |
| 31 * @param stream The data part of the stream. Will not take ownership. | 31 * @param stream The data part of the stream. |
| 32 */ | 32 */ |
| 33 explicit SkPDFStream(SkStreamAsset* stream) { this->setData(stream); } | 33 explicit SkPDFStream(std::unique_ptr<SkStreamAsset> stream) { |
| 34 this->setData(std::move(stream)); |
| 35 } |
| 34 | 36 |
| 35 virtual ~SkPDFStream(); | 37 virtual ~SkPDFStream(); |
| 36 | 38 |
| 37 // The SkPDFObject interface. | 39 // The SkPDFObject interface. |
| 38 void emitObject(SkWStream* stream, | 40 void emitObject(SkWStream* stream, |
| 39 const SkPDFObjNumMap& objNumMap, | 41 const SkPDFObjNumMap& objNumMap, |
| 40 const SkPDFSubstituteMap& substitutes) const override; | 42 const SkPDFSubstituteMap& substitutes) const override; |
| 41 void drop() override; | 43 void drop() override; |
| 42 | 44 |
| 43 protected: | 45 protected: |
| 44 /* Create a PDF stream with no data. The setData method must be called to | 46 /* Create a PDF stream with no data. The setData method must be called to |
| 45 * set the data. | 47 * set the data. |
| 46 */ | 48 */ |
| 47 SkPDFStream() {} | 49 SkPDFStream() {} |
| 48 | 50 |
| 49 /** Only call this function once. */ | 51 /** Only call this function once. */ |
| 50 void setData(SkStreamAsset* stream); | 52 void setData(std::unique_ptr<SkStreamAsset> stream); |
| 51 void setData(SkData* data) { | 53 void setData(SkData* data) { |
| 52 SkMemoryStream memoryStream(data); | 54 this->setData(std::unique_ptr<SkStreamAsset>(new SkMemoryStream(data))); |
| 53 this->setData(&memoryStream); | |
| 54 } | 55 } |
| 55 | 56 |
| 56 private: | 57 private: |
| 57 std::unique_ptr<SkStreamAsset> fCompressedData; | 58 std::unique_ptr<SkStreamAsset> fCompressedData; |
| 58 | 59 |
| 59 typedef SkPDFDict INHERITED; | 60 typedef SkPDFDict INHERITED; |
| 60 }; | 61 }; |
| 61 | 62 |
| 62 #endif | 63 #endif |
| OLD | NEW |