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_PROPERTY_ANIMATION_H
17 #define RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_PROPERTY_ANIMATION_H
18 
19 #include <memory>
20 
21 #include "animation/rs_animation.h"
22 #include "common/rs_macros.h"
23 
24 namespace OHOS {
25 namespace Rosen {
26 class RSPropertyBase;
27 
28 class RSC_EXPORT RSPropertyAnimation : public RSAnimation {
29 public:
30     RSPropertyAnimation() = delete;
31     virtual ~RSPropertyAnimation() = default;
32 
33     void SetIsCustom(const bool isCustom);
34 
35 protected:
36     RSPropertyAnimation(std::shared_ptr<RSPropertyBase> property);
37 
38     void SetAdditive(bool isAdditive);
39 
40     bool GetAdditive() const;
41 
42     const std::shared_ptr<RSPropertyBase> GetOriginValue() const;
43 
44     void SetPropertyValue(const std::shared_ptr<RSPropertyBase>& value);
45 
46     const std::shared_ptr<RSPropertyBase> GetPropertyValue() const;
47 
48     PropertyId GetPropertyId() const override;
49 
50     void OnStart() override;
51 
52     void SetOriginValue(const std::shared_ptr<RSPropertyBase>& originValue);
53 
54     virtual void InitInterpolationValue();
55 
56     void OnUpdateStagingValue(bool isFirstStart) override;
57 
58     void UpdateStagingValueOnInteractiveFinish(RSInteractiveAnimationPosition pos) override;
59 
60     void SetPropertyOnAllAnimationFinish() override;
61 
62     std::shared_ptr<RSPropertyBase> property_;
63     std::shared_ptr<RSPropertyBase> byValue_ {};
64     std::shared_ptr<RSPropertyBase> startValue_ {};
65     std::shared_ptr<RSPropertyBase> endValue_ {};
66     std::shared_ptr<RSPropertyBase> originValue_ {};
67     bool isAdditive_ { true };
68     bool isCustom_ { false };
69     bool isDelta_ { false };
70     bool hasOriginValue_ { false };
71 
72 private:
73     void InitAdditiveMode();
74 };
75 } // namespace Rosen
76 } // namespace OHOS
77 
78 #endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_PROPERTY_ANIMATION_H
79