• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_KEYFRAME_ANIMATION_H
17 #define RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_KEYFRAME_ANIMATION_H
18 
19 #include <memory>
20 
21 #include "animation/rs_animation_common.h"
22 #include "animation/rs_animation_timing_curve.h"
23 #include "animation/rs_property_animation.h"
24 
25 namespace OHOS {
26 namespace Rosen {
27 static constexpr int FRACTION_INDEX = 0;
28 static constexpr int VALUE_INDEX = 1;
29 static constexpr int INTERPOLATOR_INDEX = 2;
30 
31 class RSRenderKeyframeAnimation;
32 
33 class RSC_EXPORT RSKeyframeAnimation : public RSPropertyAnimation {
34 public:
35     RSKeyframeAnimation(std::shared_ptr<RSPropertyBase> property);
36     virtual ~RSKeyframeAnimation() = default;
37 
38     void AddKeyFrame(float fraction, const std::shared_ptr<RSPropertyBase>& value,
39         const RSAnimationTimingCurve& timingCurve);
40 
41     void AddKeyFrames(const
42         std::vector<std::tuple<float, std::shared_ptr<RSPropertyBase>, RSAnimationTimingCurve>>& keyframes);
43 
44 protected:
45     void OnStart() override;
46 
47     void InitInterpolationValue() override;
48 
49 private:
50     void StartRenderAnimation(const std::shared_ptr<RSRenderKeyframeAnimation>& animation);
51 
52     void StartUIAnimation(const std::shared_ptr<RSRenderKeyframeAnimation>& animation);
53 
54     std::vector<std::tuple<float, std::shared_ptr<RSPropertyBase>, RSAnimationTimingCurve>> keyframes_;
55 
56     friend class RSImplicitKeyframeAnimationParam;
57 };
58 } // namespace Rosen
59 } // namespace OHOS
60 
61 #endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_KEYFRAME_ANIMATION_H
62