diff options
author | mtklein <mtklein@chromium.org> | 2015-01-31 20:00:58 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-31 20:00:58 -0800 |
commit | 8a4527e98a57b1d2dd248a635f0c4fa227be2089 (patch) | |
tree | 8d2b6d3089aed5e2e818ac017fbe469569ba571f /dm | |
parent | 6c96672491b04cb782bce8fee778124df66524a0 (diff) |
SVG backend in DM
Not enabled by default, but this should get you SKPs, GMs etc for free to play with.
$ out/Debug/dm -w svgs --src gm skp --config svg
BUG=skia:
Review URL: https://codereview.chromium.org/892693002
Diffstat (limited to 'dm')
-rw-r--r-- | dm/DM.cpp | 3 | ||||
-rw-r--r-- | dm/DMSrcSink.cpp | 11 | ||||
-rw-r--r-- | dm/DMSrcSink.h | 10 |
3 files changed, 23 insertions, 1 deletions
@@ -221,7 +221,8 @@ static Sink* create_sink(const char* tag) { SINK("8888", RasterSink, kN32_SkColorType); SINK("pdf", PDFSink); SINK("skp", SKPSink); - SINK("null", NullSink); + SINK("svg", SVGSink); + SINK("null", NullSink); } #undef SINK return NULL; diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp index f3ed574d89..baf1871ba3 100644 --- a/dm/DMSrcSink.cpp +++ b/dm/DMSrcSink.cpp @@ -6,6 +6,7 @@ #include "SkOSFile.h" #include "SkPictureRecorder.h" #include "SkRandom.h" +#include "SkSVGDevice.h" #include "SkStream.h" namespace DM { @@ -227,6 +228,16 @@ Error SKPSink::draw(const Src& src, SkBitmap*, SkWStream* dst) const { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +SVGSink::SVGSink() {} + +Error SVGSink::draw(const Src& src, SkBitmap*, SkWStream* dst) const { + SkAutoTUnref<SkBaseDevice> device(SkSVGDevice::Create(src.size(), dst)); + SkCanvas canvas(device); + return src.draw(&canvas); +} + +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ + RasterSink::RasterSink(SkColorType colorType) : fColorType(colorType) {} Error RasterSink::draw(const Src& src, SkBitmap* dst, SkWStream*) const { diff --git a/dm/DMSrcSink.h b/dm/DMSrcSink.h index bf8e7d6810..1fdc9ed927 100644 --- a/dm/DMSrcSink.h +++ b/dm/DMSrcSink.h @@ -130,6 +130,16 @@ public: const char* fileExtension() const SK_OVERRIDE { return "skp"; } }; +class SVGSink : public Sink { +public: + SVGSink(); + + Error draw(const Src&, SkBitmap*, SkWStream*) const SK_OVERRIDE; + int enclave() const SK_OVERRIDE { return kAnyThread_Enclave; } + const char* fileExtension() const SK_OVERRIDE { return "svg"; } +}; + + /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ class ViaMatrix : public Sink { |