| 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 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 */ | 34 */ |
| 35 explicit SkPDFStream(SkData* data); | 35 explicit SkPDFStream(SkData* data); |
| 36 /** Deprecated constructor. */ | 36 /** Deprecated constructor. */ |
| 37 explicit SkPDFStream(SkStream* stream); | 37 explicit SkPDFStream(SkStream* stream); |
| 38 /** Create a PDF stream with the same content and dictionary entries | 38 /** Create a PDF stream with the same content and dictionary entries |
| 39 * as the passed one. | 39 * as the passed one. |
| 40 */ | 40 */ |
| 41 explicit SkPDFStream(const SkPDFStream& pdfStream); | 41 explicit SkPDFStream(const SkPDFStream& pdfStream); |
| 42 virtual ~SkPDFStream(); | 42 virtual ~SkPDFStream(); |
| 43 | 43 |
| 44 // The SkPDFObject interface. These two methods use a mutex to | 44 // The SkPDFObject interface. |
| 45 // allow multiple threads to call at the same time. | |
| 46 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog, | 45 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog, |
| 47 bool indirect); | 46 bool indirect); |
| 48 virtual size_t getOutputSize(SkPDFCatalog* catalog, bool indirect); | 47 virtual size_t getOutputSize(SkPDFCatalog* catalog, bool indirect); |
| 49 | 48 |
| 50 protected: | 49 protected: |
| 51 enum State { | 50 enum State { |
| 52 kUnused_State, //!< The stream hasn't been requested yet. | 51 kUnused_State, //!< The stream hasn't been requested yet. |
| 53 kNoCompression_State, //!< The stream's been requested in an | 52 kNoCompression_State, //!< The stream's been requested in an |
| 54 // uncompressed form. | 53 // uncompressed form. |
| 55 kCompressed_State, //!< The stream's already been compressed. | 54 kCompressed_State, //!< The stream's already been compressed. |
| 56 }; | 55 }; |
| 57 | 56 |
| 58 /* Create a PDF stream with no data. The setData method must be called to | 57 /* Create a PDF stream with no data. The setData method must be called to |
| 59 * set the data. | 58 * set the data. |
| 60 */ | 59 */ |
| 61 SkPDFStream(); | 60 SkPDFStream(); |
| 62 | 61 |
| 63 // Populate the stream dictionary. This method returns false if | 62 // Populate the stream dictionary. This method returns false if |
| 64 // fSubstitute should be used. | 63 // fSubstitute should be used. |
| 65 virtual bool populate(SkPDFCatalog* catalog); | 64 virtual bool populate(SkPDFCatalog* catalog); |
| 66 | 65 |
| 67 void setSubstitute(SkPDFStream* stream) { | 66 void setSubstitute(SkPDFStream* stream) { |
| 68 fSubstitute.reset(stream); | 67 fSubstitute.reset(stream); |
| 69 } | 68 } |
| 70 | 69 |
| 71 SkPDFStream* getSubstitute() const { | 70 SkPDFStream* getSubstitute() { |
| 72 return fSubstitute.get(); | 71 return fSubstitute.get(); |
| 73 } | 72 } |
| 74 | 73 |
| 75 void setData(SkData* data); | 74 void setData(SkData* data); |
| 76 void setData(SkStream* stream); | 75 void setData(SkStream* stream); |
| 77 | 76 |
| 78 size_t dataSize() const; | 77 SkStream* getData() { |
| 79 | 78 return fData.get(); |
| 80 SkData* getData() const { return fData.get(); } | 79 } |
| 81 | 80 |
| 82 void setState(State state) { | 81 void setState(State state) { |
| 83 fState = state; | 82 fState = state; |
| 84 } | 83 } |
| 85 | 84 |
| 86 State getState() const { | 85 State getState() { |
| 87 return fState; | 86 return fState; |
| 88 } | 87 } |
| 89 | 88 |
| 90 private: | 89 private: |
| 91 // Indicates what form (or if) the stream has been requested. | 90 // Indicates what form (or if) the stream has been requested. |
| 92 State fState; | 91 State fState; |
| 93 | 92 |
| 94 // Mutex guards fState, fData, and fSubstitute in public interface. | 93 // TODO(vandebo): Use SkData (after removing deprecated constructor). |
| 95 SkMutex fMutex; | 94 SkAutoTUnref<SkStream> fData; |
| 96 | |
| 97 SkAutoTUnref<SkData> fData; | |
| 98 SkAutoTUnref<SkPDFStream> fSubstitute; | 95 SkAutoTUnref<SkPDFStream> fSubstitute; |
| 99 | 96 |
| 100 typedef SkPDFDict INHERITED; | 97 typedef SkPDFDict INHERITED; |
| 101 }; | 98 }; |
| 102 | 99 |
| 103 #endif | 100 #endif |
| OLD | NEW |