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

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

Issue 2190643002: SkPDF: refactor font subset: fewer copies (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-07-27 (Wednesday) 16:22:36 EDT Created 4 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') | tests/PDFPrimitivesTest.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 * Copyright 2010 Google Inc. 2 * Copyright 2010 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 8
9 #ifndef SkPDFStream_DEFINED 9 #ifndef SkPDFStream_DEFINED
10 #define SkPDFStream_DEFINED 10 #define SkPDFStream_DEFINED
11 11
12 #include "SkPDFTypes.h" 12 #include "SkPDFTypes.h"
13 #include "SkStream.h" 13 #include "SkStream.h"
14 14
15 /** \class SkPDFStream 15 /** \class SkPDFStream
16 16
17 A stream object in a PDF. Note, all streams must be indirect objects (via 17 A stream object in a PDF. Note, all streams must be indirect objects (via
18 SkObjRef). 18 SkObjRef).
19 */ 19 */
20 class SkPDFStream : public SkPDFDict { 20 class SkPDFStream : public SkPDFDict {
21 21
22 public: 22 public:
23 /** Create a PDF stream. A Length entry is automatically added to the 23 /** Create a PDF stream. A Length entry is automatically added to the
24 * stream dictionary. 24 * stream dictionary.
25 * @param data The data part of the stream. Will not take ownership. 25 * @param data The data part of the stream. */
26 */ 26 explicit SkPDFStream(sk_sp<SkData> data) {
27 explicit SkPDFStream(SkData* data) { this->setData(data); } 27 this->setData(std::unique_ptr<SkStreamAsset>(
28 new SkMemoryStream(std::move(data))));
29 }
28 30
29 /** Create a PDF stream. A Length entry is automatically added to the 31 /** Create a PDF stream. A Length entry is automatically added to the
30 * stream dictionary. 32 * stream dictionary.
31 * @param stream The data part of the stream. 33 * @param stream The data part of the stream.
32 */ 34 */
33 explicit SkPDFStream(std::unique_ptr<SkStreamAsset> stream) { 35 explicit SkPDFStream(std::unique_ptr<SkStreamAsset> stream) {
34 this->setData(std::move(stream)); 36 this->setData(std::move(stream));
35 } 37 }
36 38
37 virtual ~SkPDFStream(); 39 virtual ~SkPDFStream();
38 40
39 // The SkPDFObject interface. 41 // The SkPDFObject interface.
40 void emitObject(SkWStream* stream, 42 void emitObject(SkWStream* stream,
41 const SkPDFObjNumMap& objNumMap, 43 const SkPDFObjNumMap& objNumMap,
42 const SkPDFSubstituteMap& substitutes) const override; 44 const SkPDFSubstituteMap& substitutes) const override;
43 void drop() override; 45 void drop() override;
44 46
45 protected: 47 protected:
46 /* 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
47 * set the data. 49 * set the data.
48 */ 50 */
49 SkPDFStream() {} 51 SkPDFStream() {}
50 52
51 /** Only call this function once. */ 53 /** Only call this function once. */
52 void setData(std::unique_ptr<SkStreamAsset> stream); 54 void setData(std::unique_ptr<SkStreamAsset> stream);
53 void setData(SkData* data) {
54 this->setData(std::unique_ptr<SkStreamAsset>(new SkMemoryStream(data)));
55 }
56 55
57 private: 56 private:
58 std::unique_ptr<SkStreamAsset> fCompressedData; 57 std::unique_ptr<SkStreamAsset> fCompressedData;
59 58
60 typedef SkPDFDict INHERITED; 59 typedef SkPDFDict INHERITED;
61 }; 60 };
62 61
63 #endif 62 #endif
OLDNEW
« no previous file with comments | « src/pdf/SkPDFGraphicState.cpp ('k') | tests/PDFPrimitivesTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698