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 
16 #ifndef SKIA_MASK_FILTER_H
17 #define SKIA_MASK_FILTER_H
18 
19 #include "include/core/SkMaskFilter.h"
20 
21 #include "impl_interface/mask_filter_impl.h"
22 
23 namespace OHOS {
24 namespace Rosen {
25 namespace Drawing {
26 class SkiaMaskFilter : public MaskFilterImpl {
27 public:
28     static inline constexpr AdapterType TYPE = AdapterType::SKIA_ADAPTER;
29     SkiaMaskFilter() noexcept;
~SkiaMaskFilter()30     ~SkiaMaskFilter() override {};
GetType()31     AdapterType GetType() const override
32     {
33         return AdapterType::SKIA_ADAPTER;
34     }
35 
36     void InitWithBlur(BlurType t, scalar sigma, bool respectCTM) override;
37     sk_sp<SkMaskFilter> GetMaskFilter() const;
38     /*
39      * @brief  Update the member variable to filter, adaptation layer calls.
40      */
41     void SetSkMaskFilter(const sk_sp<SkMaskFilter>& filter);
42 
43     std::shared_ptr<Data> Serialize() const override;
44     bool Deserialize(std::shared_ptr<Data> data) override;
45 private:
46     sk_sp<SkMaskFilter> filter_;
47 };
48 } // namespace Drawing
49 } // namespace Rosen
50 } // namespace OHOS
51 #endif
52