1 /*
2  * Copyright (c) 2023 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 ANIMATION_CURVE_H
17 #define ANIMATION_CURVE_H
18 
19 #include <string>
20 #include <unordered_map>
21 #include <vector>
22 #include <functional>
23 #include "animation/rs_animation_timing_curve.h"
24 
25 namespace OHOS {
26 namespace Msdp {
27 namespace DeviceStatus {
28 namespace {
29 using RosenCurveType = OHOS::Rosen::RSAnimationTimingCurve;
30 }
31 
32 class AnimationCurve {
33 public:
34     using CurveCreator = std::function<RosenCurveType(const std::vector<float> &)>;
35     static RosenCurveType CreateCurve(const std::string &curveName, const std::vector<float> &curve);
36 private:
37     static RosenCurveType CreateCubicCurve(const std::vector<float> &curve);
38     static RosenCurveType CreateSpringCurve(const std::vector<float> &curve);
39     static RosenCurveType CreateInterpolatingSpring(const std::vector<float> &curve);
40     static RosenCurveType CreateResponseSpring(const std::vector<float> &curve);
41     static RosenCurveType CreateStepsCurve(const std::vector<float> &curve);
42 private:
43     static std::unordered_map<std::string, RosenCurveType> specialCurveMap_;
44     static std::unordered_map<std::string, CurveCreator> curveMap_;
45 };
46 
47 } // namespace DeviceStatus
48 } // namespace Msdp
49 } // namespace OHOS
50 #endif // ANIMATION_CURVE_H