1 /*
2 * Copyright (c) 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 #include "drawing_mask_filter.h"
17
18 #include "effect/mask_filter.h"
19
20 using namespace OHOS;
21 using namespace Rosen;
22 using namespace Drawing;
23
CastToMaskFilter(OH_Drawing_MaskFilter * cMaskFilter)24 static MaskFilter* CastToMaskFilter(OH_Drawing_MaskFilter* cMaskFilter)
25 {
26 return reinterpret_cast<MaskFilter*>(cMaskFilter);
27 }
28
OH_Drawing_MaskFilterCreateBlur(OH_Drawing_BlurType blurType,float sigma,bool respectCTM)29 OH_Drawing_MaskFilter* OH_Drawing_MaskFilterCreateBlur(OH_Drawing_BlurType blurType, float sigma, bool respectCTM)
30 {
31 return (OH_Drawing_MaskFilter*)new MaskFilter(MaskFilter::FilterType::BLUR,
32 static_cast<BlurType>(blurType), sigma, respectCTM);
33 }
34
OH_Drawing_MaskFilterDestroy(OH_Drawing_MaskFilter * cMaskFilter)35 void OH_Drawing_MaskFilterDestroy(OH_Drawing_MaskFilter* cMaskFilter)
36 {
37 if (!cMaskFilter) {
38 return;
39 }
40 delete CastToMaskFilter(cMaskFilter);
41 }
42