blob: 631c2c22032987e66a3164ee925809af6ff9acd4 [file] [log] [blame]
fmalita2aafe6f2015-02-06 12:51:10 -08001/*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#include "include/svg/SkSVGCanvas.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -05009#include "src/svg/SkSVGDevice.h"
10#include "src/xml/SkXMLWriter.h"
fmalita2aafe6f2015-02-06 12:51:10 -080011
Florin Malitaabc96532019-07-19 09:11:29 -040012std::unique_ptr<SkCanvas> SkSVGCanvas::Make(const SkRect& bounds, SkWStream* writer,
13 uint32_t flags) {
fmalita2aafe6f2015-02-06 12:51:10 -080014 // TODO: pass full bounds to the device
Florin Malita49d140d2019-08-21 15:40:46 -040015 const auto size = bounds.roundOut().size();
16 const auto xml_flags = (flags & kNoPrettyXML_Flag) ? SkToU32(SkXMLStreamWriter::kNoPretty_Flag)
17 : 0;
fmalita2aafe6f2015-02-06 12:51:10 -080018
Florin Malita49d140d2019-08-21 15:40:46 -040019 auto svgDevice = SkSVGDevice::Make(size,
Mike Kleinf46d5ca2019-12-11 10:45:01 -050020 std::make_unique<SkXMLStreamWriter>(writer, xml_flags),
Florin Malita49d140d2019-08-21 15:40:46 -040021 flags);
Florin Malita99822ac2017-09-19 16:12:25 -040022
Mike Kleinf46d5ca2019-12-11 10:45:01 -050023 return svgDevice ? std::make_unique<SkCanvas>(std::move(svgDevice))
Florin Malita562017b2019-02-14 13:42:15 -050024 : nullptr;
Florin Malita99822ac2017-09-19 16:12:25 -040025}