blob: 631c2c22032987e66a3164ee925809af6ff9acd4 [file] [log] [blame]
/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "include/svg/SkSVGCanvas.h"
#include "src/svg/SkSVGDevice.h"
#include "src/xml/SkXMLWriter.h"
std::unique_ptr<SkCanvas> SkSVGCanvas::Make(const SkRect& bounds, SkWStream* writer,
uint32_t flags) {
// TODO: pass full bounds to the device
const auto size = bounds.roundOut().size();
const auto xml_flags = (flags & kNoPrettyXML_Flag) ? SkToU32(SkXMLStreamWriter::kNoPretty_Flag)
: 0;
auto svgDevice = SkSVGDevice::Make(size,
std::make_unique<SkXMLStreamWriter>(writer, xml_flags),
flags);
return svgDevice ? std::make_unique<SkCanvas>(std::move(svgDevice))
: nullptr;
}