diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-10-09 21:09:00 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-10-09 21:09:00 +0000 |
commit | b5a6651f9f69570d964382134d64360915db9a29 (patch) | |
tree | 0cd6b2cb12875a3fe71389c8bada5329cd72f95f /include/core/SkDocument.h | |
parent | c8fda9d96be0bd944d37a6e23f7adad5f247c51d (diff) |
SkDocument api changes (abort, close return success, set DCT encoder...).
R=reed@google.com, reed
Author: edisonn@google.com
Review URL: https://codereview.chromium.org/26744002
git-svn-id: http://skia.googlecode.com/svn/trunk@11688 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core/SkDocument.h')
-rw-r--r-- | include/core/SkDocument.h | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/include/core/SkDocument.h b/include/core/SkDocument.h index bbed64a806..b941d1bd19 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, |