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