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 #ifndef FOUNDATION_ACE_FRAMEWORKS_COMPONENTS_NG_RENDER_ADAPTER_ROSEN_MODIFIER_PROPERTY_H
17 #define FOUNDATION_ACE_FRAMEWORKS_COMPONENTS_NG_RENDER_ADAPTER_ROSEN_MODIFIER_PROPERTY_H
18 
19 #include "render_service_client/core/modifier/rs_property_modifier.h"
20 #include "render_service_client/core/ui/rs_node.h"
21 
22 namespace OHOS::Ace::NG {
23 template<typename T>
24 bool CreateOrSetModifierValue(std::shared_ptr<Rosen::RSAnimatableProperty<T>>& property, const T& value);
25 
26 void AddOrChangeScaleModifier(std::shared_ptr<Rosen::RSNode>& rsNode,
27     std::shared_ptr<Rosen::RSScaleModifier>& modifier,
28     std::shared_ptr<Rosen::RSAnimatableProperty<Rosen::Vector2f>>& property, const Rosen::Vector2f& value);
29 
30 void AddOrChangeSkewModifier(std::shared_ptr<Rosen::RSNode>& rsNode,
31     std::shared_ptr<Rosen::RSSkewModifier>& modifier,
32     std::shared_ptr<Rosen::RSAnimatableProperty<Rosen::Vector2f>>& property, const Rosen::Vector2f& value);
33 
34 void AddOrChangeTranslateZModifier(std::shared_ptr<Rosen::RSNode>& rsNode,
35     std::shared_ptr<Rosen::RSTranslateZModifier>& modifier,
36     std::shared_ptr<Rosen::RSAnimatableProperty<float>>& property, const float value);
37 
38 void AddOrChangePerspectiveModifier(std::shared_ptr<Rosen::RSNode>& rsNode,
39     std::shared_ptr<Rosen::RSPerspModifier>& modifier,
40     std::shared_ptr<Rosen::RSAnimatableProperty<Rosen::Vector2f>>& property, const Rosen::Vector2f& value);
41 
42 void AddOrChangeTranslateModifier(std::shared_ptr<Rosen::RSNode>& rsNode,
43     std::shared_ptr<Rosen::RSTranslateModifier>& modifier,
44     std::shared_ptr<Rosen::RSAnimatableProperty<Rosen::Vector2f>>& property, const Rosen::Vector2f& value);
45 
46 void AddOrChangeQuaternionModifier(std::shared_ptr<Rosen::RSNode>& rsNode,
47     std::shared_ptr<Rosen::RSQuaternionModifier>& modifier,
48     std::shared_ptr<Rosen::RSAnimatableProperty<Rosen::Quaternion>>& property, const Rosen::Quaternion& value);
49 
50 void AddOrChangePivotModifier(std::shared_ptr<Rosen::RSNode>& rsNode,
51     std::shared_ptr<Rosen::RSPivotModifier>& modifier,
52     std::shared_ptr<Rosen::RSAnimatableProperty<Rosen::Vector2f>>& property, const Rosen::Vector2f& value);
53 
54 struct TransformMatrixModifier {
55     std::shared_ptr<Rosen::RSPerspModifier> perspectiveXY;
56     std::shared_ptr<Rosen::RSTranslateModifier> translateXY;
57     std::shared_ptr<Rosen::RSTranslateZModifier> translateZ;
58     std::shared_ptr<Rosen::RSScaleModifier> scaleXY;
59     std::shared_ptr<Rosen::RSSkewModifier> skewXY;
60     std::shared_ptr<Rosen::RSPivotModifier> pivotXY;
61     std::shared_ptr<Rosen::RSQuaternionModifier> quaternion;
62     std::shared_ptr<Rosen::RSAnimatableProperty<Rosen::Vector2f>> perspectiveXYValue;
63     std::shared_ptr<Rosen::RSAnimatableProperty<Rosen::Vector2f>> translateXYValue;
64     std::shared_ptr<Rosen::RSAnimatableProperty<float>> translateZValue;
65     std::shared_ptr<Rosen::RSAnimatableProperty<Rosen::Vector2f>> scaleXYValue;
66     std::shared_ptr<Rosen::RSAnimatableProperty<Rosen::Vector2f>> skewXYValue;
67     std::shared_ptr<Rosen::RSAnimatableProperty<Rosen::Vector2f>> pivotXYValue;
68     std::shared_ptr<Rosen::RSAnimatableProperty<Rosen::Quaternion>> quaternionValue;
69 };
70 
71 struct SharedTransitionModifier {
72     std::shared_ptr<Rosen::RSTranslateModifier> translateXY;
73     std::shared_ptr<Rosen::RSAnimatableProperty<Rosen::Vector2f>> translateXYValue;
74 };
75 
76 struct WindowBlurModifier {
77     std::shared_ptr<Rosen::RSBehindWindowFilterRadiusModifier> radius;
78     std::shared_ptr<Rosen::RSBehindWindowFilterSaturationModifier> saturation;
79     std::shared_ptr<Rosen::RSBehindWindowFilterBrightnessModifier> brightness;
80     std::shared_ptr<Rosen::RSBehindWindowFilterMaskColorModifier> maskColor;
81 
82     std::shared_ptr<Rosen::RSAnimatableProperty<float>> radiusValue;
83     std::shared_ptr<Rosen::RSAnimatableProperty<float>> saturationValue;
84     std::shared_ptr<Rosen::RSAnimatableProperty<float>> brightnessValue;
85     std::shared_ptr<Rosen::RSAnimatableProperty<Rosen::RSColor>> maskColorValue;
86 
87     static void AddOrChangeRadiusModifier(std::shared_ptr<Rosen::RSNode>& rsNode,
88     std::shared_ptr<Rosen::RSBehindWindowFilterRadiusModifier>& modifier,
89     std::shared_ptr<Rosen::RSAnimatableProperty<float>>& property, const float& value);
90     static void AddOrChangeSaturationModifier(std::shared_ptr<Rosen::RSNode>& rsNode,
91     std::shared_ptr<Rosen::RSBehindWindowFilterSaturationModifier>& modifier,
92     std::shared_ptr<Rosen::RSAnimatableProperty<float>>& property, const float& value);
93     static void AddOrChangeBrightnessModifier(std::shared_ptr<Rosen::RSNode>& rsNode,
94     std::shared_ptr<Rosen::RSBehindWindowFilterBrightnessModifier>& modifier,
95     std::shared_ptr<Rosen::RSAnimatableProperty<float>>& property, const float& value);
96     static void AddOrChangeMaskColorModifier(std::shared_ptr<Rosen::RSNode>& rsNode,
97     std::shared_ptr<Rosen::RSBehindWindowFilterMaskColorModifier>& modifier,
98     std::shared_ptr<Rosen::RSAnimatableProperty<Rosen::RSColor>>& property, const Rosen::RSColor& value);
99 };
100 } // namespace OHOS::Ace::NG
101 
102 #endif // FOUNDATION_ACE_FRAMEWORKS_COMPONENTS_NG_RENDER_ADAPTER_ROSEN_MODIFIER_PROPERTY_H