Encode images with DCTDecode (JPEG) in PDFs if it makes sense. Fallback to FlateDecode (zip) if it makes sense. Otherewise include uncompressed stream.
This change will reduce the size of PDFs to 50% (in the case of the existing SKPs, we reduce the total size of PDFs from 105MB to 50MB)
Review URL: https://codereview.appspot.com/7068055
git-svn-id: http://skia.googlecode.com/svn/trunk@8835 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/pdf/SkPDFStream.h b/src/pdf/SkPDFStream.h
index 6f7a08e..4b8153f 100644
--- a/src/pdf/SkPDFStream.h
+++ b/src/pdf/SkPDFStream.h
@@ -44,32 +44,53 @@
virtual size_t getOutputSize(SkPDFCatalog* catalog, bool indirect);
protected:
- /* Create a PDF stream with no data. The setData method must be called to
- * set the data.
- */
- SkPDFStream();
-
- void setData(SkStream* stream);
-
-private:
enum State {
kUnused_State, //!< The stream hasn't been requested yet.
kNoCompression_State, //!< The stream's been requested in an
// uncompressed form.
kCompressed_State, //!< The stream's already been compressed.
};
+
+ /* Create a PDF stream with no data. The setData method must be called to
+ * set the data.
+ */
+ SkPDFStream();
+
+ // Populate the stream dictionary. This method returns false if
+ // fSubstitute should be used.
+ virtual bool populate(SkPDFCatalog* catalog);
+
+ void setSubstitute(SkPDFStream* stream) {
+ fSubstitute.reset(stream);
+ }
+
+ SkPDFStream* getSubstitute() {
+ return fSubstitute.get();
+ }
+
+ void setData(SkStream* stream);
+
+ SkStream* getData() {
+ return fData.get();
+ }
+
+ void setState(State state) {
+ fState = state;
+ }
+
+ State getState() {
+ return fState;
+ }
+
+private:
// Indicates what form (or if) the stream has been requested.
State fState;
-
+
// TODO(vandebo): Use SkData (after removing deprecated constructor).
SkAutoTUnref<SkStream> fData;
SkAutoTUnref<SkPDFStream> fSubstitute;
typedef SkPDFDict INHERITED;
-
- // Populate the stream dictionary. This method returns false if
- // fSubstitute should be used.
- bool populate(SkPDFCatalog* catalog);
};
#endif