| 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 | |
| 8 | #ifndef SkottieShapeLayer_DEFINED |
| 9 | #define SkottieShapeLayer_DEFINED |
| 10 | |
| 11 | #include "include/private/SkNoncopyable.h" |
| 12 | #include "modules/skottie/src/animator/Animator.h" |
| 13 | #include "modules/sksg/include/SkSGMerge.h" |
| 14 | |
| 15 | #include <vector> |
| 16 | |
| 17 | namespace skjson { |
| 18 | |
| 19 | class ObjectValue; |
| 20 | |
| 21 | } // namespace skjson |
| 22 | |
| 23 | namespace sksg { |
| 24 | |
| 25 | class GeometryNode; |
| 26 | class PaintNode; |
| 27 | class RenderNode; |
| 28 | |
| 29 | } // namespace sksg |
| 30 | |
| 31 | namespace skottie { |
| 32 | namespace internal { |
| 33 | |
| 34 | class AnimationBuilder; |
| 35 | |
| 36 | // TODO/TRANSITIONAL: not much state here yet, but will eventually hold ShapeLayer-related stuff. |
| 37 | class ShapeBuilder final : SkNoncopyable { |
| 38 | public: |
| 39 | static sk_sp<sksg::Merge> MergeGeometry(std::vector<sk_sp<sksg::GeometryNode>>&&, |
| 40 | sksg::Merge::Mode); |
| 41 | |
| 42 | static sk_sp<sksg::GeometryNode> AttachPathGeometry(const skjson::ObjectValue&, |
| 43 | const AnimationBuilder*); |
| 44 | static sk_sp<sksg::GeometryNode> AttachRRectGeometry(const skjson::ObjectValue&, |
| 45 | const AnimationBuilder*); |
| 46 | static sk_sp<sksg::GeometryNode> AttachEllipseGeometry(const skjson::ObjectValue&, |
| 47 | const AnimationBuilder*); |
| 48 | static sk_sp<sksg::GeometryNode> AttachPolystarGeometry(const skjson::ObjectValue&, |
| 49 | const AnimationBuilder*); |
| 50 | |
| 51 | static sk_sp<sksg::PaintNode> AttachColorFill(const skjson::ObjectValue&, |
| 52 | const AnimationBuilder*); |
| 53 | static sk_sp<sksg::PaintNode> AttachColorStroke(const skjson::ObjectValue&, |
| 54 | const AnimationBuilder*); |
| 55 | static sk_sp<sksg::PaintNode> AttachGradientFill(const skjson::ObjectValue&, |
| 56 | const AnimationBuilder*); |
| 57 | static sk_sp<sksg::PaintNode> AttachGradientStroke(const skjson::ObjectValue&, |
| 58 | const AnimationBuilder*); |
| 59 | |
| 60 | static std::vector<sk_sp<sksg::GeometryNode>> AttachMergeGeometryEffect( |
| 61 | const skjson::ObjectValue&, const AnimationBuilder*, |
| 62 | std::vector<sk_sp<sksg::GeometryNode>>&&); |
| 63 | static std::vector<sk_sp<sksg::GeometryNode>> AttachTrimGeometryEffect( |
| 64 | const skjson::ObjectValue&, |
| 65 | const AnimationBuilder*, |
| 66 | std::vector<sk_sp<sksg::GeometryNode>>&&); |
| 67 | static std::vector<sk_sp<sksg::GeometryNode>> AttachRoundGeometryEffect( |
| 68 | const skjson::ObjectValue&, const AnimationBuilder*, |
| 69 | std::vector<sk_sp<sksg::GeometryNode>>&&); |
| 70 | static std::vector<sk_sp<sksg::GeometryNode>> AdjustStrokeGeometry( |
| 71 | const skjson::ObjectValue&, const AnimationBuilder*, |
| 72 | std::vector<sk_sp<sksg::GeometryNode>>&&); |
| 73 | |
| 74 | static std::vector<sk_sp<sksg::RenderNode>> AttachRepeaterDrawEffect( |
| 75 | const skjson::ObjectValue&, |
| 76 | const AnimationBuilder*, |
| 77 | std::vector<sk_sp<sksg::RenderNode>>&&); |
| 78 | |
| 79 | private: |
| 80 | static sk_sp<sksg::PaintNode> AttachFill(const skjson::ObjectValue&, |
| 81 | const AnimationBuilder*, |
| 82 | sk_sp<sksg::PaintNode>, |
| 83 | sk_sp<AnimatablePropertyContainer> = nullptr); |
| 84 | static sk_sp<sksg::PaintNode> AttachStroke(const skjson::ObjectValue&, |
| 85 | const AnimationBuilder*, |
| 86 | sk_sp<sksg::PaintNode>, |
| 87 | sk_sp<AnimatablePropertyContainer> = nullptr); |
| 88 | }; |
| 89 | |
| 90 | } // namespace internal |
| 91 | } // namespace skottie |
| 92 | |
| 93 | #endif // SkottieShapeLayer_DEFINED |
| 94 | |