add tbm surface as the Core api
[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 of tbm_surface error type
51  * @since_tizen 2.3
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 2.3
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 2.3
70  */
71 #define TBM_SURF_OPTION_READ      (1 << 0)
72 /**
73  * @brief Definition for the access option to write.
74  * @since_tizen 2.3
75  */
76 #define TBM_SURF_OPTION_WRITE     (1 << 1)
77
78 /**
79  * @brief Definition for the tbm surface infomation struct.
80  * @since_tizen 2.3
81  */
82 typedef struct _tbm_surface_info
83 {
84     uint32_t width; /**< tbm surface width */
85     uint32_t height; /**< tbm surface height */
86     tbm_format format; /**<  tbm surface foramt*/
87     uint32_t bpp; /**< tbm surface bbp */
88     uint32_t size; /**< tbm surface size */
89
90     uint32_t num_planes; /**< the number of planes */
91
92     struct {
93         unsigned char *ptr; /**< plane pointer */
94         uint32_t size; /**< plane size */
95         uint32_t offset; /**< plane offset */
96         uint32_t stride; /**< plane stride */
97
98         void *reserved1;
99         void *reserved2;
100         void *reserved3;
101     } planes[TBM_SURF_PLANE_MAX]; /**< array of planes */
102
103     void *reserved4;
104     void *reserved5;
105     void *reserved6;
106 } tbm_surface_info_s;
107
108 #define __tbm_fourcc_code(a,b,c,d) ((uint32_t)(a) | ((uint32_t)(b) << 8) | \
109                               ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
110
111 /* color index */
112 /**
113  * @brief Definition for the tbm surface foramt C8 ([7:0] C)
114  * @since_tizen 2.3
115  */
116 #define TBM_FORMAT_C8           __tbm_fourcc_code('C', '8', ' ', ' ')
117
118 /* 8 bpp RGB */
119 /**
120  * @brief Definition for the tbm surface foramt RGB322  ([7:0] R:G:B 3:3:2)
121  * @since_tizen 2.3
122  */
123 #define TBM_FORMAT_RGB332       __tbm_fourcc_code('R', 'G', 'B', '8')
124 /**
125  * @brief Definition for the tbm surface foramt RGB233  ([7:0] B:G:R 2:3:3)
126  * @since_tizen 2.3
127  */
128 #define TBM_FORMAT_BGR233       __tbm_fourcc_code('B', 'G', 'R', '8')
129
130 /* 16 bpp RGB */
131 /**
132  * @brief Definition for the tbm surface foramt XRGB4444 ([15:0] x:R:G:B 4:4:4:4 little endian)
133  * @since_tizen 2.3
134  */
135 #define TBM_FORMAT_XRGB4444     __tbm_fourcc_code('X', 'R', '1', '2')
136 /**
137  * @brief Definition for the tbm surface foramt XBRG4444 ([15:0] x:B:G:R 4:4:4:4 little endian)
138  * @since_tizen 2.3
139  */
140 #define TBM_FORMAT_XBGR4444     __tbm_fourcc_code('X', 'B', '1', '2')
141 /**
142  * @brief Definition for the tbm surface foramt RGBX4444 ([15:0] R:G:B:x 4:4:4:4 little endian)
143  * @since_tizen 2.3
144  */
145 #define TBM_FORMAT_RGBX4444     __tbm_fourcc_code('R', 'X', '1', '2')
146 /**
147  * @brief Definition for the tbm surface foramt BGRX4444 ([15:0] B:G:R:x 4:4:4:4 little endian)
148  * @since_tizen 2.3
149  */
150 #define TBM_FORMAT_BGRX4444     __tbm_fourcc_code('B', 'X', '1', '2')
151
152 /**
153  * @brief Definition for the tbm surface foramt ARGB4444 ([15:0] A:R:G:B 4:4:4:4 little endian)
154  * @since_tizen 2.3
155  */
156 #define TBM_FORMAT_ARGB4444     __tbm_fourcc_code('A', 'R', '1', '2')
157 /**
158  * @brief Definition for the tbm surface foramt ABGR4444 ([15:0] A:B:G:R 4:4:4:4 little endian)
159  * @since_tizen 2.3
160  */
161 #define TBM_FORMAT_ABGR4444     __tbm_fourcc_code('A', 'B', '1', '2')
162 /**
163  * @brief Definition for the tbm surface foramt RGBA4444 ([15:0] R:G:B:A 4:4:4:4 little endian)
164  * @since_tizen 2.3
165  */
166 #define TBM_FORMAT_RGBA4444     __tbm_fourcc_code('R', 'A', '1', '2')
167 /**
168  * @brief Definition for the tbm surface foramt BGRA4444 ([15:0] B:G:R:A 4:4:4:4 little endian)
169  * @since_tizen 2.3
170  */
171 #define TBM_FORMAT_BGRA4444     __tbm_fourcc_code('B', 'A', '1', '2')
172
173 /**
174  * @brief Definition for the tbm surface foramt XRGB1555 ([15:0] x:R:G:B 1:5:5:5 little endian)
175  * @since_tizen 2.3
176  */
177 #define TBM_FORMAT_XRGB1555     __tbm_fourcc_code('X', 'R', '1', '5')
178 /**
179  * @brief Definition for the tbm surface foramt XBGR1555 ([15:0] x:B:G:R 1:5:5:5 little endian)
180  * @since_tizen 2.3
181  */
182 #define TBM_FORMAT_XBGR1555     __tbm_fourcc_code('X', 'B', '1', '5')
183 /**
184  * @brief Definition for the tbm surface foramt RGBX5551 ([15:0] R:G:B:x 5:5:5:1 little endian)
185  * @since_tizen 2.3
186  */
187 #define TBM_FORMAT_RGBX5551     __tbm_fourcc_code('R', 'X', '1', '5')
188 /**
189  * @brief Definition for the tbm surface foramt BGRX5551 ([15:0] B:G:R:x 5:5:5:1 little endian)
190  * @since_tizen 2.3
191  */
192 #define TBM_FORMAT_BGRX5551     __tbm_fourcc_code('B', 'X', '1', '5')
193
194 /**
195  * @brief Definition for the tbm surface foramt ARGB1555 ([15:0] A:R:G:B 1:5:5:5 little endian)
196  * @since_tizen 2.3
197  */
198 #define TBM_FORMAT_ARGB1555     __tbm_fourcc_code('A', 'R', '1', '5')
199 /**
200  * @brief Definition for the tbm surface foramt ABGR1555 ([15:0] A:B:G:R 1:5:5:5 little endian)
201  * @since_tizen 2.3
202  */
203 #define TBM_FORMAT_ABGR1555     __tbm_fourcc_code('A', 'B', '1', '5')
204 /**
205  * @brief Definition for the tbm surface foramt RGBA5551 ([15:0] R:G:B:A 5:5:5:1 little endian)
206  * @since_tizen 2.3
207  */
208 #define TBM_FORMAT_RGBA5551     __tbm_fourcc_code('R', 'A', '1', '5')
209 /**
210  * @brief Definition for the tbm surface foramt BGRA5551 ([15:0] B:G:R:A 5:5:5:1 little endian)
211  * @since_tizen 2.3
212  */
213 #define TBM_FORMAT_BGRA5551     __tbm_fourcc_code('B', 'A', '1', '5')
214
215 /**
216  * @brief Definition for the tbm surface foramt RGB565 ([15:0] R:G:B 5:6:5 little endian)
217  * @since_tizen 2.3
218  */
219 #define TBM_FORMAT_RGB565       __tbm_fourcc_code('R', 'G', '1', '6')
220 /**
221  * @brief Definition for the tbm surface foramt BGR565 ([15:0] B:G:R 5:6:5 little endian)
222  * @since_tizen 2.3
223  */
224 #define TBM_FORMAT_BGR565       __tbm_fourcc_code('B', 'G', '1', '6')
225
226 /* 24 bpp RGB */
227 /**
228  * @brief Definition for the tbm surface foramt RGB888 ([23:0] R:G:B little endian)
229  * @since_tizen 2.3
230  */
231 #define TBM_FORMAT_RGB888       __tbm_fourcc_code('R', 'G', '2', '4')
232 /**
233  * @brief Definition for the tbm surface foramt BGR888 ([23:0] B:G:R little endian)
234  * @since_tizen 2.3
235  */
236 #define TBM_FORMAT_BGR888       __tbm_fourcc_code('B', 'G', '2', '4')
237
238 /* 32 bpp RGB */
239 /**
240  * @brief Definition for the tbm surface foramt XRGB8888 ([31:0] x:R:G:B 8:8:8:8 little endian)
241  * @since_tizen 2.3
242  */
243 #define TBM_FORMAT_XRGB8888     __tbm_fourcc_code('X', 'R', '2', '4')
244 /**
245  * @brief Definition for the tbm surface foramt XBGR8888 ([31:0] x:B:G:R 8:8:8:8 little endian)
246  * @since_tizen 2.3
247  */
248 #define TBM_FORMAT_XBGR8888     __tbm_fourcc_code('X', 'B', '2', '4')
249 /**
250  * @brief Definition for the tbm surface foramt RGBX8888 ([31:0] R:G:B:x 8:8:8:8 little endian)
251  * @since_tizen 2.3
252  */
253 #define TBM_FORMAT_RGBX8888     __tbm_fourcc_code('R', 'X', '2', '4')
254 /**
255  * @brief Definition for the tbm surface foramt BGRX8888 ([31:0] B:G:R:x 8:8:8:8 little endian)
256  * @since_tizen 2.3
257  */
258 #define TBM_FORMAT_BGRX8888     __tbm_fourcc_code('B', 'X', '2', '4')
259
260 /**
261  * @brief Definition for the tbm surface foramt ARGB8888 ([31:0] A:R:G:B 8:8:8:8 little endian)
262  * @since_tizen 2.3
263  */
264 #define TBM_FORMAT_ARGB8888     __tbm_fourcc_code('A', 'R', '2', '4')
265 /**
266  * @brief Definition for the tbm surface foramt ABGR8888 ([31:0] [31:0] A:B:G:R 8:8:8:8 little endian)
267  * @since_tizen 2.3
268  */
269 #define TBM_FORMAT_ABGR8888     __tbm_fourcc_code('A', 'B', '2', '4')
270 /**
271  * @brief Definition for the tbm surface foramt RGBA8888 ([31:0] R:G:B:A 8:8:8:8 little endian)
272  * @since_tizen 2.3
273  */
274 #define TBM_FORMAT_RGBA8888     __tbm_fourcc_code('R', 'A', '2', '4')
275 /**
276  * @brief Definition for the tbm surface foramt BGRA8888 ([31:0] B:G:R:A 8:8:8:8 little endian)
277  * @since_tizen 2.3
278  */
279 #define TBM_FORMAT_BGRA8888     __tbm_fourcc_code('B', 'A', '2', '4')
280
281 /**
282  * @brief Definition for the tbm surface foramt XRGB2101010 ([31:0] x:R:G:B 2:10:10:10 little endian)
283  * @since_tizen 2.3
284  */
285 #define TBM_FORMAT_XRGB2101010  __tbm_fourcc_code('X', 'R', '3', '0')
286 /**
287  * @brief Definition for the tbm surface foramt XBGR2101010 ([31:0] x:B:G:R 2:10:10:10 little endian)
288  * @since_tizen 2.3
289  */
290 #define TBM_FORMAT_XBGR2101010  __tbm_fourcc_code('X', 'B', '3', '0')
291 /**
292  * @brief Definition for the tbm surface foramt RGBX1010102 ([31:0] R:G:B:x 10:10:10:2 little endian)
293  * @since_tizen 2.3
294  */
295 #define TBM_FORMAT_RGBX1010102  __tbm_fourcc_code('R', 'X', '3', '0')
296 /**
297  * @brief Definition for the tbm surface foramt BGRX1010102 ([31:0] B:G:R:x 10:10:10:2 little endian)
298  * @since_tizen 2.3
299  */
300 #define TBM_FORMAT_BGRX1010102  __tbm_fourcc_code('B', 'X', '3', '0')
301
302 /**
303  * @brief Definition for the tbm surface foramt ARGB2101010 ([31:0] A:R:G:B 2:10:10:10 little endian)
304  * @since_tizen 2.3
305  */
306 #define TBM_FORMAT_ARGB2101010  __tbm_fourcc_code('A', 'R', '3', '0')
307 /**
308  * @brief Definition for the tbm surface foramt ABGR2101010 ([31:0] A:B:G:R 2:10:10:10 little endian)
309  * @since_tizen 2.3
310  */
311 #define TBM_FORMAT_ABGR2101010  __tbm_fourcc_code('A', 'B', '3', '0')
312 /**
313  * @brief Definition for the tbm surface foramt RGBA1010102 ([31:0] R:G:B:A 10:10:10:2 little endian)
314  * @since_tizen 2.3
315  */
316 #define TBM_FORMAT_RGBA1010102  __tbm_fourcc_code('R', 'A', '3', '0')
317 /**
318  * @brief Definition for the tbm surface foramt BGRA1010102 ([31:0] B:G:R:A 10:10:10:2 little endian)
319  * @since_tizen 2.3
320  */
321 #define TBM_FORMAT_BGRA1010102  __tbm_fourcc_code('B', 'A', '3', '0') /*  */
322
323 /* packed YCbCr */
324 /**
325  * @brief Definition for the tbm surface foramt YUYV ([31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian)
326  * @since_tizen 2.3
327  */
328 #define TBM_FORMAT_YUYV         __tbm_fourcc_code('Y', 'U', 'Y', 'V')
329 /**
330  * @brief Definition for the tbm surface foramt YVYU ([31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian)
331  * @since_tizen 2.3
332  */
333 #define TBM_FORMAT_YVYU         __tbm_fourcc_code('Y', 'V', 'Y', 'U') /*  */
334 /**
335  * @brief Definition for the tbm surface foramt UYVY ([31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian )
336  * @since_tizen 2.3
337  */
338 #define TBM_FORMAT_UYVY         __tbm_fourcc_code('U', 'Y', 'V', 'Y')
339 /**
340  * @brief Definition for the tbm surface foramt VYUY ([31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian)
341  * @since_tizen 2.3
342  */
343 #define TBM_FORMAT_VYUY         __tbm_fourcc_code('V', 'Y', 'U', 'Y')
344
345 /**
346  * @brief Definition for the tbm surface foramt AYUV ([31:0] A:Y:Cb:Cr 8:8:8:8 little endian)
347  * @since_tizen 2.3
348  */
349 #define TBM_FORMAT_AYUV         __tbm_fourcc_code('A', 'Y', 'U', 'V')
350
351 /*
352  * 2 plane YCbCr
353  * index 0 = Y plane, [7:0] Y
354  * index 1 = Cr:Cb plane, [15:0] Cr:Cb little endian
355  * or
356  * index 1 = Cb:Cr plane, [15:0] Cb:Cr little endian
357  */
358 /**
359  * @brief Definition for the tbm surface foramt NV12 (2x2 subsampled Cr:Cb plane)
360  * @since_tizen 2.3
361  */
362 #define TBM_FORMAT_NV12         __tbm_fourcc_code('N', 'V', '1', '2')
363 /**
364  * @brief Definition for the tbm surface foramt NV21 (2x2 subsampled Cb:Cr plane)
365  * @since_tizen 2.3
366  */
367 #define TBM_FORMAT_NV21         __tbm_fourcc_code('N', 'V', '2', '1') /*  */
368 /**
369  * @brief Definition for the tbm surface foramt NV16 (2x1 subsampled Cr:Cb plane)
370  * @since_tizen 2.3
371  */
372 #define TBM_FORMAT_NV16         __tbm_fourcc_code('N', 'V', '1', '6')
373 /**
374  * @brief Definition for the tbm surface foramt NV61 (2x1 subsampled Cb:Cr plane)
375  * @since_tizen 2.3
376  */
377 #define TBM_FORMAT_NV61         __tbm_fourcc_code('N', 'V', '6', '1')
378
379 /*
380  * 3 plane YCbCr
381  * index 0: Y plane, [7:0] Y
382  * index 1: Cb plane, [7:0] Cb
383  * index 2: Cr plane, [7:0] Cr
384  * or
385  * index 1: Cr plane, [7:0] Cr
386  * index 2: Cb plane, [7:0] Cb
387  */
388 /**
389  * @brief Definition for the tbm surface foramt YUV410 (4x4 subsampled Cb (1) and Cr (2) planes)
390  */
391 #define TBM_FORMAT_YUV410       __tbm_fourcc_code('Y', 'U', 'V', '9')
392 /**
393  * @brief Definition for the tbm surface foramt YVU410 (4x4 subsampled Cr (1) and Cb (2) planes)
394  * @since_tizen 2.3
395  */
396 #define TBM_FORMAT_YVU410       __tbm_fourcc_code('Y', 'V', 'U', '9')
397 /**
398  * @brief Definition for the tbm surface foramt YUV411 (4x1 subsampled Cb (1) and Cr (2) planes)
399  * @since_tizen 2.3
400  */
401 #define TBM_FORMAT_YUV411       __tbm_fourcc_code('Y', 'U', '1', '1')
402 /**
403  * @brief Definition for the tbm surface foramt YVU411 (4x1 subsampled Cr (1) and Cb (2) planes)
404  * @since_tizen 2.3
405  */
406 #define TBM_FORMAT_YVU411       __tbm_fourcc_code('Y', 'V', '1', '1')
407 /**
408  * @brief Definition for the tbm surface foramt YUV420 (2x2 subsampled Cb (1) and Cr (2) planes)
409  * @since_tizen 2.3
410  */
411 #define TBM_FORMAT_YUV420       __tbm_fourcc_code('Y', 'U', '1', '2')
412 /**
413  * @brief Definition for the tbm surface foramt YVU420 (2x2 subsampled Cr (1) and Cb (2) planes)
414  * @since_tizen 2.3
415  */
416 #define TBM_FORMAT_YVU420       __tbm_fourcc_code('Y', 'V', '1', '2')
417 /**
418  * @brief Definition for the tbm surface foramt YUV422 (2x1 subsampled Cb (1) and Cr (2) planes)
419  * @since_tizen 2.3
420  */
421 #define TBM_FORMAT_YUV422       __tbm_fourcc_code('Y', 'U', '1', '6')
422 /**
423  * @brief Definition for the tbm surface foramt YVU422 (2x1 subsampled Cr (1) and Cb (2) planes)
424  * @since_tizen 2.3
425  */
426 #define TBM_FORMAT_YVU422       __tbm_fourcc_code('Y', 'V', '1', '6')
427 /**
428  * @brief Definition for the tbm surface foramt YUV444 (non-subsampled Cb (1) and Cr (2) planes)
429  * @since_tizen 2.3
430  */
431 #define TBM_FORMAT_YUV444       __tbm_fourcc_code('Y', 'U', '2', '4')
432 /**
433  * @brief Definition for the tbm surface foramt YVU444 (non-subsampled Cr (1) and Cb (2) planes)
434  * @since_tizen 2.3
435  */
436 #define TBM_FORMAT_YVU444       __tbm_fourcc_code('Y', 'V', '2', '4')
437
438 #ifdef __cplusplus
439 extern "C" {
440 #endif
441
442 /**
443  * @brief Queries surface format list and number of format supported by the system.
444  * @since_tizen 2.3
445  * @remarks The formats must be released using free().
446  * @param[out] **formats : format array which the system can support. This pointer has to be freed by user.
447  * @param[out] num : the number of formats.
448  * @return #TBM_SURFACE_ERROR_NONE if this function succeeds, otherwise error status value
449  * @retval #TBM_SURFACE_ERROR_NONE
450  * @retval #TBM_SURFACE_ERROR_INVALID_OPERATION
451  * @par Example
452    @code
453    #include <tbm_surface.h>
454
455    uint32_t *formats;
456    uint32_t format_num;
457    int ret, i;
458
459    if (tbm_surface_query_formats (&formats, &format_num))
460    {
461        for( i = 0 ; i < format_num ; i++)
462        {
463            if (formats[i] == TBM_FORMAT_RGB332)
464            {
465
466    ....
467
468    free (formats);
469    @endcode
470  */
471 int tbm_surface_query_formats (uint32_t **formats, uint32_t *num);
472
473 /**
474  * @brief Creates the tbm_surface.
475  * @details This function create the tbm_surface with width, height, format.
476  * @since_tizen 2.3
477  * @remark The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
478  * @param[in] width  : the width of surface
479  * @param[in] height : the height of surface
480  * @param[in] format : the format of surface
481  * @return a tbm_surface_h if this function succeeds, otherwise NULL
482  * @retval #tbm_surface_h
483  * @exception #TBM_SURFACE_ERROR_NONE Success
484  * @exception #TBM_SURFACE_ERROR_INVALID_PARAMETER  Invalid parameter
485  * @exception #TBM_SURFACE_ERROR_INVALID_OPERATION Invalid operation
486  * @see tbm_surface_destroy()
487  * @par Example
488    @code
489    #include <tbm_surface.h>
490
491    tbm_surface_h surface;
492
493    surface = tbm_surface_create (128, 128, TBM_FORMAT_RGB332);
494
495    ...
496
497    tbm_surface_destroy (surface);
498    @endcode
499  */
500 tbm_surface_h tbm_surface_create (int width, int height, tbm_format format);
501
502 /**
503  * @brief Destroies the tbm_surface.
504  * @since_tizen 2.3
505  * @param[in] surface : the tbm_surface_h
506  * @return #TBM_SURFACE_ERROR_NONE if this function succeeds, otherwise error status value
507  * @retval #TBM_SURFACE_ERROR_NONE
508  * @retval #TBM_SURFACE_ERROR_INVALID_PARAMETER
509  * @see tbm_surface_create()
510  * @par Example
511    @code
512    #include <tbm_surface.h>
513
514    tbm_surface_h surface;
515
516    surface = tbm_surface_create (128, 128, TBM_FORMAT_RGB332);
517
518    ...
519
520    tbm_surface_destroy (surface);
521    @endcode
522  */
523 int tbm_surface_destroy (tbm_surface_h surface);
524
525 /**
526  * @brief Maps the tbm_surface according to the access option.
527  * @details After mapping tbm_surface, the information of tbm_surface is assigned in #tbm_surface_info_s struct.\n
528  * The information of tbm_surface has width, height, format, bpp, size, number of planes and information of planes.\n
529  * The information of planes has stride, offset, size and pointer of plane\n
530  * #TBM_SURF_OPTION_READ indecates access option to read.\n
531  * #TBM_SURF_OPTION_WRITE indecates access option to write.
532  * @since_tizen 2.3
533  * @param[in] surface : the tbm_surface_h
534  * @param[in] opt : the option to access the tbm_surface
535  * @param[out] *info : the infomation of the tbm_surface
536  * @return #TBM_SURFACE_ERROR_NONE if this function succeeds, otherwise error status value
537  * @retval #TBM_SURFACE_ERROR_NONE
538  * @retval #TBM_SURFACE_ERROR_INVALID_PARAMETER
539  * @retval #TBM_SURFACE_ERROR_INVALID_OPERATION
540  * @see tbm_surface_unmap();
541  * @par Example
542    @code
543    #include <tbm_surface.h>
544
545    tbm_surface_h surface;
546    tbm_surface_info_s info;
547    int ret;
548
549    surface = tbm_surface_create (128, 128, TBM_FORMAT_RGB332);
550    ret = tbm_surface_map (surface, TBM_SURF_OPTION_WRITE|TBM_SURF_OPTION_READ, &info);
551
552    ...
553
554    tbm_surface_unmap (surface);
555    tbm_surface_destroy (surface);
556    @endcode
557  */
558 int tbm_surface_map (tbm_surface_h surface, int opt, tbm_surface_info_s *info);
559
560 /**
561  * @brief Unmaps the tbm_surface.
562  * @since_tizen 2.3
563  * @param[in] surface : the tbm_surface_h
564  * @return #TBM_SURFACE_ERROR_NONE if this function succeeds, otherwise error status value
565  * @retval #TBM_SURFACE_ERROR_NONE
566  * @retval #TBM_SURFACE_ERROR_INVALID_PARAMETER
567  * @see tbm_surface_map()
568  * @par Example
569    @code
570    #include <tbm_surface.h>
571
572    tbm_surface_h surface;
573    tbm_surface_info_s info;
574    int ret;
575
576    surface = tbm_surface_create (128, 128, TBM_FORMAT_RGB332);
577    ret = tbm_surface_map (surface, TBM_SURF_OPTION_WRITE|TBM_SURF_OPTION_READ, &info);
578
579    ...
580
581    tbm_surface_unmap (surface);
582    tbm_surface_destroy (surface);
583    @endcode
584  */
585 int tbm_surface_unmap (tbm_surface_h surface);
586
587 /**
588  * @brief Gets the information of the tbm_surface.
589  * @details The information of tbm_surface is assigned in #tbm_surface_info_s struct.\n
590  * The information of tbm_surface has width, height, format, bpp, size, number of planes and information of planes.\n
591  * The information of planes has stride, offset, size and pointer of plane.
592  * @since_tizen 2.3
593  * @param[in] surface : the tbm_surface_h
594  * @param[out] *info : the infomation of the tbm_surface
595  * @return #TBM_SURFACE_ERROR_NONE if this function succeeds, otherwise error status value
596  * @retval #TBM_SURFACE_ERROR_NONE
597  * @retval #TBM_SURFACE_ERROR_INVALID_PARAMETER
598  * @retval #TBM_SURFACE_ERROR_INVALID_OPERATION
599  * @see tbm_surface_map()
600  * @par Example
601    @code
602    #include <tbm_surface.h>
603
604    tbm_surface_h surface;
605    tbm_surface_info_s info;
606    int ret;
607
608    surface = tbm_surface_create (128, 128, TBM_FORMAT_RGB332);
609    ret = tbm_surface_get_info (surface, &info);
610
611    ...
612
613    tbm_surface_destroy (surface);
614    @endcode
615  */
616 int tbm_surface_get_info (tbm_surface_h surface, tbm_surface_info_s *info);
617
618 /**
619  * @brief Gets the width of the tbm_surface.
620  * @since_tizen 2.3
621  * @param[in] surface : the tbm_surface_h
622  * @return the width of the tbm_surface if this function succeeds, otherwise error status value
623  * @retval #TBM_SURFACE_ERROR_INVALID_PARAMETER
624  * @par Example
625    @code
626    #include <tbm_surface.h>
627
628    tbm_surface_h surface;
629    int width;
630
631    surface = tbm_surface_create (128, 128, TBM_FORMAT_RGB332);
632
633    ...
634
635    width = tbm_surface_get_width (surface);
636
637    ...
638
639    tbm_surface_destroy (surface);
640    @endcode
641  */
642 int tbm_surface_get_width (tbm_surface_h surface);
643
644 /**
645  * @brief Gets the height of the tbm_surface.
646  * @since_tizen 2.3
647  * @param[in] surface : the tbm_surface_h
648  * @return the height of the tbm_surface if this function succeeds, otherwise error status value
649  * @retval #TBM_SURFACE_ERROR_INVALID_PARAMETER
650  * @par Example
651    @code
652    #include <tbm_surface.h>
653
654    tbm_surface_h surface;
655    int height;
656
657    surface = tbm_surface_create (128, 128, TBM_FORMAT_RGB332);
658
659    ...
660
661    height = tbm_surface_get_height (surface);
662
663    ...
664
665    tbm_surface_destroy (surface);
666    @endcode
667  */
668 int tbm_surface_get_height (tbm_surface_h surface);
669
670 /**
671  * @brief Gets the format of the tbm_surface.
672  * @since_tizen 2.3
673  * @remark The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
674  * @param[in] surface : the tbm_surface_h
675  * @return the format of the tbm_surface if this function succeeds, otherwise 0
676  * @retval #tbm_format
677  * @exception #TBM_SURFACE_ERROR_NONE Success
678  * @exception #TBM_SURFACE_ERROR_INVALID_PARAMETER  Invalid parameter
679  * @par Example
680    @code
681    #include <tbm_surface.h>
682
683    tbm_surface_s surface;
684    tbm_format format;
685
686    surface = tbm_surface_create (128, 128, TBM_FORMAT_RGB332);
687
688    ...
689
690    format = tbm_surface_get_format (surface);
691
692    ...
693
694    tbm_surface_destroy (surface);
695    @endcode
696  */
697 tbm_format tbm_surface_get_format (tbm_surface_h surface);
698
699 #ifdef __cplusplus
700 }
701 #endif
702
703 /**
704 * @}
705 */
706
707 #endif /* _TBM_SURFACE_H_ */
708