• 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 "common/rs_macros.h"
24 #include "render/rs_skia_filter.h"
25 #include "render/rs_kawase_blur.h"
26 
27 namespace OHOS {
28 namespace Rosen {
29 #ifndef USE_ROSEN_DRAWING
30 class RSB_EXPORT RSBlurFilter : public RSSkiaFilter {
31 #else
32 class RSB_EXPORT RSBlurFilter : public RSDrawingFilter {
33 #endif
34 public:
35     RSBlurFilter(float blurRadiusX, float blurRadiusY);
36     RSBlurFilter(const RSBlurFilter&) = delete;
37     RSBlurFilter operator=(const RSBlurFilter&) = delete;
38     ~RSBlurFilter() override;
39     float GetBlurRadiusX();
40     float GetBlurRadiusY();
41     bool IsValid() const override;
42 #ifndef USE_ROSEN_DRAWING
43     std::shared_ptr<RSSkiaFilter> Compose(const std::shared_ptr<RSSkiaFilter>& other) const override;
44 #else
45     std::shared_ptr<RSDrawingFilter> Compose(const std::shared_ptr<RSDrawingFilter>& other) const override;
46 #endif
47     std::string GetDescription() override;
48 
49     std::shared_ptr<RSFilter> Add(const std::shared_ptr<RSFilter>& rhs) override;
50     std::shared_ptr<RSFilter> Sub(const std::shared_ptr<RSFilter>& rhs) override;
51     std::shared_ptr<RSFilter> Multiply(float rhs) override;
52     std::shared_ptr<RSFilter> Negate() override;
53 #ifndef USE_ROSEN_DRAWING
54     void DrawImageRect(
55         SkCanvas& canvas, const sk_sp<SkImage>& image, const SkRect& src, const SkRect& dst) const override;
56 #else
57     void DrawImageRect(Drawing::Canvas& canvas, const std::shared_ptr<Drawing::Image>& image,
58         const Drawing::Rect& src, const Drawing::Rect& dst) const override;
59 #endif
60 
61     bool CanSkipFrame() const override;
62 
63 private:
64     float blurRadiusX_;
65     float blurRadiusY_;
66 #ifndef USE_ROSEN_DRAWING
67     bool useKawase_ = false;
68     static std::shared_ptr<KawaseBlurFilter> kawaseFunc_;
69 #endif
70 };
71 } // namespace Rosen
72 } // namespace OHOS
73 
74 #endif // RENDER_SERVICE_CLIENT_CORE_RENDER_RS_BLUR_FILTER_H