| Index: include/core/SkDocument.h
|
| diff --git a/include/core/SkDocument.h b/include/core/SkDocument.h
|
| index bbed64a80691fb3fde1358904ec02ba5b5bb8d3b..b941d1bd19ce775be0c83c474dcb42ba5e0f4dc9 100644
|
| --- a/include/core/SkDocument.h
|
| +++ b/include/core/SkDocument.h
|
| @@ -8,6 +8,8 @@
|
| #ifndef SkDocument_DEFINED
|
| #define SkDocument_DEFINED
|
|
|
| +#include "SkBitmap.h"
|
| +#include "SkPicture.h"
|
| #include "SkRect.h"
|
| #include "SkRefCnt.h"
|
|
|
| @@ -31,8 +33,11 @@ public:
|
| /**
|
| * Create a PDF-backed document, writing the results into a file.
|
| * If there is an error trying to create the doc, returns NULL.
|
| + * encoder sets the DCTEncoder for images, to encode a bitmap
|
| + * as JPEG (DCT).
|
| */
|
| - static SkDocument* CreatePDF(const char filename[]);
|
| + static SkDocument* CreatePDF(const char filename[],
|
| + SkPicture::EncodeBitmap encoder = NULL);
|
|
|
| /**
|
| * Create a PDF-backed document, writing the results into a stream.
|
| @@ -43,8 +48,11 @@ public:
|
| * has been called, and all of the data has been written to the stream,
|
| * if there is a Done proc provided, it will be called with the stream.
|
| * The proc can delete the stream, or whatever it needs to do.
|
| + * encoder sets the DCTEncoder for images, to encode a bitmap
|
| + * as JPEG (DCT).
|
| */
|
| - static SkDocument* CreatePDF(SkWStream*, void (*Done)(SkWStream*) = NULL);
|
| + static SkDocument* CreatePDF(SkWStream*, void (*Done)(SkWStream*) = NULL,
|
| + SkPicture::EncodeBitmap encoder = NULL);
|
|
|
| /**
|
| * Begin a new page for the document, returning the canvas that will draw
|
| @@ -66,8 +74,15 @@ public:
|
| * or stream holding the document's contents. After close() the document
|
| * can no longer add new pages. Deleting the document will automatically
|
| * call close() if need be.
|
| + * Returns true on success or false on failure.
|
| */
|
| - void close();
|
| + bool close();
|
| +
|
| + /**
|
| + * Call abort() to stop producing the document immediately.
|
| + * The stream output must be ignored, and should not be trusted.
|
| + */
|
| + void abort();
|
|
|
| protected:
|
| SkDocument(SkWStream*, void (*)(SkWStream*));
|
| @@ -78,7 +93,8 @@ protected:
|
| virtual SkCanvas* onBeginPage(SkScalar width, SkScalar height,
|
| const SkRect& content) = 0;
|
| virtual void onEndPage() = 0;
|
| - virtual void onClose(SkWStream*) = 0;
|
| + virtual bool onClose(SkWStream*) = 0;
|
| + virtual void onAbort() = 0;
|
|
|
| enum State {
|
| kBetweenPages_State,
|
|
|