Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(451)

Side by Side Diff: src/pdf/SkPDFStream.h

Issue 340783013: Switch SkPDFStream's internal storage from SkStream to SkData (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: images/SkStreamHelpers -> core/SkStreamPriv Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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. 44 // The SkPDFObject interface. These two methods use a mutex to
45 // allow multiple threads to call at the same time.
45 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog, 46 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog,
46 bool indirect); 47 bool indirect);
47 virtual size_t getOutputSize(SkPDFCatalog* catalog, bool indirect); 48 virtual size_t getOutputSize(SkPDFCatalog* catalog, bool indirect);
48 49
49 protected: 50 protected:
50 enum State { 51 enum State {
51 kUnused_State, //!< The stream hasn't been requested yet. 52 kUnused_State, //!< The stream hasn't been requested yet.
52 kNoCompression_State, //!< The stream's been requested in an 53 kNoCompression_State, //!< The stream's been requested in an
53 // uncompressed form. 54 // uncompressed form.
54 kCompressed_State, //!< The stream's already been compressed. 55 kCompressed_State, //!< The stream's already been compressed.
55 }; 56 };
56 57
57 /* Create a PDF stream with no data. The setData method must be called to 58 /* Create a PDF stream with no data. The setData method must be called to
58 * set the data. 59 * set the data.
59 */ 60 */
60 SkPDFStream(); 61 SkPDFStream();
61 62
62 // Populate the stream dictionary. This method returns false if 63 // Populate the stream dictionary. This method returns false if
63 // fSubstitute should be used. 64 // fSubstitute should be used.
64 virtual bool populate(SkPDFCatalog* catalog); 65 virtual bool populate(SkPDFCatalog* catalog);
65 66
66 void setSubstitute(SkPDFStream* stream) { 67 void setSubstitute(SkPDFStream* stream) {
67 fSubstitute.reset(stream); 68 fSubstitute.reset(stream);
68 } 69 }
69 70
70 SkPDFStream* getSubstitute() { 71 SkPDFStream* getSubstitute() const {
71 return fSubstitute.get(); 72 return fSubstitute.get();
72 } 73 }
73 74
74 void setData(SkData* data); 75 void setData(SkData* data);
75 void setData(SkStream* stream); 76 void setData(SkStream* stream);
76 77
77 SkStream* getData() { 78 size_t dataSize() const;
78 return fData.get(); 79
79 } 80 SkData* getData() const { return fData.get(); }
80 81
81 void setState(State state) { 82 void setState(State state) {
82 fState = state; 83 fState = state;
83 } 84 }
84 85
85 State getState() { 86 State getState() const {
86 return fState; 87 return fState;
87 } 88 }
88 89
89 private: 90 private:
90 // Indicates what form (or if) the stream has been requested. 91 // Indicates what form (or if) the stream has been requested.
91 State fState; 92 State fState;
92 93
93 // TODO(vandebo): Use SkData (after removing deprecated constructor). 94 // Mutex guards fState, fData, and fSubstitute in public interface.
94 SkAutoTUnref<SkStream> fData; 95 SkMutex fMutex;
96
97 SkAutoTUnref<SkData> fData;
95 SkAutoTUnref<SkPDFStream> fSubstitute; 98 SkAutoTUnref<SkPDFStream> fSubstitute;
96 99
97 typedef SkPDFDict INHERITED; 100 typedef SkPDFDict INHERITED;
98 }; 101 };
99 102
100 #endif 103 #endif
OLDNEW
« no previous file with comments | « src/pdf/SkPDFPage.cpp ('k') | src/pdf/SkPDFStream.cpp » ('j') | src/pdf/SkPDFStream.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698