Chromium Code Reviews| 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 stream The data part of the stream. Will be duplicate()d. |
|
bungeman-skia
2014/07/11 21:43:38
This seems to want to go with the constructor belo
hal.canary
2014/07/12 00:58:49
Done.
| |
| 33 * @param data The data part of the stream. | 31 * @param data The data part of the stream. Will be ref()ed. |
| 34 */ | 32 */ |
| 35 explicit SkPDFStream(SkData* data); | 33 explicit SkPDFStream(SkData* data); |
| 36 /** Deprecated constructor. */ | |
| 37 explicit SkPDFStream(SkStream* stream); | 34 explicit SkPDFStream(SkStream* stream); |
| 38 | 35 |
| 39 virtual ~SkPDFStream(); | 36 virtual ~SkPDFStream(); |
| 40 | 37 |
| 41 // The SkPDFObject interface. These two methods use a mutex to | 38 // The SkPDFObject interface. These two methods use a mutex to |
| 42 // allow multiple threads to call at the same time. | 39 // allow multiple threads to call at the same time. |
| 43 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog, | 40 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog, |
| 44 bool indirect); | 41 bool indirect); |
| 45 virtual size_t getOutputSize(SkPDFCatalog* catalog, bool indirect); | 42 virtual size_t getOutputSize(SkPDFCatalog* catalog, bool indirect); |
| 46 | 43 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 72 | 69 |
| 73 SkPDFStream* getSubstitute() const { | 70 SkPDFStream* getSubstitute() const { |
| 74 return fSubstitute.get(); | 71 return fSubstitute.get(); |
| 75 } | 72 } |
| 76 | 73 |
| 77 void setData(SkData* data); | 74 void setData(SkData* data); |
| 78 void setData(SkStream* stream); | 75 void setData(SkStream* stream); |
| 79 | 76 |
| 80 size_t dataSize() const; | 77 size_t dataSize() const; |
| 81 | 78 |
| 82 SkData* getData() const { return fData.get(); } | |
| 83 | |
| 84 void setState(State state) { | 79 void setState(State state) { |
| 85 fState = state; | 80 fState = state; |
| 86 } | 81 } |
| 87 | 82 |
| 88 State getState() const { | 83 State getState() const { |
| 89 return fState; | 84 return fState; |
| 90 } | 85 } |
| 91 | 86 |
| 92 private: | 87 private: |
| 93 // Indicates what form (or if) the stream has been requested. | 88 // Indicates what form (or if) the stream has been requested. |
| 94 State fState; | 89 State fState; |
| 95 | 90 |
| 96 // Mutex guards fState, fData, and fSubstitute in public interface. | 91 // Mutex guards fState, fDataStream, and fSubstitute in public interface. |
| 97 SkMutex fMutex; | 92 SkMutex fMutex; |
| 98 | 93 |
| 99 SkAutoTUnref<SkData> fData; | 94 SkMemoryStream fMemoryStream; // Used by fDataStream when |
| 95 // fDataStream needs to be backed | |
| 96 // by SkData. | |
| 97 SkAutoTUnref<SkStreamRewindable> fDataStream; | |
| 100 SkAutoTUnref<SkPDFStream> fSubstitute; | 98 SkAutoTUnref<SkPDFStream> fSubstitute; |
| 101 | 99 |
| 102 typedef SkPDFDict INHERITED; | 100 typedef SkPDFDict INHERITED; |
| 103 }; | 101 }; |
| 104 | 102 |
| 105 #endif | 103 #endif |
| OLD | NEW |