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 #include <effect/filter.h>
17
18 namespace OHOS {
19 namespace Rosen {
20 namespace Drawing {
Filter()21 Filter::Filter() noexcept
22 : colorFilter_(nullptr), imageFilter_(nullptr), maskFilter_(nullptr), filterQuality_(FilterQuality::NONE)
23 {}
24
SetColorFilter(std::shared_ptr<ColorFilter> colorFilter)25 void Filter::SetColorFilter(std::shared_ptr<ColorFilter> colorFilter)
26 {
27 colorFilter_ = colorFilter;
28 }
29
GetColorFilter() const30 std::shared_ptr<ColorFilter> Filter::GetColorFilter() const
31 {
32 return colorFilter_;
33 }
34
SetImageFilter(std::shared_ptr<ImageFilter> imageFilter)35 void Filter::SetImageFilter(std::shared_ptr<ImageFilter> imageFilter)
36 {
37 imageFilter_ = imageFilter;
38 }
39
GetImageFilter() const40 std::shared_ptr<ImageFilter> Filter::GetImageFilter() const
41 {
42 return imageFilter_;
43 }
44
SetMaskFilter(std::shared_ptr<MaskFilter> maskFilter)45 void Filter::SetMaskFilter(std::shared_ptr<MaskFilter> maskFilter)
46 {
47 maskFilter_ = maskFilter;
48 }
49
GetMaskFilter() const50 std::shared_ptr<MaskFilter> Filter::GetMaskFilter() const
51 {
52 return maskFilter_;
53 }
54
SetFilterQuality(FilterQuality filterQuality)55 void Filter::SetFilterQuality(FilterQuality filterQuality)
56 {
57 filterQuality_ = filterQuality;
58 }
59
GetFilterQuality() const60 Filter::FilterQuality Filter::GetFilterQuality() const
61 {
62 return filterQuality_;
63 }
64
operator ==(const Filter & f1,const Filter & f2)65 bool operator==(const Filter& f1, const Filter& f2)
66 {
67 return f1.colorFilter_ == f2.colorFilter_ && f1.imageFilter_ == f2.imageFilter_ &&
68 f1.maskFilter_ == f2.maskFilter_ && f1.filterQuality_ == f2.filterQuality_;
69 }
70
operator !=(const Filter & f1,const Filter & f2)71 bool operator!=(const Filter& f1, const Filter& f2)
72 {
73 return f1.colorFilter_ != f2.colorFilter_ || f1.imageFilter_ != f2.imageFilter_ ||
74 f1.maskFilter_ != f2.maskFilter_ || f1.filterQuality_ != f2.filterQuality_;
75 }
76 } // namespace Drawing
77 } // namespace Rosen
78 } // namespace OHOS