aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pdf/SkPDFCanon.h
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2015-02-18 11:29:56 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-18 11:29:57 -0800
commit1b5c604d9d344537941b11b136348edfc39f236c (patch)
tree72110f65007d2e0af1cc525376488ed360b6a07d /src/pdf/SkPDFCanon.h
parent0babd3c61987428a5c532f65be9d98c7ac583e0d (diff)
PDF: Add (low-memory) SkPDFBitmap class
Also: Add SkDeflateWStream and associated unit tests. SkPDFBitmap is a replacement for SkPDFImage. As of now, it only supports 8888 bitmaps (the most common case). SkPDFBitmap takes very little extra memory (aside from refing the bitmap's pixels), and its emitObject() does not cache any data. The SkPDFBitmap::Create function will check the canon for duplicates. This can reduce the size of the output PDF. Motivation: this gives another ~40% decrease in PDF memory overhead TODO: Support other ColorTypes and scrap SkPDFImage. BUG=skia:3030 Review URL: https://codereview.chromium.org/918813002
Diffstat (limited to 'src/pdf/SkPDFCanon.h')
-rw-r--r--src/pdf/SkPDFCanon.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/pdf/SkPDFCanon.h b/src/pdf/SkPDFCanon.h
index 8e89424084..6a677e9a68 100644
--- a/src/pdf/SkPDFCanon.h
+++ b/src/pdf/SkPDFCanon.h
@@ -12,9 +12,11 @@
#include "SkTDArray.h"
struct SkIRect;
+class SkBitmap;
class SkMatrix;
class SkPDFFont;
class SkPDFGraphicState;
+class SkPDFBitmap;
class SkPaint;
// This class's fields and methods will eventually become part of
@@ -40,6 +42,7 @@ public:
static SkBaseMutex& GetFontMutex();
static SkBaseMutex& GetShaderMutex();
static SkBaseMutex& GetPaintMutex();
+ static SkBaseMutex& GetBitmapMutex();
// Returns exact match if there is one. If not, it returns NULL.
// If there is no exact match, but there is a related font, we
@@ -66,6 +69,10 @@ public:
void addGraphicState(SkPDFGraphicState*);
void removeGraphicState(SkPDFGraphicState*);
+ SkPDFBitmap* findBitmap(const SkBitmap&) const;
+ void addBitmap(SkPDFBitmap*);
+ void removeBitmap(SkPDFBitmap*);
+
private:
struct FontRec {
SkPDFFont* fFont;
@@ -81,5 +88,7 @@ private:
SkTDArray<SkPDFImageShader*> fImageShaderRecords;
SkTDArray<SkPDFGraphicState*> fGraphicStateRecords;
+
+ SkTDArray<SkPDFBitmap*> fBitmapRecords;
};
#endif // SkPDFCanon_DEFINED