• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 #include "modifier/rs_property_modifier.h"
17 
18 #include "modifier/rs_modifier_type.h"
19 #include "modifier/rs_render_modifier.h"
20 
21 namespace OHOS {
22 namespace Rosen {
23 
RSEnvForegroundColorModifier(const std::shared_ptr<RSPropertyBase> & property)24 RSEnvForegroundColorModifier::RSEnvForegroundColorModifier(const std::shared_ptr<RSPropertyBase>& property)
25     : RSForegroundModifier(property, RSModifierType::ENV_FOREGROUND_COLOR)
26 {}
GetModifierType() const27 RSModifierType RSEnvForegroundColorModifier::GetModifierType() const
28 {
29     return RSModifierType::ENV_FOREGROUND_COLOR;
30 }
CreateRenderModifier() const31 std::shared_ptr<RSRenderModifier> RSEnvForegroundColorModifier::CreateRenderModifier() const
32 {
33     auto renderProperty = GetRenderProperty();
34     auto renderModifier = std::make_shared<RSEnvForegroundColorRenderModifier>(renderProperty);
35     return renderModifier;
36 }
37 
RSEnvForegroundColorStrategyModifier(const std::shared_ptr<RSPropertyBase> & property)38 RSEnvForegroundColorStrategyModifier::RSEnvForegroundColorStrategyModifier(
39     const std::shared_ptr<RSPropertyBase>& property)
40     : RSForegroundModifier(property, RSModifierType::ENV_FOREGROUND_COLOR_STRATEGY)
41 {}
GetModifierType() const42 RSModifierType RSEnvForegroundColorStrategyModifier::GetModifierType() const
43 {
44     return RSModifierType::ENV_FOREGROUND_COLOR_STRATEGY;
45 }
CreateRenderModifier() const46 std::shared_ptr<RSRenderModifier> RSEnvForegroundColorStrategyModifier::CreateRenderModifier() const
47 {
48     auto renderProperty = GetRenderProperty();
49     auto renderModifier = std::make_shared<RSEnvForegroundColorStrategyRenderModifier>(renderProperty);
50     return renderModifier;
51 }
52 
53 #define DECLARE_ANIMATABLE_MODIFIER_CREATE(MODIFIER_NAME)                                          \
54     std::shared_ptr<RSRenderModifier> RS##MODIFIER_NAME##Modifier::CreateRenderModifier() const    \
55     {                                                                                              \
56         auto renderProperty = GetRenderProperty();                                                 \
57         auto renderModifier = std::make_shared<RS##MODIFIER_NAME##RenderModifier>(renderProperty); \
58         return renderModifier;                                                                     \
59     }
60 
61 #define DECLARE_ANIMATABLE_MODIFIER(MODIFIER_NAME, TYPE, MODIFIER_TYPE, DELTA_OP, MODIFIER_TIER, THRESHOLD_TYPE) \
62     RS##MODIFIER_NAME##Modifier::RS##MODIFIER_NAME##Modifier(const std::shared_ptr<RSPropertyBase>& property)    \
63         : RS##MODIFIER_TIER##Modifier(property, RSModifierType::MODIFIER_TYPE)                                   \
64     {                                                                                                            \
65         property_->SetThresholdType(ThresholdType::THRESHOLD_TYPE);                                              \
66     }                                                                                                            \
67     RSModifierType RS##MODIFIER_NAME##Modifier::GetModifierType() const                                          \
68     {                                                                                                            \
69         return RSModifierType::MODIFIER_TYPE;                                                                    \
70     }                                                                                                            \
71     DECLARE_ANIMATABLE_MODIFIER_CREATE(MODIFIER_NAME)
72 
73 #define DECLARE_NOANIMATABLE_MODIFIER_CREATE(MODIFIER_NAME)                                        \
74     std::shared_ptr<RSRenderModifier> RS##MODIFIER_NAME##Modifier::CreateRenderModifier() const    \
75     {                                                                                              \
76         auto renderProperty = GetRenderProperty();                                                 \
77         auto renderModifier = std::make_shared<RS##MODIFIER_NAME##RenderModifier>(renderProperty); \
78         return renderModifier;                                                                     \
79     }
80 
81 #define DECLARE_NOANIMATABLE_MODIFIER(MODIFIER_NAME, TYPE, MODIFIER_TYPE, MODIFIER_TIER)                            \
82     RS##MODIFIER_NAME##Modifier::RS##MODIFIER_NAME##Modifier(const std::shared_ptr<RSPropertyBase>& property)       \
83         : RS##MODIFIER_TIER##Modifier(property, RSModifierType::MODIFIER_TYPE)                                      \
84     {}                                                                                                              \
85     RSModifierType RS##MODIFIER_NAME##Modifier::GetModifierType() const                                             \
86     {                                                                                                               \
87         return RSModifierType::MODIFIER_TYPE;                                                                       \
88     }                                                                                                               \
89     DECLARE_NOANIMATABLE_MODIFIER_CREATE(MODIFIER_NAME)
90 
91 #include "modifier/rs_modifiers_def.in"
92 
93 #undef DECLARE_ANIMATABLE_MODIFIER
94 #undef DECLARE_NOANIMATABLE_MODIFIER
95 } // namespace Rosen
96 } // namespace OHOS
97