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