1 /* 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 8 #include "include/svg/SkSVGCanvas.h" 9 #include "src/svg/SkSVGDevice.h" 10 #include "src/xml/SkXMLWriter.h" 11 Make(const SkRect & bounds,SkWStream * writer,uint32_t flags)12std::unique_ptr<SkCanvas> SkSVGCanvas::Make(const SkRect& bounds, SkWStream* writer, 13 uint32_t flags) { 14 // TODO: pass full bounds to the device 15 const auto size = bounds.roundOut().size(); 16 const auto xml_flags = (flags & kNoPrettyXML_Flag) ? SkToU32(SkXMLStreamWriter::kNoPretty_Flag) 17 : 0; 18 19 auto svgDevice = SkSVGDevice::Make(size, 20 std::make_unique<SkXMLStreamWriter>(writer, xml_flags), 21 flags); 22 23 return svgDevice ? std::make_unique<SkCanvas>(std::move(svgDevice)) 24 : nullptr; 25 } 26