| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #ifndef SkPDFStream_DEFINED | 10 #ifndef SkPDFStream_DEFINED |
| 11 #define SkPDFStream_DEFINED | 11 #define SkPDFStream_DEFINED |
| 12 | 12 |
| 13 #include "SkPDFTypes.h" | 13 #include "SkPDFTypes.h" |
| 14 #include "SkRefCnt.h" | 14 #include "SkRefCnt.h" |
| 15 #include "SkStream.h" | 15 #include "SkStream.h" |
| 16 #include "SkTemplates.h" | 16 #include "SkTemplates.h" |
| 17 | 17 |
| 18 class SkPDFCatalog; | 18 class SkPDFObjNumMap; |
| 19 | 19 |
| 20 /** \class SkPDFStream | 20 /** \class SkPDFStream |
| 21 | 21 |
| 22 A stream object in a PDF. Note, all streams must be indirect objects (via | 22 A stream object in a PDF. Note, all streams must be indirect objects (via |
| 23 SkObjRef). | 23 SkObjRef). |
| 24 */ | 24 */ |
| 25 class SkPDFStream : public SkPDFDict { | 25 class SkPDFStream : public SkPDFDict { |
| 26 SK_DECLARE_INST_COUNT(SkPDFStream) | 26 SK_DECLARE_INST_COUNT(SkPDFStream) |
| 27 public: | 27 public: |
| 28 /** Create a PDF stream. A Length entry is automatically added to the | 28 /** Create a PDF stream. A Length entry is automatically added to the |
| 29 * stream dictionary. | 29 * stream dictionary. |
| 30 * @param data The data part of the stream. Will be ref()ed. | 30 * @param data The data part of the stream. Will be ref()ed. |
| 31 */ | 31 */ |
| 32 explicit SkPDFStream(SkData* data); | 32 explicit SkPDFStream(SkData* data); |
| 33 | 33 |
| 34 /** Create a PDF stream. A Length entry is automatically added to the | 34 /** Create a PDF stream. A Length entry is automatically added to the |
| 35 * stream dictionary. | 35 * stream dictionary. |
| 36 * @param stream The data part of the stream. Will be duplicate()d. | 36 * @param stream The data part of the stream. Will be duplicate()d. |
| 37 */ | 37 */ |
| 38 explicit SkPDFStream(SkStream* stream); | 38 explicit SkPDFStream(SkStream* stream); |
| 39 | 39 |
| 40 virtual ~SkPDFStream(); | 40 virtual ~SkPDFStream(); |
| 41 | 41 |
| 42 // The SkPDFObject interface. | 42 // The SkPDFObject interface. |
| 43 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog) override; | 43 virtual void emitObject(SkWStream* stream, |
| 44 const SkPDFObjNumMap& objNumMap, |
| 45 const SkPDFSubstituteMap& substitutes) override; |
| 44 | 46 |
| 45 protected: | 47 protected: |
| 46 enum State { | 48 enum State { |
| 47 kUnused_State, //!< The stream hasn't been requested yet. | 49 kUnused_State, //!< The stream hasn't been requested yet. |
| 48 kNoCompression_State, //!< The stream's been requested in an | 50 kNoCompression_State, //!< The stream's been requested in an |
| 49 // uncompressed form. | 51 // uncompressed form. |
| 50 kCompressed_State, //!< The stream's already been compressed. | 52 kCompressed_State, //!< The stream's already been compressed. |
| 51 }; | 53 }; |
| 52 | 54 |
| 53 /* Create a PDF stream with no data. The setData method must be called to | 55 /* Create a PDF stream with no data. The setData method must be called to |
| 54 * set the data. | 56 * set the data. |
| 55 */ | 57 */ |
| 56 SkPDFStream(); | 58 SkPDFStream(); |
| 57 | 59 |
| 58 // Populate the stream dictionary. This method returns false if | |
| 59 // fSubstitute should be used. | |
| 60 virtual bool populate(SkPDFCatalog* catalog); | |
| 61 | |
| 62 void setData(SkData* data); | 60 void setData(SkData* data); |
| 63 void setData(SkStream* stream); | 61 void setData(SkStream* stream); |
| 64 | 62 |
| 65 size_t dataSize() const; | 63 size_t dataSize() const; |
| 66 | 64 |
| 67 void setState(State state) { | 65 void setState(State state) { |
| 68 fState = state; | 66 fState = state; |
| 69 } | 67 } |
| 70 | 68 |
| 71 private: | 69 private: |
| 72 // Indicates what form (or if) the stream has been requested. | 70 // Indicates what form (or if) the stream has been requested. |
| 73 State fState; | 71 State fState; |
| 74 | 72 |
| 75 SkAutoTDelete<SkStreamRewindable> fDataStream; | 73 SkAutoTDelete<SkStreamRewindable> fDataStream; |
| 76 | 74 |
| 77 typedef SkPDFDict INHERITED; | 75 typedef SkPDFDict INHERITED; |
| 78 }; | 76 }; |
| 79 | 77 |
| 80 #endif | 78 #endif |
| OLD | NEW |