Flutter Engine
The Flutter Engine
SvgSlide.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2018 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
9
10#if defined(SK_ENABLE_SVG)
11
18#include "src/utils/SkOSPath.h"
20
22 : fPath(path) {
23 fName = name;
24}
25
26SvgSlide::~SvgSlide() = default;
27
29 auto stream = SkStream::MakeFromFile(fPath.c_str());
30
31 if (!stream) {
32 SkDebugf("Could not open %s.\n", fPath.c_str());
33 return;
34 }
35
36 // Viewer should have already registered the codecs necessary for DataURIResourceProviderProxy
40 predecode, ToolUtils::TestFontMgr());
41
42 fDom = SkSVGDOM::Builder()
43 .setFontManager(ToolUtils::TestFontMgr())
44 .setResourceProvider(std::move(rp))
45 .setTextShapingFactory(SkShapers::BestAvailable())
46 .make(*stream);
47
48 if (fDom) {
50 }
51}
52
53void SvgSlide::unload() {
54 fDom.reset();
55}
56
58 if (fDom) {
60 }
61}
62
63void SvgSlide::draw(SkCanvas* canvas) {
64 if (fDom) {
65 fDom->render(canvas);
66 }
67}
68
69#endif // defined(SK_ENABLE_SVG)
SkPath fPath
const char * fName
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static SkString Dirname(const char *fullPath)
Definition: SkOSPath.cpp:36
void render(SkCanvas *) const
Definition: SkSVGDOM.cpp:460
void setContainerSize(const SkSize &)
Definition: SkSVGDOM.cpp:497
static std::unique_ptr< SkStreamAsset > MakeFromFile(const char path[])
Definition: SkStream.cpp:922
const char * c_str() const
Definition: SkString.h:133
void draw(SkCanvas *) override
~SvgSlide() override
void unload() override
SvgSlide(const SkString &name, const SkString &path)
void load(SkScalar winWidth, SkScalar winHeight) override
void resize(SkScalar, SkScalar) override
void reset(T *ptr=nullptr)
Definition: SkRefCnt.h:310
static sk_sp< DataURIResourceProviderProxy > Make(sk_sp< ResourceProvider > rp, ImageDecodeStrategy=ImageDecodeStrategy::kLazyDecode, sk_sp< const SkFontMgr > fontMgr=nullptr)
static sk_sp< FileResourceProvider > Make(SkString base_dir, ImageDecodeStrategy=ImageDecodeStrategy::kLazyDecode)
float SkScalar
Definition: extension.cpp:12
sk_sp< Factory > BestAvailable()
sk_sp< SkFontMgr > TestFontMgr()
DlVertices::Builder Builder
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
SkScalar w
SkScalar h
static constexpr SkSize Make(SkScalar w, SkScalar h)
Definition: SkSize.h:56