• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 ROSEN_ENGINE_CORE_RENDER_RS_FILTER_H
17 #define ROSEN_ENGINE_CORE_RENDER_RS_FILTER_H
18 
19 #include <memory>
20 
21 #include "common/rs_macros.h"
22 
23 namespace OHOS {
24 namespace Rosen {
25 class RS_EXPORT RSFilter : public std::enable_shared_from_this<RSFilter> {
26 public:
27     virtual ~RSFilter();
28     static std::shared_ptr<RSFilter> CreateBlurFilter(float blurRadiusX, float blurRadiusY);
29 
30     enum FilterType {
31         NONE = 0,
32         BLUR,
33     };
GetFilterType()34     FilterType GetFilterType() const
35     {
36         return type_;
37     }
IsValid()38     bool IsValid() const
39     {
40         return type_ != FilterType::NONE;
41     }
42 protected:
43     FilterType type_;
44     RSFilter();
Add(const std::shared_ptr<RSFilter> & rhs)45     virtual std::shared_ptr<RSFilter> Add(const std::shared_ptr<RSFilter>& rhs) { return nullptr; }
Sub(const std::shared_ptr<RSFilter> & rhs)46     virtual std::shared_ptr<RSFilter> Sub(const std::shared_ptr<RSFilter>& rhs) { return nullptr; }
Multiply(float rhs)47     virtual std::shared_ptr<RSFilter> Multiply(float rhs) { return nullptr; }
Negate()48     virtual std::shared_ptr<RSFilter> Negate() { return nullptr; }
49     friend std::shared_ptr<RSFilter> operator+(const std::shared_ptr<RSFilter>& lhs, const std::shared_ptr<RSFilter>& rhs);
50     friend std::shared_ptr<RSFilter> operator-(const std::shared_ptr<RSFilter>& lhs, const std::shared_ptr<RSFilter>& rhs);
51     friend std::shared_ptr<RSFilter> operator*(const std::shared_ptr<RSFilter>& lhs, float rhs);
52 };
53 } // namespace Rosen
54 } // namespace OHOS
55 
56 #endif // ROSEN_ENGINE_CORE_RENDER_RS_FILTER_H
57