1 /*
2  * Copyright (c) 2024 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_color_space.h"
17 #include "effect/color_space.h"
18 
19 using namespace OHOS;
20 using namespace Rosen;
21 using namespace Drawing;
22 
CastToColorSpace(OH_Drawing_ColorSpace * colorSpace)23 static ColorSpace* CastToColorSpace(OH_Drawing_ColorSpace* colorSpace)
24 {
25     return reinterpret_cast<ColorSpace*>(colorSpace);
26 }
27 
OH_Drawing_ColorSpaceCreateSrgb()28 OH_Drawing_ColorSpace* OH_Drawing_ColorSpaceCreateSrgb()
29 {
30     return (OH_Drawing_ColorSpace*)new ColorSpace(ColorSpace::ColorSpaceType::SRGB);
31 }
32 
OH_Drawing_ColorSpaceCreateSrgbLinear()33 OH_Drawing_ColorSpace* OH_Drawing_ColorSpaceCreateSrgbLinear()
34 {
35     return (OH_Drawing_ColorSpace*)new ColorSpace(ColorSpace::ColorSpaceType::SRGB_LINEAR);
36 }
37 
OH_Drawing_ColorSpaceDestroy(OH_Drawing_ColorSpace * colorSpace)38 void OH_Drawing_ColorSpaceDestroy(OH_Drawing_ColorSpace* colorSpace)
39 {
40     if (colorSpace == nullptr) {
41         return;
42     }
43     delete CastToColorSpace(colorSpace);
44 }
45