• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     /** PRIMARIES_BT2020 | TRANSFUNC_SRGB | RANGE_FULL */
116     DISPLAY_BT2020_SRGB = 26,
117     /** Indicates a customized color space. */
118     CUSTOM = 5,
119 } ColorSpaceName;
120 
121 /**
122  * @brief Describes the primary colors red, green, blue and white point coordinated as (x, y)
123  * in color space, in terms of real world chromaticities.
124  * @since 13
125  */
126 typedef struct {
127     /** Coordinate value x of red color */
128     float rX;
129     /** Coordinate value y of red color */
130     float rY;
131     /** Coordinate value x of green color */
132     float gX;
133     /** Coordinate value y of green color */
134     float gY;
135     /** Coordinate value x of blue color */
136     float bX;
137     /** Coordinate value y of blue color */
138     float bY;
139     /** Coordinate value x of white point */
140     float wX;
141     /** Coordinate value y of white point */
142     float wY;
143 } ColorSpacePrimaries;
144 
145 /**
146  * @brief Indicates white point coordinated as (x, y) return array.
147  * @since 13
148  */
149 typedef struct {
150     /** Indicates white point return array */
151     float arr[2];
152 } WhitePointArray;
153 
154 /**
155  * @brief Creates a <b>NativeColorSpaceManager</b> instance by colorSpaceName.
156  * A new <b>NativeColorSpaceManager</b> instance is created each time this function is called.
157  *
158  * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core
159  * @param colorSpaceName Indicates the NativeColorSpace connection name.
160  * @return Returns the pointer to the <b>NativeColorSpaceManager</b> instance created.
161  * Creation failed, cause memory shortage.
162  * @since 13
163  * @version 1.0
164  */
165 OH_NativeColorSpaceManager* OH_NativeColorSpaceManager_CreateFromName(ColorSpaceName colorSpaceName);
166 
167 /**
168  * @brief Creates a <b>NativeColorSpaceManager</b> instance by primaries and gamma.
169  * A new <b>NativeColorSpaceManager</b> instance is created each time this function is called.
170  *
171  * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core
172  * @param primaries Indicates the NativeColorSpace connection primaries.
173  * @param gamma Indicates the NativeColorSpace connection gamma.
174  * @return Returns the pointer to the <b>NativeColorSpaceManager</b> instance created.
175  * Creation failed, cause memory shortage.
176  * @since 13
177  * @version 1.0
178  */
179 OH_NativeColorSpaceManager* OH_NativeColorSpaceManager_CreateFromPrimariesAndGamma(
180     ColorSpacePrimaries primaries, float gamma);
181 
182 /**
183  * @brief Delete the NativeColorSpaceManager instance.
184  *
185  * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core
186  * @param nativeColorSpaceManager Indicates the pointer to a <b>NativeColorSpaceManager</b> instance.
187  * @since 13
188  * @version 1.0
189  */
190 void OH_NativeColorSpaceManager_Destroy(OH_NativeColorSpaceManager* nativeColorSpaceManager);
191 
192 /**
193  * @brief Get colorSpace name.
194  *
195  * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core
196  * @param nativeColorSpaceManager Indicates the pointer to a <b>NativeColorSpaceManager</b> instance.
197  * @return Returns value, return value > 0 && value <= 25, success, return value == 0 , failed.
198  * @since 13
199  * @version 1.0
200  */
201 int OH_NativeColorSpaceManager_GetColorSpaceName(
202     OH_NativeColorSpaceManager* nativeColorSpaceManager);
203 
204 /**
205  * @brief Get white point.
206  *
207  * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core
208  * @param nativeColorSpaceManager Indicates the pointer to a <b>NativeColorSpaceManager</b> instance.
209  * @return Returns float array, return array = <0.f, 0.f>, failed, otherwise, true.
210  * @since 13
211  * @version 1.0
212  */
213 WhitePointArray OH_NativeColorSpaceManager_GetWhitePoint(
214     OH_NativeColorSpaceManager* nativeColorSpaceManager);
215 
216 /**
217  * @brief Get gamma.
218  *
219  * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core
220  * @param nativeColorSpaceManager Indicates the pointer to a <b>NativeColorSpaceManager</b> instance.
221  * @return Returns float, return value == 0.f, failed, otherwise, true.
222  * @since 13
223  * @version 1.0
224  */
225 float OH_NativeColorSpaceManager_GetGamma(OH_NativeColorSpaceManager* nativeColorSpaceManager);
226 
227 #ifdef __cplusplus
228 }
229 #endif
230 /** @} */
231 #endif