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

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

Issue 1304493002: SkPDF: Simplify PDFStream / emitObject() const (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: formatting Created 5 years, 4 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
« no previous file with comments | « src/pdf/SkPDFGraphicState.cpp ('k') | src/pdf/SkPDFStream.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
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 SkPDFObjNumMap; 18 class SkPDFObjNumMap;
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 */ 24 */
25 class SkPDFStream : public SkPDFDict { 25 class SkPDFStream : public SkPDFDict {
26 26
27 public: 27 public:
28 /** 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
29 * stream dictionary. 29 * stream dictionary.
30 * @param data The data part of the stream. Will be ref()ed. 30 * @param data The data part of the stream. Will not take ownership.
31 */ 31 */
32 explicit SkPDFStream(SkData* data); 32 explicit SkPDFStream(SkData* data) { this->setData(data); }
33 33
34 /** Create a PDF stream. A Length entry is automatically added to the 34 /** Create a PDF stream. A Length entry is automatically added to the
35 * stream dictionary. 35 * stream dictionary.
36 * @param stream The data part of the stream. Will be duplicate()d. 36 * @param stream The data part of the stream. Will not take ownership.
37 */ 37 */
38 explicit SkPDFStream(SkStream* stream); 38 explicit SkPDFStream(SkStream* stream) { this->setData(stream); }
39 39
40 virtual ~SkPDFStream(); 40 virtual ~SkPDFStream();
41 41
42 // The SkPDFObject interface. 42 // The SkPDFObject interface.
43 void emitObject(SkWStream* stream, 43 void emitObject(SkWStream* stream,
44 const SkPDFObjNumMap& objNumMap, 44 const SkPDFObjNumMap& objNumMap,
45 const SkPDFSubstituteMap& substitutes) override; 45 const SkPDFSubstituteMap& substitutes) const override;
46 46
47 protected: 47 protected:
48 enum State {
49 kUnused_State, //!< The stream hasn't been requested yet.
50 kNoCompression_State, //!< The stream's been requested in an
51 // uncompressed form.
52 kCompressed_State, //!< The stream's already been compressed.
53 };
54
55 /* Create a PDF stream with no data. The setData method must be called to 48 /* Create a PDF stream with no data. The setData method must be called to
56 * set the data. 49 * set the data.
57 */ 50 */
58 SkPDFStream(); 51 SkPDFStream() {}
59 52
60 void setData(SkData* data); 53 /** Only call this function once. */
61 void setData(SkStream* stream); 54 void setData(SkStream* stream);
62 55 void setData(SkData* data) {
63 size_t dataSize() const; 56 SkMemoryStream memoryStream(data);
64 57 this->setData(&memoryStream);
65 void setState(State state) {
66 fState = state;
67 } 58 }
68 59
69 private: 60 private:
70 // Indicates what form (or if) the stream has been requested. 61 SkAutoTDelete<SkStreamRewindable> fCompressedData;
71 State fState;
72
73 SkAutoTDelete<SkStreamRewindable> fDataStream;
74 62
75 typedef SkPDFDict INHERITED; 63 typedef SkPDFDict INHERITED;
76 }; 64 };
77 65
78 #endif 66 #endif
OLDNEW
« no previous file with comments | « src/pdf/SkPDFGraphicState.cpp ('k') | src/pdf/SkPDFStream.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698