• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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 RENDER_SERVICE_CLIENT_CORE_RENDER_RS_BLUR_FILTER_H
16 #define RENDER_SERVICE_CLIENT_CORE_RENDER_RS_BLUR_FILTER_H
17 
18 #include "include/core/SkColorFilter.h"
19 #ifdef NEW_SKIA
20 #include "include/effects/SkRuntimeEffect.h"
21 #endif
22 
23 #include "property/rs_properties_painter.h"
24 #include "common/rs_macros.h"
25 #include "render/rs_skia_filter.h"
26 #include "render/rs_kawase_blur.h"
27 
28 namespace OHOS {
29 namespace Rosen {
30 class RSB_EXPORT RSBlurFilter : public RSDrawingFilterOriginal {
31 public:
32     RSBlurFilter(float blurRadiusX, float blurRadiusY);
33     RSBlurFilter(const RSBlurFilter&) = delete;
34     RSBlurFilter operator=(const RSBlurFilter&) = delete;
35     ~RSBlurFilter() override;
36     float GetBlurRadiusX();
37     float GetBlurRadiusY();
38     bool IsValid() const override;
39     std::shared_ptr<RSDrawingFilterOriginal> Compose(
40         const std::shared_ptr<RSDrawingFilterOriginal>& other) const override;
41     std::string GetDescription() override;
42     std::string GetDetailedDescription() override;
43 
44     std::shared_ptr<RSFilter> Add(const std::shared_ptr<RSFilter>& rhs) override;
45     std::shared_ptr<RSFilter> Sub(const std::shared_ptr<RSFilter>& rhs) override;
46     std::shared_ptr<RSFilter> Multiply(float rhs) override;
47     std::shared_ptr<RSFilter> Negate() override;
48     void DrawImageRect(Drawing::Canvas& canvas, const std::shared_ptr<Drawing::Image>& image,
49         const Drawing::Rect& src, const Drawing::Rect& dst) const override;
50     void SetGreyCoef(const std::optional<Vector2f>& greyCoef) override;
51 
52     bool CanSkipFrame() const override;
53 
54     bool IsNearEqual(
55         const std::shared_ptr<RSFilter>& other, float threshold = std::numeric_limits<float>::epsilon()) const override;
56     bool IsNearZero(float threshold = std::numeric_limits<float>::epsilon()) const override;
57 
58     bool IsEqual(const std::shared_ptr<RSFilter>& other) const override;
59     bool IsEqualZero() const override;
60 
61 private:
62     float blurRadiusX_;
63     float blurRadiusY_;
64     std::optional<Vector2f> greyCoef_;
65 };
66 } // namespace Rosen
67 } // namespace OHOS
68 
69 #endif // RENDER_SERVICE_CLIENT_CORE_RENDER_RS_BLUR_FILTER_H