Index: dm/DMSrcSink.cpp |
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp |
index e67d4355e4ca4caf4f7605422b2bd73f8b91a3ac..cec782e392f780d7da6603dfc901f36b0ceeca85 100644 |
--- a/dm/DMSrcSink.cpp |
+++ b/dm/DMSrcSink.cpp |
@@ -194,12 +194,9 @@ Error GPUSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log) co |
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ |
-PDFSink::PDFSink() {} |
- |
-Error PDFSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const { |
- // Print the given DM:Src to a PDF, breaking on 8.5x11 pages. |
- SkAutoTUnref<SkDocument> doc(SkDocument::CreatePDF(dst)); |
- |
+static Error draw_skdocument(const Src& src, SkDocument* doc, SkWStream* dst) { |
+ // Print the given DM:Src to a document, breaking on 8.5x11 pages. |
+ SkASSERT(doc); |
int width = src.size().width(), |
height = src.size().height(); |
@@ -231,6 +228,27 @@ Error PDFSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const |
return ""; |
} |
+PDFSink::PDFSink() {} |
+ |
+Error PDFSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const { |
+ SkAutoTUnref<SkDocument> doc(SkDocument::CreatePDF(dst)); |
+ if (!doc) { |
+ return "SkDocument::CreatePDF() returned NULL"; |
+ } |
+ return draw_skdocument(src, doc.get(), dst); |
+} |
+ |
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ |
+ |
+XPSSink::XPSSink() {} |
+ |
+Error XPSSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const { |
+ SkAutoTUnref<SkDocument> doc(SkDocument::CreateXPS(dst)); |
+ if (!doc) { |
+ return "SkDocument::CreateXPS() returned NULL"; |
+ } |
+ return draw_skdocument(src, doc.get(), dst); |
+} |
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ |
SKPSink::SKPSink() {} |