• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 
16 #ifndef RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_ANIMATION_TIMING_CURVE_H
17 #define RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_ANIMATION_TIMING_CURVE_H
18 
19 #include <functional>
20 #include <map>
21 
22 #include "common/rs_macros.h"
23 
24 namespace OHOS {
25 namespace Rosen {
26 class RSInterpolator;
27 
28 class RS_EXPORT RSAnimationTimingCurve final {
29 public:
30     static const RSAnimationTimingCurve DEFAULT;
31 
32     static const RSAnimationTimingCurve LINEAR;
33 
34     static const RSAnimationTimingCurve EASE;
35 
36     static const RSAnimationTimingCurve EASE_IN;
37 
38     static const RSAnimationTimingCurve EASE_OUT;
39 
40     static const RSAnimationTimingCurve EASE_IN_OUT;
41 
42     static RSAnimationTimingCurve CreateCustomCurve(const std::function<float(float)>& customCurveFunc);
43 
44     static RSAnimationTimingCurve CreateCubicCurve(float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2);
45 
46     static RSAnimationTimingCurve CreateSpringCurve(float velocity, float mass, float stiffness, float damping);
47 
48     RSAnimationTimingCurve();
49     RSAnimationTimingCurve(const RSAnimationTimingCurve& timingCurve) = default;
50     RSAnimationTimingCurve& operator=(const RSAnimationTimingCurve& timingCurve) = default;
51     virtual ~RSAnimationTimingCurve() = default;
52 
53 private:
54     RSAnimationTimingCurve(const std::shared_ptr<RSInterpolator>& interpolator);
55     RSAnimationTimingCurve(const std::function<float(float)>& customCurveFunc);
56 
57     std::shared_ptr<RSInterpolator> GetInterpolator(int duration) const;
58 
59     std::shared_ptr<RSInterpolator> interpolator_;
60     std::function<float(float)> customCurveFunc_;
61 
62     template<typename T>
63     friend class RSCurveAnimation;
64     template<typename T>
65     friend class RSKeyframeAnimation;
66     friend class RSPathAnimation;
67     friend class RSTransition;
68 };
69 } // namespace Rosen
70 } // namespace OHOS
71 
72 #endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_ANIMATION_TIMING_CURVE_H
73