3 * Copyright 2010 Google Inc.
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
10 #ifndef SkPDFStream_DEFINED
11 #define SkPDFStream_DEFINED
13 #include "SkPDFTypes.h"
16 #include "SkTemplates.h"
20 /** \class SkPDFStream
22 A stream object in a PDF. Note, all streams must be indirect objects (via
25 class SkPDFStream : public SkPDFDict {
26 SK_DECLARE_INST_COUNT(SkPDFStream)
28 /** Create a PDF stream. A Length entry is automatically added to the
30 * @param data The data part of the stream. Will be ref()ed.
32 explicit SkPDFStream(SkData* data);
34 /** Create a PDF stream. A Length entry is automatically added to the
36 * @param stream The data part of the stream. Will be duplicate()d.
38 explicit SkPDFStream(SkStream* stream);
40 virtual ~SkPDFStream();
42 // The SkPDFObject interface.
43 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog) override;
47 kUnused_State, //!< The stream hasn't been requested yet.
48 kNoCompression_State, //!< The stream's been requested in an
50 kCompressed_State, //!< The stream's already been compressed.
53 /** Create a PDF stream with the same content and dictionary entries
56 explicit SkPDFStream(const SkPDFStream& pdfStream);
58 /* Create a PDF stream with no data. The setData method must be called to
63 // Populate the stream dictionary. This method returns false if
64 // fSubstitute should be used.
65 virtual bool populate(SkPDFCatalog* catalog);
67 void setSubstitute(SkPDFStream* stream) {
68 fSubstitute.reset(stream);
71 SkPDFStream* getSubstitute() const {
72 return fSubstitute.get();
75 void setData(SkData* data);
76 void setData(SkStream* stream);
78 size_t dataSize() const;
80 void setState(State state) {
84 State getState() const {
89 // Indicates what form (or if) the stream has been requested.
92 SkAutoTDelete<SkStreamRewindable> fDataStream;
93 SkAutoTUnref<SkPDFStream> fSubstitute;
95 typedef SkPDFDict INHERITED;