1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include <meta/base/namespace.h>
16 #include <meta/interface/animation/builtin_animations.h>
17 #include <meta/interface/intf_object.h>
18 #include <meta/interface/intf_object_registry.h>
19 
20 #include "animation/animation_controller.h"
21 #include "animation/interpolator.h"
22 #include "animation/keyframe_animation.h"
23 #include "animation/modifiers/loop.h"
24 #include "animation/modifiers/reverse.h"
25 #include "animation/modifiers/speed.h"
26 #include "animation/parallel_animation.h"
27 #include "animation/property_animation.h"
28 #include "animation/sequential_animation.h"
29 #include "animation/track_animation.h"
30 #include "curves/bezier_curve.h"
31 #include "curves/easing_curve.h"
32 
33 META_BEGIN_NAMESPACE()
34 
35 namespace Internal {
36 
37 #define DECL_NO(A, B) { ObjectTypeInfo::UID }, ClassId::A, (B)
38 #define DECL_AN(A, B) { ObjectTypeInfo::UID }, ClassId::A, (B)
39 
40 static constexpr ObjectTypeInfo OBJECTS[] = {
41     AnimationController::OBJECT_INFO,
42     KeyframeAnimation::OBJECT_INFO,
43     PropertyAnimation::OBJECT_INFO,
44     TrackAnimation::OBJECT_INFO,
45     ParallelAnimation::OBJECT_INFO,
46     SequentialAnimation::OBJECT_INFO,
47     AnimationModifiers::Loop::OBJECT_INFO,
48     AnimationModifiers::Reverse::OBJECT_INFO,
49     AnimationModifiers::SpeedImpl::OBJECT_INFO,
50 
51     Curves::Easing::LinearEasingCurve::OBJECT_INFO,
52     Curves::Easing::InQuadEasingCurve::OBJECT_INFO,
53     Curves::Easing::OutQuadEasingCurve::OBJECT_INFO,
54     Curves::Easing::InOutQuadEasingCurve::OBJECT_INFO,
55     Curves::Easing::InCubicEasingCurve::OBJECT_INFO,
56     Curves::Easing::OutCubicEasingCurve::OBJECT_INFO,
57     Curves::Easing::InOutCubicEasingCurve::OBJECT_INFO,
58     Curves::Easing::InSineEasingCurve::OBJECT_INFO,
59     Curves::Easing::OutSineEasingCurve::OBJECT_INFO,
60     Curves::Easing::InOutSineEasingCurve::OBJECT_INFO,
61     Curves::Easing::InQuartEasingCurve::OBJECT_INFO,
62     Curves::Easing::OutQuartEasingCurve::OBJECT_INFO,
63     Curves::Easing::InOutQuartEasingCurve::OBJECT_INFO,
64     Curves::Easing::InQuintEasingCurve::OBJECT_INFO,
65     Curves::Easing::OutQuintEasingCurve::OBJECT_INFO,
66     Curves::Easing::InOutQuintEasingCurve::OBJECT_INFO,
67     Curves::Easing::InExpoEasingCurve::OBJECT_INFO,
68     Curves::Easing::OutExpoEasingCurve::OBJECT_INFO,
69     Curves::Easing::InOutExpoEasingCurve::OBJECT_INFO,
70     Curves::Easing::InCircEasingCurve::OBJECT_INFO,
71     Curves::Easing::OutCircEasingCurve::OBJECT_INFO,
72     Curves::Easing::InOutCircEasingCurve::OBJECT_INFO,
73     Curves::Easing::InBackEasingCurve::OBJECT_INFO,
74     Curves::Easing::OutBackEasingCurve::OBJECT_INFO,
75     Curves::Easing::InOutBackEasingCurve::OBJECT_INFO,
76     Curves::Easing::InElasticEasingCurve::OBJECT_INFO,
77     Curves::Easing::OutElasticEasingCurve::OBJECT_INFO,
78     Curves::Easing::InOutElasticEasingCurve::OBJECT_INFO,
79     Curves::Easing::InBounceEasingCurve::OBJECT_INFO,
80     Curves::Easing::OutBounceEasingCurve::OBJECT_INFO,
81     Curves::Easing::InOutBounceEasingCurve::OBJECT_INFO,
82     Curves::Easing::StepStartEasingCurve::OBJECT_INFO,
83     Curves::Easing::StepEndEasingCurve::OBJECT_INFO,
84     Curves::Easing::CubicBezierEasingCurve::OBJECT_INFO,
85 };
86 
RegisterBuiltInAnimations(IObjectRegistry & registry)87 void RegisterBuiltInAnimations(IObjectRegistry& registry)
88 {
89     for (auto& t : OBJECTS) {
90         registry.RegisterObjectType(t.GetFactory());
91     }
92 
93     RegisterDefaultInterpolators(registry);
94 }
UnRegisterBuiltInAnimations(IObjectRegistry & registry)95 void UnRegisterBuiltInAnimations(IObjectRegistry& registry)
96 {
97     for (auto& t : OBJECTS) {
98         registry.UnregisterObjectType(t.GetFactory());
99     }
100 
101     UnRegisterDefaultInterpolators(registry);
102 }
103 } // namespace Internal
104 META_END_NAMESPACE()
105