• 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_BASE_RENDER_RENDER_RS_BLUR_FILTER_H
16 #define RENDER_SERVICE_BASE_RENDER_RENDER_RS_BLUR_FILTER_H
17 
18 #include <optional>
19 
20 #include "include/core/SkColorFilter.h"
21 #include "include/effects/SkRuntimeEffect.h"
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, bool disableSystemAdaptation = true);
33     RSBlurFilter(const RSBlurFilter&) = delete;
34     RSBlurFilter operator=(const RSBlurFilter&) = delete;
35     ~RSBlurFilter() override;
36     float GetBlurRadiusX();
37     float GetBlurRadiusY();
38     bool GetDisableSystemAdaptation();
39     bool IsValid() const override;
40     std::shared_ptr<RSDrawingFilterOriginal> Compose(
41         const std::shared_ptr<RSDrawingFilterOriginal>& other) const override;
42     std::string GetDescription() override;
43     std::string GetDetailedDescription() override;
44 
45     void DrawImageRect(Drawing::Canvas& canvas, const std::shared_ptr<Drawing::Image>& image,
46         const Drawing::Rect& src, const Drawing::Rect& dst) const override;
47     void SetGreyCoef(const std::optional<Vector2f>& greyCoef) override;
48 
49     bool CanSkipFrame() const override;
50 
51 private:
52     float blurRadiusX_;
53     float blurRadiusY_;
54     std::optional<Vector2f> greyCoef_;
55     bool disableSystemAdaptation_ {true};
56 };
57 } // namespace Rosen
58 } // namespace OHOS
59 
60 #endif // RENDER_SERVICE_BASE_RENDER_RENDER_RS_BLUR_FILTER_H