aboutsummaryrefslogtreecommitdiffhomepage
path: root/dm/DMSrcSink.cpp
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2015-03-03 09:13:09 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-03-03 09:13:09 -0800
commit47ef4d5d934bba86848aa238efab21f54a160c1a (patch)
tree8e0fd1776a766fc9b4bcddba37d520763d50ab58 /dm/DMSrcSink.cpp
parentf24f2247c25b842327e12c70e44efe4cc1b28dfa (diff)
XPS, DM: add SkDocument::CreateXPS
- SkDocument::CreateXPS() function added, returns NULL on non-Windows OS. - DM: (Windows only) an XPSSink is added, fails on non-Windows OS - DM: Common code for PDFSink::draw and XPSSink::draw are factored into draw_skdocument static function. - SkDocument_XPS (Windows only) implementation of SkDocument via SkXPSDevice. - SkDocument_XPS_None (non-Windows) returns NULL for SkDocument::CreateXPS(). - gyp/xps.gyp refactored. - SkXPSDevice::drawTextOnPath removed (see http://crrev.com/925343003 ) - SkXPSDevice::drawPath supports conics via SkAutoConicToQuads. Review URL: https://codereview.chromium.org/963953002
Diffstat (limited to 'dm/DMSrcSink.cpp')
-rw-r--r--dm/DMSrcSink.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 67f8ac6edb..2060ce2d68 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -223,12 +223,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();
@@ -260,6 +257,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() {}