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 /**
17  * @addtogroup NativeColorSpaceManager
18  * @{
19  *
20  * @brief Provides the native colorSpaceManager capability.
21  *
22  * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core
23  * @since 13
24  * @version 1.0
25  */
26 
27 /**
28  * @file native_color_space_manager.h
29  *
30  * @brief Defines the functions for obtaining and using a native colorSpaceManager.
31  *
32  * @library libnative_color_space_manager.so
33  * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core
34  * @since 13
35  * @version 1.0
36  */
37 #ifndef C_INCLUDE_NATIVE_COLOR_SPACE_MANAGER_H_
38 #define C_INCLUDE_NATIVE_COLOR_SPACE_MANAGER_H_
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 /**
45  * @brief Defines a colorspace manager.
46  * @since 13
47  */
48 typedef struct OH_NativeColorSpaceManager OH_NativeColorSpaceManager;
49 
50 /**
51  * @brief Enumerates color space types.
52  * @since 13
53  */
54 typedef enum {
55     /** Indicates an unknown color space. */
56     NONE = 0,
57     /** Indicates the color space based on Adobe RGB. */
58     ADOBE_RGB = 1,
59     /** Indicates the color space based on SMPTE RP 431-2-2007 and IEC 61966-2.1:1999. */
60     DCI_P3 = 2,
61     /** Indicates the color space based on SMPTE RP 431-2-2007 and IEC 61966-2.1:1999. */
62     DISPLAY_P3 = 3,
63     /** Indicates the standard red green blue (SRGB) color space based on IEC 61966-2.1:1999. */
64     SRGB = 4,
65     /** Indicates the color space based on ITU-R BT.709. */
66     BT709 = 6,
67     /** Indicates the color space based on ITU-R BT.601. */
68     BT601_EBU = 7,
69     /** Indicates the color space based on ITU-R BT.601. */
70     BT601_SMPTE_C = 8,
71     /** Indicates the color space based on ITU-R BT.2020. */
72     BT2020_HLG = 9,
73     /** Indicates the color space based on ITU-R BT.2020. */
74     BT2020_PQ = 10,
75     /** PRIMARIES_P3_D65 | TRANSFUNC_HLG | RANGE_FULL */
76     P3_HLG = 11,
77     /** PRIMARIES_P3_D65 | TRANSFUNC_PQ | RANGE_FULL */
78     P3_PQ = 12,
79     /** PRIMARIES_ADOBE_RGB | TRANSFUNC_ADOBE_RGB | RANGE_LIMIT */
80     ADOBE_RGB_LIMIT = 13,
81     /** PRIMARIES_P3_D65 | TRANSFUNC_SRGB | RANGE_LIMIT */
82     DISPLAY_P3_LIMIT = 14,
83     /** PRIMARIES_SRGB | TRANSFUNC_SRGB | RANGE_LIMIT */
84     SRGB_LIMIT = 15,
85     /** PRIMARIES_BT709 | TRANSFUNC_BT709 | RANGE_LIMIT */
86     BT709_LIMIT = 16,
87     /** PRIMARIES_BT601_P | TRANSFUNC_BT709 | RANGE_LIMIT */
88     BT601_EBU_LIMIT = 17,
89     /** PRIMARIES_BT601_N | TRANSFUNC_BT709 | RANGE_LIMIT */
90     BT601_SMPTE_C_LIMIT = 18,
91     /** PRIMARIES_BT2020 | TRANSFUNC_HLG | RANGE_LIMIT */
92     BT2020_HLG_LIMIT = 19,
93     /** PRIMARIES_BT2020 | TRANSFUNC_PQ | RANGE_LIMIT */
94     BT2020_PQ_LIMIT = 20,
95     /** PRIMARIES_P3_D65 | TRANSFUNC_HLG | RANGE_LIMIT */
96     P3_HLG_LIMIT = 21,
97     /** PRIMARIES_P3_D65 | TRANSFUNC_PQ | RANGE_LIMIT */
98     P3_PQ_LIMIT = 22,
99     /** PRIMARIES_P3_D65 | TRANSFUNC_LINEAR */
100     LINEAR_P3 = 23,
101     /** PRIMARIES_SRGB | TRANSFUNC_LINEAR */
102     LINEAR_SRGB = 24,
103     /** PRIMARIES_BT709 | TRANSFUNC_LINEAR */
104     LINEAR_BT709 = LINEAR_SRGB,
105     /** PRIMARIES_BT2020 | TRANSFUNC_LINEAR */
106     LINEAR_BT2020 = 25,
107     /** PRIMARIES_SRGB | TRANSFUNC_SRGB | RANGE_FULL */
108     DISPLAY_SRGB = SRGB,
109     /** PRIMARIES_P3_D65 | TRANSFUNC_SRGB | RANGE_FULL */
110     DISPLAY_P3_SRGB = DISPLAY_P3,
111     /** PRIMARIES_P3_D65 | TRANSFUNC_HLG | RANGE_FULL */
112     DISPLAY_P3_HLG = P3_HLG,
113     /** PRIMARIES_DISPLAY_P3 | TRANSFUNC_PQ | RANGE_FULL */
114     DISPLAY_P3_PQ = P3_PQ,
115     /** Indicates a customized color space. */
116     CUSTOM = 5,
117 } ColorSpaceName;
118 
119 /**
120  * @brief Describes the primary colors red, green, blue and white point coordinated as (x, y)
121  * in color space, in terms of real world chromaticities.
122  * @since 13
123  */
124 typedef struct {
125     /** Coordinate value x of red color */
126     float rX;
127     /** Coordinate value y of red color */
128     float rY;
129     /** Coordinate value x of green color */
130     float gX;
131     /** Coordinate value y of green color */
132     float gY;
133     /** Coordinate value x of blue color */
134     float bX;
135     /** Coordinate value y of blue color */
136     float bY;
137     /** Coordinate value x of white point */
138     float wX;
139     /** Coordinate value y of white point */
140     float wY;
141 } ColorSpacePrimaries;
142 
143 /**
144  * @brief Indicates white point coordinated as (x, y) return array.
145  * @since 13
146  */
147 typedef struct {
148     /** Indicates white point return array */
149     float arr[2];
150 } WhitePointArray;
151 
152 /**
153  * @brief Creates a <b>NativeColorSpaceManager</b> instance by colorSpaceName.
154  * A new <b>NativeColorSpaceManager</b> instance is created each time this function is called.
155  *
156  * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core
157  * @param colorSpaceName Indicates the NativeColorSpace connection name.
158  * @return Returns the pointer to the <b>NativeColorSpaceManager</b> instance created.
159  * Creation failed, cause memory shortage.
160  * @since 13
161  * @version 1.0
162  */
163 OH_NativeColorSpaceManager* OH_NativeColorSpaceManager_CreateFromName(ColorSpaceName colorSpaceName);
164 
165 /**
166  * @brief Creates a <b>NativeColorSpaceManager</b> instance by primaries and gamma.
167  * A new <b>NativeColorSpaceManager</b> instance is created each time this function is called.
168  *
169  * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core
170  * @param primaries Indicates the NativeColorSpace connection primaries.
171  * @param gamma Indicates the NativeColorSpace connection gamma.
172  * @return Returns the pointer to the <b>NativeColorSpaceManager</b> instance created.
173  * Creation failed, cause memory shortage.
174  * @since 13
175  * @version 1.0
176  */
177 OH_NativeColorSpaceManager* OH_NativeColorSpaceManager_CreateFromPrimariesAndGamma(
178     ColorSpacePrimaries primaries, float gamma);
179 
180 /**
181  * @brief Delete the NativeColorSpaceManager instance.
182  *
183  * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core
184  * @param nativeColorSpaceManager Indicates the pointer to a <b>NativeColorSpaceManager</b> instance.
185  * @since 13
186  * @version 1.0
187  */
188 void OH_NativeColorSpaceManager_Destroy(OH_NativeColorSpaceManager* nativeColorSpaceManager);
189 
190 /**
191  * @brief Get colorSpace name.
192  *
193  * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core
194  * @param nativeColorSpaceManager Indicates the pointer to a <b>NativeColorSpaceManager</b> instance.
195  * @return Returns value, return value > 0 && value <= 25, success, return value == 0 , failed.
196  * @since 13
197  * @version 1.0
198  */
199 int OH_NativeColorSpaceManager_GetColorSpaceName(
200     OH_NativeColorSpaceManager* nativeColorSpaceManager);
201 
202 /**
203  * @brief Get white point.
204  *
205  * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core
206  * @param nativeColorSpaceManager Indicates the pointer to a <b>NativeColorSpaceManager</b> instance.
207  * @return Returns float array, return array = <0.f, 0.f>, failed, otherwise, true.
208  * @since 13
209  * @version 1.0
210  */
211 WhitePointArray OH_NativeColorSpaceManager_GetWhitePoint(
212     OH_NativeColorSpaceManager* nativeColorSpaceManager);
213 
214 /**
215  * @brief Get gamma.
216  *
217  * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core
218  * @param nativeColorSpaceManager Indicates the pointer to a <b>NativeColorSpaceManager</b> instance.
219  * @return Returns float, return value == 0.f, failed, otherwise, true.
220  * @since 13
221  * @version 1.0
222  */
223 float OH_NativeColorSpaceManager_GetGamma(OH_NativeColorSpaceManager* nativeColorSpaceManager);
224 
225 #ifdef __cplusplus
226 }
227 #endif
228 /** @} */
229 #endif