Flutter Engine
The Flutter Engine
RoundCorners.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
15#include "src/utils/SkJSON.h"
16
17#include <utility>
18#include <vector>
19
20namespace skottie {
21namespace internal {
22
23namespace {
24
25class RoundCornersAdapter final : public DiscardableAdapterBase<RoundCornersAdapter,
26 sksg::RoundEffect> {
27public:
28 RoundCornersAdapter(const skjson::ObjectValue& jround,
29 const AnimationBuilder& abuilder,
31 : INHERITED(sksg::RoundEffect::Make(std::move(child))) {
32 this->bind(abuilder, jround["r"], fRadius);
33 }
34
35private:
36 void onSync() override {
37 this->node()->setRadius(fRadius);
38 }
39
40 ScalarValue fRadius = 0;
41
42 using INHERITED = DiscardableAdapterBase<RoundCornersAdapter, sksg::RoundEffect>;
43};
44
45} // namespace
46
47std::vector<sk_sp<sksg::GeometryNode>> ShapeBuilder::AttachRoundGeometryEffect(
48 const skjson::ObjectValue& jround, const AnimationBuilder* abuilder,
49 std::vector<sk_sp<sksg::GeometryNode>>&& geos) {
50 std::vector<sk_sp<sksg::GeometryNode>> rounded;
51 rounded.reserve(geos.size());
52
53 for (auto& g : geos) {
54 rounded.push_back(
55 abuilder->attachDiscardableAdapter<RoundCornersAdapter>
56 (jround, *abuilder, std::move(g)));
57 }
58
59 return rounded;
60}
61
62} // namespace internal
63} // namespace skottie
#define INHERITED(method,...)
Definition: SkRecorder.cpp:128
void attachDiscardableAdapter(sk_sp< T > adapter) const
Definition: SkottiePriv.h:139
static std::vector< sk_sp< sksg::GeometryNode > > AttachRoundGeometryEffect(const skjson::ObjectValue &, const AnimationBuilder *, std::vector< sk_sp< sksg::GeometryNode > > &&)
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
SkScalar ScalarValue
Definition: SkottieValue.h:22
Definition: Skottie.h:32
Definition: ref_ptr.h:256