[PDF] Make stream compression optional on a per device basis.
There are a lot of small pieces to make this change work:
- SkPDFDocument (and SkPDFCatalog) take flags to disable compression (and font embedding - not implemented yet, can disable font subsetting for now).
- SkPDFStream now defers compression until the size/emit step.
- Classes that *had* a stream (because they didn't know the stream size at construction time) now *are* streams to make the substitution work correctly.
- The SkPDFShader implementation got pulled apart into two classes, one that is a SkPDFDict, and one that is a SkPDFStream (making the common ancestor SkPDFObject).
- Added helper methods in SkPDFObject for children that have simple resource lists.
- Added an iterator to SkPDFDict so that a substitute SkPDFStream can get a copy of the stream dictionary.
- Change SkPDFDocument to have a pointer to an SkPDFCatalog to remove a new circular header reference.
Review URL: http://codereview.appspot.com/4700045
git-svn-id: http://skia.googlecode.com/svn/trunk@1911 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/pdf/SkPDFDocument.h b/include/pdf/SkPDFDocument.h
index 5fb7c95..1a5d835 100644
--- a/include/pdf/SkPDFDocument.h
+++ b/include/pdf/SkPDFDocument.h
@@ -17,11 +17,12 @@
#ifndef SkPDFDocument_DEFINED
#define SkPDFDocument_DEFINED
-#include "SkPDFCatalog.h"
#include "SkPDFTypes.h"
#include "SkRefCnt.h"
#include "SkTDArray.h"
+#include "SkTScopedPtr.h"
+class SkPDFCatalog;
class SkPDFDevice;
class SkPDFPage;
class SkWSteam;
@@ -32,9 +33,15 @@
*/
class SkPDFDocument {
public:
+ enum Flags {
+ kNoCompression_Flag = 0x01, //!< mask disable stream compression.
+ kNoEmbedding_Flag = 0x02, //!< mask do not embed fonts.
+
+ kDraftMode_Flags = 0x03,
+ };
/** Create a PDF document.
*/
- SK_API SkPDFDocument();
+ explicit SK_API SkPDFDocument(Flags flags = (Flags)0);
SK_API ~SkPDFDocument();
/** Output the PDF to the passed stream. It is an error to call this (it
@@ -67,7 +74,7 @@
SK_API const SkTDArray<SkPDFPage*>& getPages();
private:
- SkPDFCatalog fCatalog;
+ SkTScopedPtr<SkPDFCatalog> fCatalog;
int64_t fXRefFileOffset;
SkTDArray<SkPDFPage*> fPages;