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 FILTER_H
17 #define FILTER_H
18 
19 #include "common/rs_macros.h"
20 #include "effect/image_filter.h"
21 #include "effect/mask_filter.h"
22 #include "effect/path_effect.h"
23 #include "utils/drawing_macros.h"
24 #include "utils/scalar.h"
25 
26 namespace OHOS {
27 namespace Rosen {
28 namespace Drawing {
29 class DRAWING_API Filter {
30 public:
31     enum class FilterQuality {
32         NONE,
33         LOW,
34         MEDIUM,
35         HIGH,
36     };
37 
38     Filter() noexcept;
~Filter()39     ~Filter() {};
40 
41     void SetColorFilter(std::shared_ptr<ColorFilter> colorFilter);
42     std::shared_ptr<ColorFilter> GetColorFilter() const;
43     const ColorFilter* GetColorFilterPtr() const;
44 
45     void SetImageFilter(std::shared_ptr<ImageFilter> imageFilter);
46     std::shared_ptr<ImageFilter> GetImageFilter() const;
47     const ImageFilter* GetImageFilterPtr() const;
48 
49     void SetMaskFilter(std::shared_ptr<MaskFilter> maskFilter);
50     std::shared_ptr<MaskFilter> GetMaskFilter() const;
51     const MaskFilter* GetMaskFilterPtr() const;
52 
53     FilterQuality GetFilterQuality() const;
54     void SetFilterQuality(FilterQuality fq);
55 
56     void Reset();
57 
58     friend bool operator==(const Filter& f1, const Filter& f2);
59     friend bool operator!=(const Filter& f1, const Filter& f2);
60 
61     void Dump(std::string& out) const;
62 
63 private:
64     std::shared_ptr<ColorFilter> colorFilter_;
65     std::shared_ptr<ImageFilter> imageFilter_;
66     std::shared_ptr<MaskFilter> maskFilter_;
67     FilterQuality filterQuality_;
68 };
69 } // namespace Drawing
70 } // namespace Rosen
71 } // namespace OHOS
72 #endif