aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar edisonn@google.com <edisonn@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-04-24 13:01:01 +0000
committerGravatar edisonn@google.com <edisonn@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-04-24 13:01:01 +0000
commitd9dfa18372119c8e1318125d2075fa80e0819094 (patch)
tree1a4a321c54972e86cf5bec762839145a01f028dd /include
parent6238c57c8dd8ddc14ca778017a0c43ba773b744f (diff)
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
Diffstat (limited to 'include')
-rw-r--r--include/pdf/SkPDFDevice.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/pdf/SkPDFDevice.h b/include/pdf/SkPDFDevice.h
index f8261b5da1..7731d3f4ae 100644
--- a/include/pdf/SkPDFDevice.h
+++ b/include/pdf/SkPDFDevice.h
@@ -37,6 +37,8 @@ struct ContentEntry;
struct GraphicStateEntry;
struct NamedDestination;
+typedef bool (*EncodeToDCTStream)(SkWStream* stream, const SkBitmap& bitmap, const SkIRect& rect);
+
/** \class SkPDFDevice
The drawing context for the PDF backend.
@@ -126,6 +128,21 @@ public:
*/
SK_API void setDrawingArea(DrawingArea drawingArea);
+ /** Sets the DCTEncoder for images.
+ * @param encoder The encoder to encode a bitmap as JPEG (DCT).
+ * Result of encodings are cached, if the encoder changes the
+ * behaivor dynamically and an image is added to a second catalog,
+ * we will likely use the result of the first encoding call.
+ * By returning false from the encoder function, the encoder result
+ * is not used.
+ * Callers might not want to encode small images, as the time spent
+ * encoding and decoding might not be worth the space savings,
+ * if any at all.
+ */
+ void setDCTEncoder(EncodeToDCTStream encoder) {
+ fEncoder = encoder;
+ }
+
// PDF specific methods.
/** Returns the resource dictionary for this device.
@@ -230,6 +247,8 @@ private:
// Glyph ids used for each font on this device.
SkTScopedPtr<SkPDFGlyphSetMap> fFontGlyphUsage;
+ EncodeToDCTStream fEncoder;
+
SkPDFDevice(const SkISize& layerSize, const SkClipStack& existingClipStack,
const SkRegion& existingClipRegion);