• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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>> AttachOffsetGeometryEffect(
71             const skjson::ObjectValue&, const AnimationBuilder*,
72             std::vector<sk_sp<sksg::GeometryNode>>&&);
73     static std::vector<sk_sp<sksg::GeometryNode>> AttachPuckerBloatGeometryEffect(
74             const skjson::ObjectValue&, const AnimationBuilder*,
75             std::vector<sk_sp<sksg::GeometryNode>>&&);
76     static std::vector<sk_sp<sksg::GeometryNode>> AdjustStrokeGeometry(
77             const skjson::ObjectValue&, const AnimationBuilder*,
78             std::vector<sk_sp<sksg::GeometryNode>>&&);
79 
80     static std::vector<sk_sp<sksg::RenderNode>> AttachRepeaterDrawEffect(
81             const skjson::ObjectValue&,
82             const AnimationBuilder*,
83             std::vector<sk_sp<sksg::RenderNode>>&&);
84 
85 private:
86     static sk_sp<sksg::PaintNode> AttachFill(const skjson::ObjectValue&,
87                                              const AnimationBuilder*,
88                                              sk_sp<sksg::PaintNode>,
89                                              sk_sp<AnimatablePropertyContainer> = nullptr);
90     static sk_sp<sksg::PaintNode> AttachStroke(const skjson::ObjectValue&,
91                                                const AnimationBuilder*,
92                                                sk_sp<sksg::PaintNode>,
93                                                sk_sp<AnimatablePropertyContainer> = nullptr);
94 };
95 
96 } // namespace internal
97 } // namespace skottie
98 
99 #endif // SkottieShapeLayer_DEFINED
100