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

Unified Diff: src/pdf/SkPDFTypes.h

Issue 2190883003: SkPDF: PDFStream has-a not is-a PDFDict (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-07-29 (Friday) 12:30:20 EDT Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pdf/SkPDFStream.cpp ('k') | src/pdf/SkPDFTypes.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « src/pdf/SkPDFStream.cpp ('k') | src/pdf/SkPDFTypes.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698