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/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 6298f7b..15da5a5 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -591,7 +591,8 @@
fContentSize(contentSize),
fLastContentEntry(NULL),
fLastMarginContentEntry(NULL),
- fClipStack(NULL) {
+ fClipStack(NULL),
+ fEncoder(NULL) {
// Skia generally uses the top left as the origin but PDF natively has the
// origin at the bottom left. This matrix corrects for that. But that only
// needs to be done once, we don't do it when layering.
@@ -1822,7 +1823,7 @@
return;
}
- SkPDFImage* image = SkPDFImage::CreateImage(bitmap, subset);
+ SkPDFImage* image = SkPDFImage::CreateImage(bitmap, subset, fEncoder);
if (!image) {
return;
}