• 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 
16 #ifndef RENDER_SERVICE_CLIENT_CORE_RENDER_RS_HPS_BLUR_H
17 #define RENDER_SERVICE_CLIENT_CORE_RENDER_RS_HPS_BLUR_H
18 
19 #include "draw/canvas.h"
20 #include "effect/color_filter.h"
21 #include "effect/runtime_effect.h"
22 #include "image/image.h"
23 #include "utils/matrix.h"
24 #include "utils/rect.h"
25 
26 namespace OHOS {
27 namespace Rosen {
28 class RSB_EXPORT HpsBlurFilter {
29 public:
30     ~HpsBlurFilter() = default;
31     bool ApplyHpsBlur(Drawing::Canvas& canvas, const std::shared_ptr<Drawing::Image>& image,
32         const Drawing::HpsBlurParameter& param, float alpha,
33         std::shared_ptr<Drawing::ColorFilter> colorFilter = nullptr) const;
GetHpsBlurFilter()34     const static HpsBlurFilter& GetHpsBlurFilter()
35     {
36         static HpsBlurFilter filter;
37         return filter;
38     }
39 
40 private:
41     HpsBlurFilter() = default;
42     static Drawing::Matrix GetShaderTransform(const Drawing::Rect& blurRect, float scaleW = 1.0f, float scaleH = 1.0f);
43     std::shared_ptr<Drawing::RuntimeEffect> GetMixEffect() const;
44     bool SetShaderEffect(Drawing::Brush& brush, std::shared_ptr<Drawing::ShaderEffect> blurShader,
45         std::shared_ptr<Drawing::Image> imageCache) const;
46 };
47 } // namespace Rosen
48 } // namespace OHOS
49 #endif // RENDER_SERVICE_CLIENT_CORE_RENDER_RS_HPS_BLUR_H