xref: /third_party/skia/src/svg/SkSVGCanvas.cpp
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/skia/src/svg/
1cb93a386Sopenharmony_ci/*
2cb93a386Sopenharmony_ci * Copyright 2015 Google Inc.
3cb93a386Sopenharmony_ci *
4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be
5cb93a386Sopenharmony_ci * found in the LICENSE file.
6cb93a386Sopenharmony_ci */
7cb93a386Sopenharmony_ci
8cb93a386Sopenharmony_ci#include "include/svg/SkSVGCanvas.h"
9cb93a386Sopenharmony_ci#include "src/svg/SkSVGDevice.h"
10cb93a386Sopenharmony_ci#include "src/xml/SkXMLWriter.h"
11cb93a386Sopenharmony_ci
12cb93a386Sopenharmony_cistd::unique_ptr<SkCanvas> SkSVGCanvas::Make(const SkRect& bounds, SkWStream* writer,
13cb93a386Sopenharmony_ci                                            uint32_t flags) {
14cb93a386Sopenharmony_ci    // TODO: pass full bounds to the device
15cb93a386Sopenharmony_ci    const auto size = bounds.roundOut().size();
16cb93a386Sopenharmony_ci    const auto xml_flags = (flags & kNoPrettyXML_Flag) ? SkToU32(SkXMLStreamWriter::kNoPretty_Flag)
17cb93a386Sopenharmony_ci                                                       : 0;
18cb93a386Sopenharmony_ci
19cb93a386Sopenharmony_ci    auto svgDevice = SkSVGDevice::Make(size,
20cb93a386Sopenharmony_ci                                       std::make_unique<SkXMLStreamWriter>(writer, xml_flags),
21cb93a386Sopenharmony_ci                                       flags);
22cb93a386Sopenharmony_ci
23cb93a386Sopenharmony_ci    return svgDevice ? std::make_unique<SkCanvas>(std::move(svgDevice))
24cb93a386Sopenharmony_ci                     : nullptr;
25cb93a386Sopenharmony_ci}
26

Indexes created Thu Nov 07 10:32:03 CST 2024