Index: src/pdf/SkPDFTypes.h |
diff --git a/src/pdf/SkPDFTypes.h b/src/pdf/SkPDFTypes.h |
index 5e4de3a2595fd24d2c1b5e88ac86d8200d479d72..6ee9162139158e41d9d411b127ee6dfd5ff463df 100644 |
--- a/src/pdf/SkPDFTypes.h |
+++ b/src/pdf/SkPDFTypes.h |
@@ -14,6 +14,7 @@ |
#include "SkTHash.h" |
#include "SkTypes.h" |
+class SkData; |
class SkPDFObjNumMap; |
class SkPDFObject; |
class SkPDFSubstituteMap; |
@@ -307,10 +308,9 @@ private: |
*/ |
class SkPDFSharedStream final : public SkPDFObject { |
public: |
- // Takes ownership of asset. |
- SkPDFSharedStream(SkStreamAsset* data); |
+ SkPDFSharedStream(std::unique_ptr<SkStreamAsset> data); |
~SkPDFSharedStream(); |
- SkPDFDict* dict() { return fDict.get(); } |
+ SkPDFDict* dict() { return &fDict; } |
void emitObject(SkWStream*, |
const SkPDFObjNumMap&, |
const SkPDFSubstituteMap&) const override; |
@@ -320,11 +320,52 @@ public: |
private: |
std::unique_ptr<SkStreamAsset> fAsset; |
- sk_sp<SkPDFDict> fDict; |
- SkDEBUGCODE(bool fDumped;) |
+ SkPDFDict fDict; |
typedef SkPDFObject INHERITED; |
}; |
+/** \class SkPDFStream |
+ |
+ This class takes an asset and assumes that it is the only owner of |
+ the asset's data. It immediately compresses the asset to save |
+ memory. |
+ */ |
+ |
+class SkPDFStream : public SkPDFObject { |
+ |
+public: |
+ /** Create a PDF stream. A Length entry is automatically added to the |
+ * stream dictionary. |
+ * @param data The data part of the stream. |
+ * @param stream The data part of the stream. */ |
+ explicit SkPDFStream(sk_sp<SkData> data); |
+ explicit SkPDFStream(std::unique_ptr<SkStreamAsset> stream); |
+ virtual ~SkPDFStream(); |
+ |
+ SkPDFDict* dict() { return &fDict; } |
+ |
+ // The SkPDFObject interface. |
+ void emitObject(SkWStream* stream, |
+ const SkPDFObjNumMap& objNumMap, |
+ const SkPDFSubstituteMap& substitutes) const override; |
+ void addResources(SkPDFObjNumMap*, const SkPDFSubstituteMap&) const final; |
+ void drop() override; |
+ |
+protected: |
+ /* Create a PDF stream with no data. The setData method must be called to |
+ * set the data. */ |
+ SkPDFStream(); |
+ |
+ /** Only call this function once. */ |
+ void setData(std::unique_ptr<SkStreamAsset> stream); |
+ |
+private: |
+ std::unique_ptr<SkStreamAsset> fCompressedData; |
+ SkPDFDict fDict; |
+ |
+ typedef SkPDFDict INHERITED; |
+}; |
+ |
//////////////////////////////////////////////////////////////////////////////// |
/** \class SkPDFObjNumMap |