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

Unified Diff: src/doc/SkDocument_PDF.cpp

Issue 24615006: rebaseline drawbitmap gms (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: remove expectation included by mistake in another cl Created 7 years, 3 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
Index: src/doc/SkDocument_PDF.cpp
diff --git a/src/doc/SkDocument_PDF.cpp b/src/doc/SkDocument_PDF.cpp
index 27cf2e88c53241d20b56ce3c79b9166580909bc6..affc9f81fa3faef274621c5929b76a80bca4e841 100644
--- a/src/doc/SkDocument_PDF.cpp
+++ b/src/doc/SkDocument_PDF.cpp
@@ -6,6 +6,7 @@
*/
#include "SkDocument.h"
+#include "SkCanvasSimplifier.h"
#include "SkPDFDocument.h"
#include "SkPDFDevice.h"
@@ -16,6 +17,7 @@ public:
fDoc = SkNEW(SkPDFDocument);
fCanvas = NULL;
fDevice = NULL;
+ fEncoder = NULL;
}
virtual ~SkDocument_PDF() {
@@ -24,21 +26,18 @@ public:
}
protected:
- virtual SkCanvas* onBeginPage(SkScalar width, SkScalar height,
- const SkRect& content) SK_OVERRIDE {
+ virtual SkCanvas* onBeginPage(const SkSize& trimSize,
+ const SkRect* mediaBox) SK_OVERRIDE {
SkASSERT(NULL == fCanvas);
SkASSERT(NULL == fDevice);
- SkISize pageS, contentS;
- SkMatrix matrix;
+ SkRect content = mediaBox ? *mediaBox : SkRect::MakeSize(trimSize);
- pageS.set(SkScalarRoundToInt(width), SkScalarRoundToInt(height));
- contentS.set(SkScalarRoundToInt(content.width()),
- SkScalarRoundToInt(content.height()));
- matrix.setTranslate(content.fLeft, content.fTop);
-
- fDevice = SkNEW_ARGS(SkPDFDevice, (pageS, contentS, matrix));
- fCanvas = SkNEW_ARGS(SkCanvas, (fDevice));
+ fDevice = SkNEW_ARGS(SkPDFDevice, (trimSize, content));
+ if (fEncoder) {
+ fDevice->setDCTEncoder(fEncoder);
+ }
+ fCanvas = SkNEW_ARGS(SkCanvasSimplifier, (fDevice));
return fCanvas;
}
@@ -56,19 +55,31 @@ 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;
+ }
+
+ virtual bool setDCTEncoder(EncodeToDCTStream encoder) {
+ fEncoder = encoder;
+ return true;
}
private:
SkPDFDocument* fDoc;
SkPDFDevice* fDevice;
SkCanvas* fCanvas;
+ EncodeToDCTStream fEncoder;
};
///////////////////////////////////////////////////////////////////////////////
« include/core/SkDocument.h ('K') | « src/doc/SkDocument.cpp ('k') | src/pdf/SkPDFDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698