SkSVGCanvas.cpp 719 B

12345678910111213141516171819202122
  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. #include "include/svg/SkSVGCanvas.h"
  8. #include "src/core/SkMakeUnique.h"
  9. #include "src/svg/SkSVGDevice.h"
  10. #include "src/xml/SkXMLWriter.h"
  11. std::unique_ptr<SkCanvas> SkSVGCanvas::Make(const SkRect& bounds, SkWStream* writer,
  12. uint32_t flags) {
  13. // TODO: pass full bounds to the device
  14. SkISize size = bounds.roundOut().size();
  15. auto svgDevice = SkSVGDevice::Make(size, skstd::make_unique<SkXMLStreamWriter>(writer), flags);
  16. return svgDevice ? skstd::make_unique<SkCanvas>(svgDevice)
  17. : nullptr;
  18. }