• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 GRAPHICS_EFFECT_GE_GRADIENT_BLUR_PARA_H
16 #define GRAPHICS_EFFECT_GE_GRADIENT_BLUR_PARA_H
17 
18 #include <array>
19 
20 #include "ge_kawase_blur_shader_filter.h"
21 #include "ge_shader_filter.h"
22 #include "ge_visual_effect.h"
23 
24 namespace OHOS {
25 namespace Rosen {
26 
27 enum class GEGradientDirection {
28     LEFT = 0,
29     TOP,
30     RIGHT,
31     BOTTOM,
32     LEFT_TOP,
33     LEFT_BOTTOM,
34     RIGHT_TOP,
35     RIGHT_BOTTOM,
36     NONE,
37     START_TO_END,
38     END_TO_START
39 };
40 
41 class GELinearGradientBlurPara {
42 public:
GELinearGradientBlurPara(const float blurRadius,const std::vector<std::pair<float,float>> fractionStops,const GEGradientDirection direction,const bool maskLinearBlurEnabled)43     explicit GELinearGradientBlurPara(const float blurRadius, const std::vector<std::pair<float, float>> fractionStops,
44         const GEGradientDirection direction, const bool maskLinearBlurEnabled)
45         : blurRadius_(blurRadius), fractionStops_(fractionStops), direction_(direction)
46     {
47         if (maskLinearBlurEnabled) {
48             auto kawaseParams = std::make_shared<Drawing::GEKawaseBlurShaderFilterParams>();
49             kawaseParams->radius = blurRadius_ / 2; // 2: experience factor
50             linearGradientBlurFilter_ = std::make_shared<GEKawaseBlurShaderFilter>(*kawaseParams);
51         }
52     }
53 
54     ~GELinearGradientBlurPara() = default;
55 
56     float blurRadius_;
57     // Each pair in fractionStops_ represents <blur degree, position scale>
58     std::vector<std::pair<float, float>> fractionStops_;
59     GEGradientDirection direction_;
60     std::shared_ptr<GEShaderFilter> linearGradientBlurFilter_;
61     bool isRadiusGradient_ = false;
62 };
63 
64 } // namespace Rosen
65 } // namespace OHOS
66 
67 #endif // GRAPHICS_EFFECT_GE_GRADIENT_BLUR_PARA_H
68