Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(377)

Unified Diff: src/doc/SkDocument_PDF.cpp

Issue 26744002: SkDocument api changes (abort, close return success, ...) modified: include/core/SkDocument.h m… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: consitent names Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/doc/SkDocument.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/doc/SkDocument_PDF.cpp
diff --git a/src/doc/SkDocument_PDF.cpp b/src/doc/SkDocument_PDF.cpp
index 27cf2e88c53241d20b56ce3c79b9166580909bc6..b9b55f8dce688cefa8f1e555200d5a8a93f36f79 100644
--- a/src/doc/SkDocument_PDF.cpp
+++ b/src/doc/SkDocument_PDF.cpp
@@ -6,13 +6,15 @@
*/
#include "SkDocument.h"
-#include "SkPDFDocument.h"
#include "SkPDFDevice.h"
+#include "SkPDFDocument.h"
class SkDocument_PDF : public SkDocument {
public:
- SkDocument_PDF(SkWStream* stream, void (*doneProc)(SkWStream*))
- : SkDocument(stream, doneProc) {
+ SkDocument_PDF(SkWStream* stream, void (*doneProc)(SkWStream*),
+ SkPicture::EncodeBitmap encoder)
+ : SkDocument(stream, doneProc)
+ , fEncoder(encoder) {
fDoc = SkNEW(SkPDFDocument);
fCanvas = NULL;
fDevice = NULL;
@@ -38,6 +40,9 @@ protected:
matrix.setTranslate(content.fLeft, content.fTop);
fDevice = SkNEW_ARGS(SkPDFDevice, (pageS, contentS, matrix));
+ if (fEncoder) {
+ fDevice->setDCTEncoder(fEncoder);
+ }
fCanvas = SkNEW_ARGS(SkCanvas, (fDevice));
return fCanvas;
}
@@ -56,36 +61,44 @@ protected:
fDevice = NULL;
}
- virtual void onClose(SkWStream* stream) SK_OVERRIDE {
+ virtual bool onClose(SkWStream* stream) SK_OVERRIDE {
SkASSERT(NULL == fCanvas);
SkASSERT(NULL == fDevice);
- fDoc->emitPDF(stream);
+ bool success = fDoc->emitPDF(stream);
+ SkDELETE(fDoc);
+ fDoc = NULL;
+ return success;
+ }
+
+ virtual void onAbort() SK_OVERRIDE {
SkDELETE(fDoc);
fDoc = NULL;
}
private:
SkPDFDocument* fDoc;
- SkPDFDevice* fDevice;
+ SkPDFDevice* fDevice;
SkCanvas* fCanvas;
+ SkPicture::EncodeBitmap fEncoder;
};
///////////////////////////////////////////////////////////////////////////////
-SkDocument* SkDocument::CreatePDF(SkWStream* stream, void (*done)(SkWStream*)) {
- return stream ? SkNEW_ARGS(SkDocument_PDF, (stream, done)) : NULL;
+SkDocument* SkDocument::CreatePDF(SkWStream* stream, void (*done)(SkWStream*),
+ SkPicture::EncodeBitmap enc) {
+ return stream ? SkNEW_ARGS(SkDocument_PDF, (stream, done, enc)) : NULL;
}
static void delete_wstream(SkWStream* stream) {
SkDELETE(stream);
}
-SkDocument* SkDocument::CreatePDF(const char path[]) {
+SkDocument* SkDocument::CreatePDF(const char path[], SkPicture::EncodeBitmap enc) {
SkFILEWStream* stream = SkNEW_ARGS(SkFILEWStream, (path));
if (!stream->isValid()) {
SkDELETE(stream);
return NULL;
}
- return SkNEW_ARGS(SkDocument_PDF, (stream, delete_wstream));
+ return SkNEW_ARGS(SkDocument_PDF, (stream, delete_wstream, enc));
}
« no previous file with comments | « src/doc/SkDocument.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698