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) \
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 RSModifierType RS##MODIFIER_NAME##Modifier::GetModifierType() const \
66 { \
67 return RSModifierType::MODIFIER_TYPE; \
68 } \
69 DECLARE_ANIMATABLE_MODIFIER_CREATE(MODIFIER_NAME)
70
71 #define DECLARE_NOANIMATABLE_MODIFIER_CREATE(MODIFIER_NAME) \
72 std::shared_ptr<RSRenderModifier> RS##MODIFIER_NAME##Modifier::CreateRenderModifier() const \
73 { \
74 auto renderProperty = GetRenderProperty(); \
75 auto renderModifier = std::make_shared<RS##MODIFIER_NAME##RenderModifier>(renderProperty); \
76 return renderModifier; \
77 }
78
79 #define DECLARE_NOANIMATABLE_MODIFIER(MODIFIER_NAME, TYPE, MODIFIER_TYPE, MODIFIER_TIER) \
80 RS##MODIFIER_NAME##Modifier::RS##MODIFIER_NAME##Modifier(const std::shared_ptr<RSPropertyBase>& property) \
81 : RS##MODIFIER_TIER##Modifier(property, RSModifierType::MODIFIER_TYPE) \
82 {} \
83 RSModifierType RS##MODIFIER_NAME##Modifier::GetModifierType() const \
84 { \
85 return RSModifierType::MODIFIER_TYPE; \
86 } \
87 DECLARE_NOANIMATABLE_MODIFIER_CREATE(MODIFIER_NAME)
88
89 #include "modifier/rs_modifiers_def.in"
90
91 #undef DECLARE_ANIMATABLE_MODIFIER
92 #undef DECLARE_NOANIMATABLE_MODIFIER
93 } // namespace Rosen
94 } // namespace OHOS
95