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 #include "render/rs_kawase_blur_shader_filter.h"
16 
17 #include "effect/color_matrix.h"
18 #include "effect/runtime_shader_builder.h"
19 #include "include/gpu/GrDirectContext.h"
20 #include "platform/common/rs_system_properties.h"
21 #include "src/core/SkOpts.h"
22 
23 
24 namespace OHOS {
25 namespace Rosen {
RSKawaseBlurShaderFilter(int radius)26 RSKawaseBlurShaderFilter::RSKawaseBlurShaderFilter(int radius)
27     : radius_(radius)
28 {
29     type_ = ShaderFilterType::KAWASE;
30     hash_ = SkOpts::hash(&radius_, sizeof(radius_), 0);
31 }
32 
33 RSKawaseBlurShaderFilter::~RSKawaseBlurShaderFilter() = default;
34 
GetRadius() const35 int RSKawaseBlurShaderFilter::GetRadius() const
36 {
37     return radius_;
38 }
39 
GenerateGEVisualEffect(std::shared_ptr<Drawing::GEVisualEffectContainer> visualEffectContainer)40 void RSKawaseBlurShaderFilter::GenerateGEVisualEffect(
41     std::shared_ptr<Drawing::GEVisualEffectContainer> visualEffectContainer)
42 {
43     auto kawaseFilter = std::make_shared<Drawing::GEVisualEffect>("KAWASE_BLUR", Drawing::DrawingPaintType::BRUSH);
44     kawaseFilter->SetParam("KAWASE_BLUR_RADIUS", (int)radius_); // blur radius
45     visualEffectContainer->AddToChainedFilter(kawaseFilter);
46 }
47 } // namespace Rosen
48 } // namespace OHOS