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 SkPDFCatalog; |
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 TODO(vandebo): SkStream should be replaced by SkStreamRewindable when that | |
25 is feasible. | |
26 */ | 24 */ |
27 class SkPDFStream : public SkPDFDict { | 25 class SkPDFStream : public SkPDFDict { |
28 SK_DECLARE_INST_COUNT(SkPDFStream) | 26 SK_DECLARE_INST_COUNT(SkPDFStream) |
29 public: | 27 public: |
30 /** 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 |
31 * stream dictionary. The stream may be retained (stream->ref() may be | 29 * stream dictionary. |
32 * called) so its contents must not be changed after calling this. | 30 * @param data The data part of the stream. Will be ref()ed. |
33 * @param data The data part of the stream. | |
34 */ | 31 */ |
35 explicit SkPDFStream(SkData* data); | 32 explicit SkPDFStream(SkData* data); |
36 /** Deprecated constructor. */ | 33 |
| 34 /** Create a PDF stream. A Length entry is automatically added to the |
| 35 * stream dictionary. |
| 36 * @param stream The data part of the stream. Will be duplicate()d. |
| 37 */ |
37 explicit SkPDFStream(SkStream* stream); | 38 explicit SkPDFStream(SkStream* stream); |
38 | 39 |
39 virtual ~SkPDFStream(); | 40 virtual ~SkPDFStream(); |
40 | 41 |
41 // The SkPDFObject interface. These two methods use a mutex to | 42 // The SkPDFObject interface. These two methods use a mutex to |
42 // allow multiple threads to call at the same time. | 43 // allow multiple threads to call at the same time. |
43 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog, | 44 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog, |
44 bool indirect); | 45 bool indirect); |
45 virtual size_t getOutputSize(SkPDFCatalog* catalog, bool indirect); | 46 virtual size_t getOutputSize(SkPDFCatalog* catalog, bool indirect); |
46 | 47 |
(...skipping 25 matching lines...) Expand all Loading... |
72 | 73 |
73 SkPDFStream* getSubstitute() const { | 74 SkPDFStream* getSubstitute() const { |
74 return fSubstitute.get(); | 75 return fSubstitute.get(); |
75 } | 76 } |
76 | 77 |
77 void setData(SkData* data); | 78 void setData(SkData* data); |
78 void setData(SkStream* stream); | 79 void setData(SkStream* stream); |
79 | 80 |
80 size_t dataSize() const; | 81 size_t dataSize() const; |
81 | 82 |
82 SkData* getData() const { return fData.get(); } | |
83 | |
84 void setState(State state) { | 83 void setState(State state) { |
85 fState = state; | 84 fState = state; |
86 } | 85 } |
87 | 86 |
88 State getState() const { | 87 State getState() const { |
89 return fState; | 88 return fState; |
90 } | 89 } |
91 | 90 |
92 private: | 91 private: |
93 // Indicates what form (or if) the stream has been requested. | 92 // Indicates what form (or if) the stream has been requested. |
94 State fState; | 93 State fState; |
95 | 94 |
96 // Mutex guards fState, fData, and fSubstitute in public interface. | 95 // Mutex guards fState, fDataStream, and fSubstitute in public interface. |
97 SkMutex fMutex; | 96 SkMutex fMutex; |
98 | 97 |
99 SkAutoTUnref<SkData> fData; | 98 SkMemoryStream fMemoryStream; // Used by fDataStream when |
| 99 // fDataStream needs to be backed |
| 100 // by SkData. |
| 101 SkAutoTUnref<SkStreamRewindable> fDataStream; |
100 SkAutoTUnref<SkPDFStream> fSubstitute; | 102 SkAutoTUnref<SkPDFStream> fSubstitute; |
101 | 103 |
102 typedef SkPDFDict INHERITED; | 104 typedef SkPDFDict INHERITED; |
103 }; | 105 }; |
104 | 106 |
105 #endif | 107 #endif |
OLD | NEW |