• 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_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     void DumpAnimationInfo(std::string& dumpInfo) const override;
36 
GetPropertyType()37     ModifierNG::RSPropertyType GetPropertyType() const override
38     {
39         return property_ ? property_->GetPropertyTypeNG() : ModifierNG::RSPropertyType::INVALID;
40     }
41 
42 protected:
43     RSPropertyAnimation(std::shared_ptr<RSPropertyBase> property);
44 
45     void SetAdditive(bool isAdditive);
46 
47     bool GetAdditive() const;
48 
49     const std::shared_ptr<RSPropertyBase> GetOriginValue() const;
50 
51     void SetPropertyValue(const std::shared_ptr<RSPropertyBase>& value);
52 
53     const std::shared_ptr<RSPropertyBase> GetPropertyValue() const;
54 
55     PropertyId GetPropertyId() const override;
56 
57     void OnStart() override;
58 
59     void SetOriginValue(const std::shared_ptr<RSPropertyBase>& originValue);
60 
61     virtual void InitInterpolationValue();
62 
63     void OnUpdateStagingValue(bool isFirstStart) override;
64 
65     void UpdateStagingValueOnInteractiveFinish(RSInteractiveAnimationPosition pos) override;
66 
67     void SetPropertyOnAllAnimationFinish() override;
68 
69     std::shared_ptr<RSPropertyBase> property_;
70     std::shared_ptr<RSPropertyBase> byValue_ {};
71     std::shared_ptr<RSPropertyBase> startValue_ {};
72     std::shared_ptr<RSPropertyBase> endValue_ {};
73     std::shared_ptr<RSPropertyBase> originValue_ {};
74     bool isAdditive_ { true };
75     bool isCustom_ { false };
76     bool isDelta_ { false };
77     bool hasOriginValue_ { false };
78 
79 private:
80     void InitAdditiveMode();
81 };
82 } // namespace Rosen
83 } // namespace OHOS
84 
85 #endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_PROPERTY_ANIMATION_H
86