• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 #ifndef UIEFFECT_EFFECT_SHADOW_BLENDER_H
16 #define UIEFFECT_EFFECT_SHADOW_BLENDER_H
17 
18 #include "blender.h"
19 #include "ui_effect/utils.h"
20 
21 namespace OHOS {
22 namespace Rosen {
23 constexpr std::pair<float, float> SHADOW_BLENDER_LIMITS {-100.f, 100.f};
24 
25 class ShadowBlender : public Blender {
26 public:
ShadowBlender()27     ShadowBlender()
28     {
29         this->blenderType_ = Blender::SHADOW_BLENDER;
30     }
31     ~ShadowBlender() override = default;
32 
SetCubicCoeff(float cubic)33     void SetCubicCoeff(float cubic)
34     {
35         cubic_ = UIEffect::GetLimitedPara(cubic, SHADOW_BLENDER_LIMITS);
36     }
37 
GetCubicCoeff()38     float GetCubicCoeff() const
39     {
40         return cubic_;
41     }
42 
SetQuadraticCoeff(float quadratic)43     void SetQuadraticCoeff(float quadratic)
44     {
45         quadratic_ = UIEffect::GetLimitedPara(quadratic, SHADOW_BLENDER_LIMITS);
46     }
47 
GetQuadraticCoeff()48     float GetQuadraticCoeff() const
49     {
50         return quadratic_;
51     }
52 
SetLinearCoeff(float linear)53     void SetLinearCoeff(float linear)
54     {
55         linear_ = UIEffect::GetLimitedPara(linear, SHADOW_BLENDER_LIMITS);
56     }
57 
GetLinearCoeff()58     float GetLinearCoeff() const
59     {
60         return linear_;
61     }
62 
SetConstantTerm(float constant)63     void SetConstantTerm(float constant)
64     {
65         constant_ = UIEffect::GetLimitedPara(constant, SHADOW_BLENDER_LIMITS);
66     }
67 
GetConstantTerm()68     float GetConstantTerm() const
69     {
70         return constant_;
71     }
72 
73 private:
74     float cubic_ = 0.0f;
75     float quadratic_ = 0.0f;
76     float linear_ = 0.0f;
77     float constant_ = 0.0f;
78 };
79 } // namespace Rosen
80 } // namespace OHOS
81 #endif // UIEFFECT_EFFECT_SHADOW_BLENDER_H
82