/* * Copyright 2020 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "modules/skottie/src/Adapter.h" #include "modules/skottie/src/SkottieJson.h" #include "modules/skottie/src/SkottiePriv.h" #include "modules/skottie/src/SkottieValue.h" #include "modules/skottie/src/layers/shapelayer/ShapeLayer.h" #include "modules/sksg/include/SkSGGeometryEffect.h" namespace skottie { namespace internal { namespace { class RoundCornersAdapter final : public DiscardableAdapterBase { public: RoundCornersAdapter(const skjson::ObjectValue& jround, const AnimationBuilder& abuilder, sk_sp child) : INHERITED(sksg::RoundEffect::Make(std::move(child))) { this->bind(abuilder, jround["r"], fRadius); } private: void onSync() override { this->node()->setRadius(fRadius); } ScalarValue fRadius = 0; using INHERITED = DiscardableAdapterBase; }; } // namespace std::vector> ShapeBuilder::AttachRoundGeometryEffect( const skjson::ObjectValue& jround, const AnimationBuilder* abuilder, std::vector>&& geos) { std::vector> rounded; rounded.reserve(geos.size()); for (auto& g : geos) { rounded.push_back( abuilder->attachDiscardableAdapter (jround, *abuilder, std::move(g))); } return rounded; } } // namespace internal } // namespace skottie