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 20 matching lines...) Expand all Loading... |
31 * stream dictionary. The stream may be retained (stream->ref() may be | 31 * stream dictionary. The stream may be retained (stream->ref() may be |
32 * called) so its contents must not be changed after calling this. | 32 * called) so its contents must not be changed after calling this. |
33 * @param data The data part of the stream. | 33 * @param data The data part of the stream. |
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 | 38 |
39 virtual ~SkPDFStream(); | 39 virtual ~SkPDFStream(); |
40 | 40 |
41 // The SkPDFObject interface. | 41 // The SkPDFObject interface. These two methods use a mutex to |
| 42 // allow multiple threads to call at the same time. |
42 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog, | 43 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog, |
43 bool indirect); | 44 bool indirect); |
44 virtual size_t getOutputSize(SkPDFCatalog* catalog, bool indirect); | 45 virtual size_t getOutputSize(SkPDFCatalog* catalog, bool indirect); |
45 | 46 |
46 protected: | 47 protected: |
47 enum State { | 48 enum State { |
48 kUnused_State, //!< The stream hasn't been requested yet. | 49 kUnused_State, //!< The stream hasn't been requested yet. |
49 kNoCompression_State, //!< The stream's been requested in an | 50 kNoCompression_State, //!< The stream's been requested in an |
50 // uncompressed form. | 51 // uncompressed form. |
51 kCompressed_State, //!< The stream's already been compressed. | 52 kCompressed_State, //!< The stream's already been compressed. |
(...skipping 10 matching lines...) Expand all Loading... |
62 SkPDFStream(); | 63 SkPDFStream(); |
63 | 64 |
64 // Populate the stream dictionary. This method returns false if | 65 // Populate the stream dictionary. This method returns false if |
65 // fSubstitute should be used. | 66 // fSubstitute should be used. |
66 virtual bool populate(SkPDFCatalog* catalog); | 67 virtual bool populate(SkPDFCatalog* catalog); |
67 | 68 |
68 void setSubstitute(SkPDFStream* stream) { | 69 void setSubstitute(SkPDFStream* stream) { |
69 fSubstitute.reset(stream); | 70 fSubstitute.reset(stream); |
70 } | 71 } |
71 | 72 |
72 SkPDFStream* getSubstitute() { | 73 SkPDFStream* getSubstitute() const { |
73 return fSubstitute.get(); | 74 return fSubstitute.get(); |
74 } | 75 } |
75 | 76 |
76 void setData(SkData* data); | 77 void setData(SkData* data); |
77 void setData(SkStream* stream); | 78 void setData(SkStream* stream); |
78 | 79 |
79 SkStream* getData() { | 80 size_t dataSize() const; |
80 return fData.get(); | 81 |
81 } | 82 SkData* getData() const { return fData.get(); } |
82 | 83 |
83 void setState(State state) { | 84 void setState(State state) { |
84 fState = state; | 85 fState = state; |
85 } | 86 } |
86 | 87 |
87 State getState() { | 88 State getState() const { |
88 return fState; | 89 return fState; |
89 } | 90 } |
90 | 91 |
91 private: | 92 private: |
92 // Indicates what form (or if) the stream has been requested. | 93 // Indicates what form (or if) the stream has been requested. |
93 State fState; | 94 State fState; |
94 | 95 |
95 // TODO(vandebo): Use SkData (after removing deprecated constructor). | 96 // Mutex guards fState, fData, and fSubstitute in public interface. |
96 SkAutoTUnref<SkStream> fData; | 97 SkMutex fMutex; |
| 98 |
| 99 SkAutoTUnref<SkData> fData; |
97 SkAutoTUnref<SkPDFStream> fSubstitute; | 100 SkAutoTUnref<SkPDFStream> fSubstitute; |
98 | 101 |
99 typedef SkPDFDict INHERITED; | 102 typedef SkPDFDict INHERITED; |
100 }; | 103 }; |
101 | 104 |
102 #endif | 105 #endif |
OLD | NEW |