Index: include/core/SkDocument.h |
diff --git a/include/core/SkDocument.h b/include/core/SkDocument.h |
index bbed64a80691fb3fde1358904ec02ba5b5bb8d3b..dd43204cdbc019af68cdea5f92703d54bbbd35c1 100644 |
--- a/include/core/SkDocument.h |
+++ b/include/core/SkDocument.h |
@@ -8,8 +8,11 @@ |
#ifndef SkDocument_DEFINED |
#define SkDocument_DEFINED |
+#include "SkPDFCallbacks.h" |
bungeman-skia
2013/09/26 19:52:39
core should not depend on PDF.
edisonn
2013/10/04 19:40:37
Done.
|
#include "SkRect.h" |
#include "SkRefCnt.h" |
+#include "SkBitmap.h" |
+#include "SkRect.h" |
class SkCanvas; |
class SkWStream; |
@@ -31,8 +34,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[], |
+ EncodeToDCTStream encoder = NULL); |
/** |
* Create a PDF-backed document, writing the results into a stream. |
@@ -43,16 +49,20 @@ 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, |
+ EncodeToDCTStream encoder = NULL); |
/** |
* Begin a new page for the document, returning the canvas that will draw |
* into the page. The document owns this canvas, and it will go out of |
* scope when endPage() or close() is called, or the document is deleted. |
+ * If mediaBox is null, then we set the mediabox to the trim rectangle. |
vandebo (ex-Chrome)
2013/09/27 15:50:17
Please document the args better. What affect does
edisonn
2013/10/04 19:40:37
Done.
|
*/ |
- SkCanvas* beginPage(SkScalar width, SkScalar height, |
- const SkRect* content = NULL); |
+ SkCanvas* beginPage(const SkSize& trimSize, |
+ const SkRect* mediaBox = NULL); |
/** |
* Call endPage() when the content for the current page has been drawn |
@@ -66,8 +76,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. |
+ */ |
+ bool close(); |
+ |
+ /** |
+ * Call abort() to stop producing the document immediately. |
+ * The stream output must be ignored, and should not be trusted. |
*/ |
- void close(); |
+ void abort(); |
protected: |
SkDocument(SkWStream*, void (*)(SkWStream*)); |
@@ -75,10 +92,11 @@ protected: |
// cannot do this for them. |
virtual ~SkDocument(); |
- virtual SkCanvas* onBeginPage(SkScalar width, SkScalar height, |
- const SkRect& content) = 0; |
+ virtual SkCanvas* onBeginPage(const SkSize& trimSize, |
+ const SkRect* mediaBox) = 0; |
virtual void onEndPage() = 0; |
- virtual void onClose(SkWStream*) = 0; |
+ virtual bool onClose(SkWStream*) = 0; |
+ virtual void onAbort() = 0; |
enum State { |
kBetweenPages_State, |