Flutter Engine
The Flutter Engine
OffsetPaths.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2020 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
18#include "src/utils/SkJSON.h"
19
20#include <utility>
21#include <vector>
22
23namespace skottie::internal {
24
25namespace {
26
27class OffsetPathsAdapter final : public DiscardableAdapterBase<OffsetPathsAdapter,
28 sksg::OffsetEffect> {
29public:
30 OffsetPathsAdapter(const skjson::ObjectValue& joffset,
31 const AnimationBuilder& abuilder,
33 : INHERITED(sksg::OffsetEffect::Make(std::move(child))) {
34 static constexpr SkPaint::Join gJoinMap[] = {
35 SkPaint::kMiter_Join, // 'lj': 1
36 SkPaint::kRound_Join, // 'lj': 2
37 SkPaint::kBevel_Join, // 'lj': 3
38 };
39
40 const auto join = ParseDefault<int>(joffset["lj"], 1) - 1;
41 this->node()->setJoin(gJoinMap[SkTPin<int>(join, 0, std::size(gJoinMap) - 1)]);
42
43 this->bind(abuilder, joffset["a" ], fAmount);
44 this->bind(abuilder, joffset["ml"], fMiterLimit);
45 }
46
47private:
48 void onSync() override {
49 this->node()->setOffset(fAmount);
50 this->node()->setMiterLimit(fMiterLimit);
51 }
52
53 ScalarValue fAmount = 0,
54 fMiterLimit = 0;
55
56 using INHERITED = DiscardableAdapterBase<OffsetPathsAdapter, sksg::OffsetEffect>;
57};
58
59} // namespace
60
61std::vector<sk_sp<sksg::GeometryNode>> ShapeBuilder::AttachOffsetGeometryEffect(
62 const skjson::ObjectValue& jround, const AnimationBuilder* abuilder,
63 std::vector<sk_sp<sksg::GeometryNode>>&& geos) {
64 std::vector<sk_sp<sksg::GeometryNode>> offsetted;
65 offsetted.reserve(geos.size());
66
67 for (auto& g : geos) {
68 offsetted.push_back(abuilder->attachDiscardableAdapter<OffsetPathsAdapter>
69 (jround, *abuilder, std::move(g)));
70 }
71
72 return offsetted;
73}
74
75} // namespace skottie::internal
#define INHERITED(method,...)
Definition: SkRecorder.cpp:128
@ kRound_Join
adds circle
Definition: SkPaint.h:360
@ kMiter_Join
extends to miter limit
Definition: SkPaint.h:359
@ kBevel_Join
connects outside edges
Definition: SkPaint.h:361
void attachDiscardableAdapter(sk_sp< T > adapter) const
Definition: SkottiePriv.h:139
static std::vector< sk_sp< sksg::GeometryNode > > AttachOffsetGeometryEffect(const skjson::ObjectValue &, const AnimationBuilder *, std::vector< sk_sp< sksg::GeometryNode > > &&)
Definition: OffsetPaths.cpp:61
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
SkScalar ScalarValue
Definition: SkottieValue.h:22
Definition: Skottie.h:32
Definition: ref_ptr.h:256
static SkString join(const CommandLineFlags::StringArray &)
Definition: skpbench.cpp:741