add TBM_FORMAT_NV12MT format
[platform/core/uifw/libtbm.git] / src / tbm_surface.h
1 /**************************************************************************
2
3 libtbm
4
5 Copyright 2014 Samsung Electronics co., Ltd. All Rights Reserved.
6
7 Contact: SooChan Lim <sc1.lim@samsung.com>, Sangjin Lee <lsj119@samsung.com>
8 Inpyo Kang <mantiger@samsung.com>, Dongyeon Kim <dy5.kim@samsung.com>
9 Boram Park <boram1288.park@samsung.com>, Changyeon Lee <cyeon.lee@samsung.com>
10
11 Permission is hereby granted, free of charge, to any person obtaining a
12 copy of this software and associated documentation files (the
13 "Software"), to deal in the Software without restriction, including
14 without limitation the rights to use, copy, modify, merge, publish,
15 distribute, sub license, and/or sell copies of the Software, and to
16 permit persons to whom the Software is furnished to do so, subject to
17 the following conditions:
18
19 The above copyright notice and this permission notice (including the
20 next paragraph) shall be included in all copies or substantial portions
21 of the Software.
22
23 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
26 IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
27 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
28 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
29 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30
31 **************************************************************************/
32
33 #ifndef _TBM_SURFACE_H_
34 #define _TBM_SURFACE_H_
35
36 /**
37  * @addtogroup CAPI_UI_TBM_SURFACE_MODULE
38  * @{
39  */
40
41 #include <tbm_type.h>
42 #include <tizen.h>
43
44 /**
45  * \file tbm_surface.h
46  * \brief TBM Surface
47  */
48
49 /**
50  * @brief Enumeration for tbm_surface error type.
51  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
52  */
53 typedef enum
54 {
55     TBM_SURFACE_ERROR_NONE  = TIZEN_ERROR_NONE,                           /**< Successful */
56     TBM_SURFACE_ERROR_INVALID_PARAMETER  = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
57     TBM_SURFACE_ERROR_INVALID_OPERATION  = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid Operation */
58 } tbm_surface_error_e;
59
60 /**
61  * @brief Definition for the max number of TBM surface plane.
62  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
63  */
64 #define TBM_SURF_PLANE_MAX 4
65
66 /* option to map the tbm_surface */
67 /**
68  * @brief Definition for the access option to read.
69  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
70  */
71 #define TBM_SURF_OPTION_READ      (1 << 0)
72 /**
73  * @brief Definition for the access option to write.
74  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
75  */
76 #define TBM_SURF_OPTION_WRITE     (1 << 1)
77
78 /**
79  * @brief Definition for the TBM plane struct.
80  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
81  */
82 typedef struct _tbm_surface_plane
83 {
84     unsigned char *ptr;   /**< Plane pointer */
85     uint32_t size;        /**< Plane size */
86     uint32_t offset;      /**< Plane offset */
87     uint32_t stride;      /**< Plane stride */
88
89     void *reserved1;      /**< Reserved pointer1 */
90     void *reserved2;      /**< Reserved pointer2 */
91     void *reserved3;      /**< Reserved pointer3 */
92 } tbm_surface_plane_s;
93
94 /**
95  * @brief Definition for the TBM surface information struct.
96  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
97  */
98 typedef struct _tbm_surface_info
99 {
100     uint32_t width;      /**< TBM surface width */
101     uint32_t height;     /**< TBM surface height */
102     tbm_format format;   /**< TBM surface format*/
103     uint32_t bpp;        /**< TBM surface bbp */
104     uint32_t size;       /**< TBM surface size */
105
106     uint32_t num_planes;                            /**< The number of planes */
107     tbm_surface_plane_s planes[TBM_SURF_PLANE_MAX]; /**< Array of planes */
108
109     void *reserved4;   /**< Reserved pointer4 */
110     void *reserved5;   /**< Reserved pointer5 */
111     void *reserved6;   /**< Reserved pointer6 */
112 } tbm_surface_info_s;
113
114 #define __tbm_fourcc_code(a,b,c,d) ((uint32_t)(a) | ((uint32_t)(b) << 8) | \
115                   ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
116
117 /* color index */
118 /**
119  * @brief Definition for the TBM surface format C8 ([7:0] C).
120  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
121  */
122 #define TBM_FORMAT_C8       __tbm_fourcc_code('C', '8', ' ', ' ')
123
124 /* 8 bpp RGB */
125 /**
126  * @brief Definition for the TBM surface format RGB322 ([7:0] R:G:B 3:3:2).
127  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
128  */
129 #define TBM_FORMAT_RGB332   __tbm_fourcc_code('R', 'G', 'B', '8')
130 /**
131  * @brief Definition for the TBM surface format RGB233 ([7:0] B:G:R 2:3:3).
132  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
133  */
134 #define TBM_FORMAT_BGR233   __tbm_fourcc_code('B', 'G', 'R', '8')
135
136 /* 16 bpp RGB */
137 /**
138  * @brief Definition for the TBM surface format XRGB4444 ([15:0] x:R:G:B 4:4:4:4 little endian).
139  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
140  */
141 #define TBM_FORMAT_XRGB4444 __tbm_fourcc_code('X', 'R', '1', '2')
142 /**
143  * @brief Definition for the TBM surface format XBRG4444 ([15:0] x:B:G:R 4:4:4:4 little endian).
144  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
145  */
146 #define TBM_FORMAT_XBGR4444 __tbm_fourcc_code('X', 'B', '1', '2')
147 /**
148  * @brief Definition for the TBM surface format RGBX4444 ([15:0] R:G:B:x 4:4:4:4 little endian).
149  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
150  */
151 #define TBM_FORMAT_RGBX4444 __tbm_fourcc_code('R', 'X', '1', '2')
152 /**
153  * @brief Definition for the TBM surface format BGRX4444 ([15:0] B:G:R:x 4:4:4:4 little endian).
154  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
155  */
156 #define TBM_FORMAT_BGRX4444 __tbm_fourcc_code('B', 'X', '1', '2')
157
158 /**
159  * @brief Definition for the TBM surface format ARGB4444 ([15:0] A:R:G:B 4:4:4:4 little endian).
160  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
161  */
162 #define TBM_FORMAT_ARGB4444 __tbm_fourcc_code('A', 'R', '1', '2')
163 /**
164  * @brief Definition for the TBM surface format ABGR4444 ([15:0] A:B:G:R 4:4:4:4 little endian).
165  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
166  */
167 #define TBM_FORMAT_ABGR4444 __tbm_fourcc_code('A', 'B', '1', '2')
168 /**
169  * @brief Definition for the TBM surface format RGBA4444 ([15:0] R:G:B:A 4:4:4:4 little endian).
170  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
171  */
172 #define TBM_FORMAT_RGBA4444 __tbm_fourcc_code('R', 'A', '1', '2')
173 /**
174  * @brief Definition for the TBM surface format BGRA4444 ([15:0] B:G:R:A 4:4:4:4 little endian).
175  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
176  */
177 #define TBM_FORMAT_BGRA4444 __tbm_fourcc_code('B', 'A', '1', '2')
178
179 /**
180  * @brief Definition for the TBM surface format XRGB1555 ([15:0] x:R:G:B 1:5:5:5 little endian).
181  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
182  */
183 #define TBM_FORMAT_XRGB1555 __tbm_fourcc_code('X', 'R', '1', '5')
184 /**
185  * @brief Definition for the TBM surface format XBGR1555 ([15:0] x:B:G:R 1:5:5:5 little endian).
186  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
187  */
188 #define TBM_FORMAT_XBGR1555 __tbm_fourcc_code('X', 'B', '1', '5')
189 /**
190  * @brief Definition for the TBM surface format RGBX5551 ([15:0] R:G:B:x 5:5:5:1 little endian).
191  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
192  */
193 #define TBM_FORMAT_RGBX5551 __tbm_fourcc_code('R', 'X', '1', '5')
194 /**
195  * @brief Definition for the TBM surface format BGRX5551 ([15:0] B:G:R:x 5:5:5:1 little endian).
196  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
197  */
198 #define TBM_FORMAT_BGRX5551 __tbm_fourcc_code('B', 'X', '1', '5')
199
200 /**
201  * @brief Definition for the TBM surface format ARGB1555 ([15:0] A:R:G:B 1:5:5:5 little endian).
202  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
203  */
204 #define TBM_FORMAT_ARGB1555 __tbm_fourcc_code('A', 'R', '1', '5')
205 /**
206  * @brief Definition for the TBM surface format ABGR1555 ([15:0] A:B:G:R 1:5:5:5 little endian).
207  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
208  */
209 #define TBM_FORMAT_ABGR1555 __tbm_fourcc_code('A', 'B', '1', '5')
210 /**
211  * @brief Definition for the TBM surface format RGBA5551 ([15:0] R:G:B:A 5:5:5:1 little endian).
212  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
213  */
214 #define TBM_FORMAT_RGBA5551 __tbm_fourcc_code('R', 'A', '1', '5')
215 /**
216  * @brief Definition for the TBM surface format BGRA5551 ([15:0] B:G:R:A 5:5:5:1 little endian).
217  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
218  */
219 #define TBM_FORMAT_BGRA5551 __tbm_fourcc_code('B', 'A', '1', '5')
220
221 /**
222  * @brief Definition for the TBM surface format RGB565 ([15:0] R:G:B 5:6:5 little endian).
223  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
224  */
225 #define TBM_FORMAT_RGB565   __tbm_fourcc_code('R', 'G', '1', '6')
226 /**
227  * @brief Definition for the TBM surface format BGR565 ([15:0] B:G:R 5:6:5 little endian).
228  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
229  */
230 #define TBM_FORMAT_BGR565   __tbm_fourcc_code('B', 'G', '1', '6')
231
232 /* 24 bpp RGB */
233 /**
234  * @brief Definition for the TBM surface format RGB888 ([23:0] R:G:B little endian).
235  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
236  */
237 #define TBM_FORMAT_RGB888   __tbm_fourcc_code('R', 'G', '2', '4')
238 /**
239  * @brief Definition for the TBM surface format BGR888 ([23:0] B:G:R little endian).
240  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
241  */
242 #define TBM_FORMAT_BGR888   __tbm_fourcc_code('B', 'G', '2', '4')
243
244 /* 32 bpp RGB */
245 /**
246  * @brief Definition for the TBM surface format XRGB8888 ([31:0] x:R:G:B 8:8:8:8 little endian).
247  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
248  */
249 #define TBM_FORMAT_XRGB8888 __tbm_fourcc_code('X', 'R', '2', '4')
250 /**
251  * @brief Definition for the TBM surface format XBGR8888 ([31:0] x:B:G:R 8:8:8:8 little endian).
252  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
253  */
254 #define TBM_FORMAT_XBGR8888 __tbm_fourcc_code('X', 'B', '2', '4')
255 /**
256  * @brief Definition for the TBM surface format RGBX8888 ([31:0] R:G:B:x 8:8:8:8 little endian).
257  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
258  */
259 #define TBM_FORMAT_RGBX8888 __tbm_fourcc_code('R', 'X', '2', '4')
260 /**
261  * @brief Definition for the TBM surface format BGRX8888 ([31:0] B:G:R:x 8:8:8:8 little endian).
262  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
263  */
264 #define TBM_FORMAT_BGRX8888 __tbm_fourcc_code('B', 'X', '2', '4')
265
266 /**
267  * @brief Definition for the TBM surface format ARGB8888 ([31:0] A:R:G:B 8:8:8:8 little endian).
268  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
269  */
270 #define TBM_FORMAT_ARGB8888 __tbm_fourcc_code('A', 'R', '2', '4')
271 /**
272  * @brief Definition for the TBM surface format ABGR8888 ([31:0] [31:0] A:B:G:R 8:8:8:8 little endian).
273  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
274  */
275 #define TBM_FORMAT_ABGR8888 __tbm_fourcc_code('A', 'B', '2', '4')
276 /**
277  * @brief Definition for the TBM surface format RGBA8888 ([31:0] R:G:B:A 8:8:8:8 little endian).
278  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
279  */
280 #define TBM_FORMAT_RGBA8888 __tbm_fourcc_code('R', 'A', '2', '4')
281 /**
282  * @brief Definition for the TBM surface format BGRA8888 ([31:0] B:G:R:A 8:8:8:8 little endian).
283  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
284  */
285 #define TBM_FORMAT_BGRA8888 __tbm_fourcc_code('B', 'A', '2', '4')
286
287 /**
288  * @brief Definition for the TBM surface format XRGB2101010 ([31:0] x:R:G:B 2:10:10:10 little endian).
289  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
290  */
291 #define TBM_FORMAT_XRGB2101010  __tbm_fourcc_code('X', 'R', '3', '0')
292 /**
293  * @brief Definition for the TBM surface format XBGR2101010 ([31:0] x:B:G:R 2:10:10:10 little endian).
294  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
295  */
296 #define TBM_FORMAT_XBGR2101010  __tbm_fourcc_code('X', 'B', '3', '0')
297 /**
298  * @brief Definition for the TBM surface format RGBX1010102 ([31:0] R:G:B:x 10:10:10:2 little endian).
299  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
300  */
301 #define TBM_FORMAT_RGBX1010102  __tbm_fourcc_code('R', 'X', '3', '0')
302 /**
303  * @brief Definition for the TBM surface format BGRX1010102 ([31:0] B:G:R:x 10:10:10:2 little endian).
304  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
305  */
306 #define TBM_FORMAT_BGRX1010102  __tbm_fourcc_code('B', 'X', '3', '0')
307
308 /**
309  * @brief Definition for the TBM surface format ARGB2101010 ([31:0] A:R:G:B 2:10:10:10 little endian).
310  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
311  */
312 #define TBM_FORMAT_ARGB2101010  __tbm_fourcc_code('A', 'R', '3', '0')
313 /**
314  * @brief Definition for the TBM surface format ABGR2101010 ([31:0] A:B:G:R 2:10:10:10 little endian).
315  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
316  */
317 #define TBM_FORMAT_ABGR2101010  __tbm_fourcc_code('A', 'B', '3', '0')
318 /**
319  * @brief Definition for the TBM surface format RGBA1010102 ([31:0] R:G:B:A 10:10:10:2 little endian).
320  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
321  */
322 #define TBM_FORMAT_RGBA1010102  __tbm_fourcc_code('R', 'A', '3', '0')
323 /**
324  * @brief Definition for the TBM surface format BGRA1010102 ([31:0] B:G:R:A 10:10:10:2 little endian).
325  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
326  */
327 #define TBM_FORMAT_BGRA1010102  __tbm_fourcc_code('B', 'A', '3', '0') /*  */
328
329 /* packed YCbCr */
330 /**
331  * @brief Definition for the TBM surface format YUYV ([31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian).
332  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
333  */
334 #define TBM_FORMAT_YUYV     __tbm_fourcc_code('Y', 'U', 'Y', 'V')
335 /**
336  * @brief Definition for the TBM surface format YVYU ([31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian).
337  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
338  */
339 #define TBM_FORMAT_YVYU     __tbm_fourcc_code('Y', 'V', 'Y', 'U') /*  */
340 /**
341  * @brief Definition for the TBM surface format UYVY ([31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian).
342  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
343  */
344 #define TBM_FORMAT_UYVY     __tbm_fourcc_code('U', 'Y', 'V', 'Y')
345 /**
346  * @brief Definition for the TBM surface format VYUY ([31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian).
347  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
348  */
349 #define TBM_FORMAT_VYUY     __tbm_fourcc_code('V', 'Y', 'U', 'Y')
350
351 /**
352  * @brief Definition for the TBM surface format AYUV ([31:0] A:Y:Cb:Cr 8:8:8:8 little endian).
353  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
354  */
355 #define TBM_FORMAT_AYUV     __tbm_fourcc_code('A', 'Y', 'U', 'V')
356
357 /*
358  * 2 plane YCbCr
359  * index 0 = Y plane, [7:0] Y
360  * index 1 = Cr:Cb plane, [15:0] Cr:Cb little endian
361  * or
362  * index 1 = Cb:Cr plane, [15:0] Cb:Cr little endian
363  */
364 /**
365  * @brief Definition for the TBM surface format NV12 (2x2 subsampled Cr:Cb plane).
366  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
367  */
368 #define TBM_FORMAT_NV12     __tbm_fourcc_code('N', 'V', '1', '2')
369 /**
370  * @brief Definition for the TBM surface format NV21 (2x2 subsampled Cb:Cr plane).
371  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
372  */
373 #define TBM_FORMAT_NV21     __tbm_fourcc_code('N', 'V', '2', '1') /*  */
374 /**
375  * @brief Definition for the TBM surface format NV16 (2x1 subsampled Cr:Cb plane).
376  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
377  */
378 #define TBM_FORMAT_NV16     __tbm_fourcc_code('N', 'V', '1', '6')
379 /**
380  * @brief Definition for the TBM surface format NV61 (2x1 subsampled Cb:Cr plane).
381  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
382  */
383 #define TBM_FORMAT_NV61     __tbm_fourcc_code('N', 'V', '6', '1')
384
385 /*
386  * 3 plane YCbCr
387  * index 0: Y plane, [7:0] Y
388  * index 1: Cb plane, [7:0] Cb
389  * index 2: Cr plane, [7:0] Cr
390  * or
391  * index 1: Cr plane, [7:0] Cr
392  * index 2: Cb plane, [7:0] Cb
393  */
394 /**
395  * @brief Definition for the TBM surface format YUV410 (4x4 subsampled Cb (1) and Cr (2) planes).
396  */
397 #define TBM_FORMAT_YUV410   __tbm_fourcc_code('Y', 'U', 'V', '9')
398 /**
399  * @brief Definition for the TBM surface format YVU410 (4x4 subsampled Cr (1) and Cb (2) planes).
400  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
401  */
402 #define TBM_FORMAT_YVU410   __tbm_fourcc_code('Y', 'V', 'U', '9')
403 /**
404  * @brief Definition for the TBM surface format YUV411 (4x1 subsampled Cb (1) and Cr (2) planes).
405  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
406  */
407 #define TBM_FORMAT_YUV411   __tbm_fourcc_code('Y', 'U', '1', '1')
408 /**
409  * @brief Definition for the TBM surface format YVU411 (4x1 subsampled Cr (1) and Cb (2) planes).
410  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
411  */
412 #define TBM_FORMAT_YVU411   __tbm_fourcc_code('Y', 'V', '1', '1')
413 /**
414  * @brief Definition for the TBM surface format YUV420 (2x2 subsampled Cb (1) and Cr (2) planes).
415  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
416  */
417 #define TBM_FORMAT_YUV420   __tbm_fourcc_code('Y', 'U', '1', '2')
418 /**
419  * @brief Definition for the TBM surface format YVU420 (2x2 subsampled Cr (1) and Cb (2) planes).
420  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
421  */
422 #define TBM_FORMAT_YVU420   __tbm_fourcc_code('Y', 'V', '1', '2')
423 /**
424  * @brief Definition for the TBM surface format YUV422 (2x1 subsampled Cb (1) and Cr (2) planes).
425  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
426  */
427 #define TBM_FORMAT_YUV422   __tbm_fourcc_code('Y', 'U', '1', '6')
428 /**
429  * @brief Definition for the TBM surface format YVU422 (2x1 subsampled Cr (1) and Cb (2) planes).
430  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
431  */
432 #define TBM_FORMAT_YVU422   __tbm_fourcc_code('Y', 'V', '1', '6')
433 /**
434  * @brief Definition for the TBM surface format YUV444 (non-subsampled Cb (1) and Cr (2) planes).
435  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
436  */
437 #define TBM_FORMAT_YUV444   __tbm_fourcc_code('Y', 'U', '2', '4')
438 /**
439  * @brief Definition for the TBM surface format YVU444 (non-subsampled Cr (1) and Cb (2) planes).
440  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
441  */
442 #define TBM_FORMAT_YVU444   __tbm_fourcc_code('Y', 'V', '2', '4')
443
444 /* 2 plane YCbCr */
445 /**
446  * @brief Definition for the TBM surface format NV12MT (tiled '64x32' & multi-plane version of NV12).
447  * @since_tizen 3.0 @endif
448  */
449 #define TBM_FORMAT_NV12MT   __tbm_fourcc_code('T', 'M', '1', '2')
450
451 #ifdef __cplusplus
452 extern "C" {
453 #endif
454
455 /**
456  * @brief Queries surface format list and number of format supported by the system.
457  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
458  *
459  * @remarks You must release the formats using free().
460  *
461  * @param[out] formats  The format array which the system can support \n
462  *                      This pointer has to be freed by user.
463  * @param[out] num      The number of formats
464  *
465  * @return  #TBM_SURFACE_ERROR_NONE if this function succeeds,
466  *          otherwise an error status value
467  *
468  * @retval #TBM_SURFACE_ERROR_NONE               Success
469  * @retval #TBM_SURFACE_ERROR_INVALID_OPERATION  Invalid operation
470  *
471  * @par Example
472    @code
473    #include <tbm_surface.h>
474
475    uint32_t *formats;
476    uint32_t format_num;
477    int ret, i;
478
479    if (tbm_surface_query_formats (&formats, &format_num))
480    {
481        for( i = 0 ; i < format_num ; i++)
482        {
483            if (formats[i] == TBM_FORMAT_RGB332)
484            {
485
486    ....
487
488    free (formats);
489    @endcode
490  */
491 int tbm_surface_query_formats (uint32_t **formats, uint32_t *num);
492
493 /**
494  * @brief Creates the tbm_surface.
495  * @details This function creates the tbm_surface with the given width, height, and format.
496  *
497  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
498  *
499  * @remark The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
500  *
501  * @param[in] width   The width of surface
502  * @param[in] height  The height of surface
503  * @param[in] format  The format of surface
504  *
505  * @return   #tbm_surface_h on success,
506  *           otherwise @c NULL
507  *
508  * @retval #tbm_surface_h  The TBM surface handle
509  *
510  * @exception #TBM_SURFACE_ERROR_NONE               Success
511  * @exception #TBM_SURFACE_ERROR_INVALID_PARAMETER  Invalid parameter
512  * @exception #TBM_SURFACE_ERROR_INVALID_OPERATION  Invalid operation
513  *
514  * @see tbm_surface_destroy()
515  *
516  * @par Example
517    @code
518    #include <tbm_surface.h>
519
520    tbm_surface_h surface;
521
522    surface = tbm_surface_create (128, 128, TBM_FORMAT_RGB332);
523
524    ...
525
526    tbm_surface_destroy (surface);
527    @endcode
528  */
529 tbm_surface_h tbm_surface_create (int width, int height, tbm_format format);
530
531 /**
532  * @brief Destroys the tbm_surface.
533  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
534  *
535  * @param[in] surface  The #tbm_surface_h
536  *
537  * @return  #TBM_SURFACE_ERROR_NONE on success,
538  *          otherwise an error status value
539  *
540  * @retval #TBM_SURFACE_ERROR_NONE               Success
541  * @retval #TBM_SURFACE_ERROR_INVALID_PARAMETER  Invalid parameter
542  *
543  * @see tbm_surface_create()
544  *
545  * @par Example
546    @code
547    #include <tbm_surface.h>
548
549    tbm_surface_h surface;
550
551    surface = tbm_surface_create (128, 128, TBM_FORMAT_RGB332);
552
553    ...
554
555    tbm_surface_destroy (surface);
556    @endcode
557  */
558 int tbm_surface_destroy (tbm_surface_h surface);
559
560 /**
561  * @brief Maps the tbm_surface according to the access option.
562  * @details After mapping tbm_surface, the information of tbm_surface is assigned in #tbm_surface_info_s struct. \n
563  *          The information of tbm_surface has width, height, format, bpp, size, number of planes and information of planes. \n
564  *          The information of planes has stride, offset, size and pointer of plane. \n
565  *          #TBM_SURF_OPTION_READ indicates access option to read. \n
566  *          #TBM_SURF_OPTION_WRITE indicates access option to write.
567  *
568  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
569  *
570  * @param[in]  surface  The #tbm_surface_h
571  * @param[in]  opt      The option to access the tbm_surface
572  * @param[out] info     The information of the tbm_surface
573  *
574  * @return  #TBM_SURFACE_ERROR_NONE on success,
575  *          otherwise an error status value
576  *
577  * @retval #TBM_SURFACE_ERROR_NONE               Success
578  * @retval #TBM_SURFACE_ERROR_INVALID_PARAMETER  Invalid parameter
579  * @retval #TBM_SURFACE_ERROR_INVALID_OPERATION  Invalid operation
580  *
581  * @see tbm_surface_unmap();
582  *
583  * @par Example
584    @code
585    #include <tbm_surface.h>
586
587    tbm_surface_h surface;
588    tbm_surface_info_s info;
589    int ret;
590
591    surface = tbm_surface_create (128, 128, TBM_FORMAT_RGB332);
592    ret = tbm_surface_map (surface, TBM_SURF_OPTION_WRITE|TBM_SURF_OPTION_READ, &info);
593
594    ...
595
596    tbm_surface_unmap (surface);
597    tbm_surface_destroy (surface);
598    @endcode
599  */
600 int tbm_surface_map (tbm_surface_h surface, int opt, tbm_surface_info_s *info);
601
602 /**
603  * @brief Unmaps the tbm_surface.
604  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
605  *
606  * @param[in] surface  The #tbm_surface_h
607  *
608  * @return  #TBM_SURFACE_ERROR_NONE on success,
609  *          otherwise an error status value
610  *
611  * @retval #TBM_SURFACE_ERROR_NONE               Success
612  * @retval #TBM_SURFACE_ERROR_INVALID_PARAMETER  Invalid parameter
613  *
614  * @see tbm_surface_map()
615  *
616  * @par Example
617    @code
618    #include <tbm_surface.h>
619
620    tbm_surface_h surface;
621    tbm_surface_info_s info;
622    int ret;
623
624    surface = tbm_surface_create (128, 128, TBM_FORMAT_RGB332);
625    ret = tbm_surface_map (surface, TBM_SURF_OPTION_WRITE|TBM_SURF_OPTION_READ, &info);
626
627    ...
628
629    tbm_surface_unmap (surface);
630    tbm_surface_destroy (surface);
631    @endcode
632  */
633 int tbm_surface_unmap (tbm_surface_h surface);
634
635 /**
636  * @brief Gets the information of the tbm_surface.
637  * @details The information of tbm_surface is assigned in #tbm_surface_info_s struct. \n
638  *          The information of tbm_surface has width, height, format, bpp, size, number of planes and information of planes. \n
639  *          The information of planes has stride, offset, size and pointer of plane.
640  *
641  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
642  *
643  * @param[in]   surface  The #tbm_surface_h
644  * @param[out]  info     The information of the tbm_surface
645  *
646  * @return  #TBM_SURFACE_ERROR_NONE on success,
647  *          otherwise an error status value
648  *
649  * @retval #TBM_SURFACE_ERROR_NONE               Success
650  * @retval #TBM_SURFACE_ERROR_INVALID_PARAMETER  Invalid parameter
651  * @retval #TBM_SURFACE_ERROR_INVALID_OPERATION  Invalid operation
652  *
653  * @see tbm_surface_map()
654  *
655  * @par Example
656    @code
657    #include <tbm_surface.h>
658
659    tbm_surface_h surface;
660    tbm_surface_info_s info;
661    int ret;
662
663    surface = tbm_surface_create (128, 128, TBM_FORMAT_RGB332);
664    ret = tbm_surface_get_info (surface, &info);
665
666    ...
667
668    tbm_surface_destroy (surface);
669    @endcode
670  */
671 int tbm_surface_get_info (tbm_surface_h surface, tbm_surface_info_s *info);
672
673 /**
674  * @brief Gets the width of the tbm_surface.
675  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
676  *
677  * @param[in] surface  The #tbm_surface_h
678  *
679  * @return  The width of the tbm_surface on success,
680  *          otherwise an error status value
681  *
682  * @retval #TBM_SURFACE_ERROR_INVALID_PARAMETER  Invalid parameter
683  *
684  * @par Example
685    @code
686    #include <tbm_surface.h>
687
688    tbm_surface_h surface;
689    int width;
690
691    surface = tbm_surface_create (128, 128, TBM_FORMAT_RGB332);
692
693    ...
694
695    width = tbm_surface_get_width (surface);
696
697    ...
698
699    tbm_surface_destroy (surface);
700    @endcode
701  */
702 int tbm_surface_get_width (tbm_surface_h surface);
703
704 /**
705  * @brief Gets the height of the tbm_surface.
706  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
707  *
708  * @param[in] surface  The #tbm_surface_h
709  *
710  * @return  The height of the tbm_surface if this function succeeds,
711  *          otherwise an error status value
712  *
713  * @retval #TBM_SURFACE_ERROR_INVALID_PARAMETER  Invalid parameter
714  *
715  * @par Example
716    @code
717    #include <tbm_surface.h>
718
719    tbm_surface_h surface;
720    int height;
721
722    surface = tbm_surface_create (128, 128, TBM_FORMAT_RGB332);
723
724    ...
725
726    height = tbm_surface_get_height (surface);
727
728    ...
729
730    tbm_surface_destroy (surface);
731    @endcode
732  */
733 int tbm_surface_get_height (tbm_surface_h surface);
734
735 /**
736  * @brief Gets the format of the tbm_surface.
737  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
738  *
739  * @remark The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
740  *
741  * @param[in] surface  The #tbm_surface_h
742  *
743  * @return  The format of the tbm_surface on success,
744  *          otherwise @c 0 on failure
745  *
746  * @retval #tbm_format  The format of surface
747  *
748  * @exception #TBM_SURFACE_ERROR_NONE               Success
749  * @exception #TBM_SURFACE_ERROR_INVALID_PARAMETER  Invalid parameter
750  *
751  * @par Example
752    @code
753    #include <tbm_surface.h>
754
755    tbm_surface_s surface;
756    tbm_format format;
757
758    surface = tbm_surface_create (128, 128, TBM_FORMAT_RGB332);
759
760    ...
761
762    format = tbm_surface_get_format (surface);
763
764    ...
765
766    tbm_surface_destroy (surface);
767    @endcode
768  */
769 tbm_format tbm_surface_get_format (tbm_surface_h surface);
770
771 #ifdef __cplusplus
772 }
773 #endif
774
775 /**
776 * @}
777 */
778
779 #endif /* _TBM_SURFACE_H_ */
780