1 /**************************************************************************
5 Copyright 2014 Samsung Electronics co., Ltd. All Rights Reserved.
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>
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:
19 The above copyright notice and this permission notice (including the
20 next paragraph) shall be included in all copies or substantial portions
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.
31 **************************************************************************/
33 #ifndef _TBM_SURFACE_H_
34 #define _TBM_SURFACE_H_
37 * @addtogroup CAPI_UI_TBM_SURFACE_MODULE
50 * @brief Enumeration for tbm_surface error type.
51 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
54 TBM_SURFACE_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
55 TBM_SURFACE_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
56 TBM_SURFACE_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid Operation */
57 } tbm_surface_error_e;
60 * @brief Definition for the max number of TBM surface plane.
61 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
63 #define TBM_SURF_PLANE_MAX 4
65 /* option to map the tbm_surface */
67 * @brief Definition for the access option to read.
68 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
70 #define TBM_SURF_OPTION_READ (1 << 0)
72 * @brief Definition for the access option to write.
73 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
75 #define TBM_SURF_OPTION_WRITE (1 << 1)
78 * @brief Definition for the TBM plane struct.
79 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
81 typedef struct _tbm_surface_plane {
82 unsigned char *ptr; /**< Plane pointer */
83 uint32_t size; /**< Plane size */
84 uint32_t offset; /**< Plane offset */
85 uint32_t stride; /**< Plane stride */
87 void *reserved1; /**< Reserved pointer1 */
88 void *reserved2; /**< Reserved pointer2 */
89 void *reserved3; /**< Reserved pointer3 */
90 } tbm_surface_plane_s;
93 * @brief Definition for the TBM surface information struct.
94 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
96 typedef struct _tbm_surface_info {
97 uint32_t width; /**< TBM surface width */
98 uint32_t height; /**< TBM surface height */
99 tbm_format format; /**< TBM surface format*/
100 uint32_t bpp; /**< TBM surface bbp */
101 uint32_t size; /**< TBM surface size */
103 uint32_t num_planes; /**< The number of planes */
104 tbm_surface_plane_s planes[TBM_SURF_PLANE_MAX]; /**< Array of planes */
106 void *reserved4; /**< Reserved pointer4 */
107 void *reserved5; /**< Reserved pointer5 */
108 void *reserved6; /**< Reserved pointer6 */
109 } tbm_surface_info_s;
116 * @brief Queries surface format list and number of format supported by the system.
117 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
119 * @remarks You must release the formats using free().
121 * @param[out] formats The format array which the system can support \n
122 * This pointer has to be freed by user.
123 * @param[out] num The number of formats
125 * @return #TBM_SURFACE_ERROR_NONE if this function succeeds,
126 * otherwise an error status value
128 * @retval #TBM_SURFACE_ERROR_NONE Success
129 * @retval #TBM_SURFACE_ERROR_INVALID_OPERATION Invalid operation
133 #include <tbm_surface.h>
138 tbm_surface_error_e tse;
140 tse = tbm_surface_query_formats (&formats, &format_num))
142 for( i = 0 ; i < format_num ; i++)
144 if (formats[i] == TBM_FORMAT_RGB332)
151 int tbm_surface_query_formats(uint32_t **formats, uint32_t *num);
154 * @brief Creates the tbm_surface.
155 * @details This function creates the tbm_surface with the given width, height, and format.
157 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
159 * @remark The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
161 * @param[in] width The width of surface
162 * @param[in] height The height of surface
163 * @param[in] format The format of surface
165 * @return #tbm_surface_h on success,
168 * @retval #tbm_surface_h The TBM surface handle
170 * @exception #TBM_SURFACE_ERROR_NONE Success
171 * @exception #TBM_SURFACE_ERROR_INVALID_PARAMETER Invalid parameter
172 * @exception #TBM_SURFACE_ERROR_INVALID_OPERATION Invalid operation
174 * @see tbm_surface_destroy()
178 #include <tbm_surface.h>
180 tbm_surface_h surface;
182 surface = tbm_surface_create (128, 128, TBM_FORMAT_RGB332);
186 tbm_surface_destroy (surface);
189 tbm_surface_h tbm_surface_create(int width, int height, tbm_format format);
192 * @brief Destroys the tbm_surface.
193 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
195 * @param[in] surface The #tbm_surface_h
197 * @return #TBM_SURFACE_ERROR_NONE on success,
198 * otherwise an error status value
200 * @retval #TBM_SURFACE_ERROR_NONE Success
201 * @retval #TBM_SURFACE_ERROR_INVALID_PARAMETER Invalid parameter
203 * @see tbm_surface_create()
207 #include <tbm_surface.h>
209 tbm_surface_h surface;
211 surface = tbm_surface_create (128, 128, TBM_FORMAT_RGB332);
215 tbm_surface_destroy (surface);
218 int tbm_surface_destroy(tbm_surface_h surface);
221 * @brief Maps the tbm_surface according to the access option.
222 * @details After mapping tbm_surface, the information of tbm_surface is assigned in #tbm_surface_info_s struct. \n
223 * The information of tbm_surface has width, height, format, bpp, size, number of planes and information of planes. \n
224 * The information of planes has stride, offset, size and pointer of plane. \n
225 * #TBM_SURF_OPTION_READ indicates access option to read. \n
226 * #TBM_SURF_OPTION_WRITE indicates access option to write.
228 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
230 * @param[in] surface The #tbm_surface_h
231 * @param[in] opt The option to access the tbm_surface
232 * @param[out] info The information of the tbm_surface
234 * @return #TBM_SURFACE_ERROR_NONE on success,
235 * otherwise an error status value
237 * @retval #TBM_SURFACE_ERROR_NONE Success
238 * @retval #TBM_SURFACE_ERROR_INVALID_PARAMETER Invalid parameter
239 * @retval #TBM_SURFACE_ERROR_INVALID_OPERATION Invalid operation
241 * @see tbm_surface_unmap();
245 #include <tbm_surface.h>
247 tbm_surface_h surface;
248 tbm_surface_info_s info;
251 surface = tbm_surface_create (128, 128, TBM_FORMAT_RGB332);
252 ret = tbm_surface_map (surface, TBM_SURF_OPTION_WRITE|TBM_SURF_OPTION_READ, &info);
256 tbm_surface_unmap (surface);
257 tbm_surface_destroy (surface);
260 int tbm_surface_map(tbm_surface_h surface, int opt, tbm_surface_info_s *info);
263 * @brief Unmaps the tbm_surface.
264 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
266 * @param[in] surface The #tbm_surface_h
268 * @return #TBM_SURFACE_ERROR_NONE on success,
269 * otherwise an error status value
271 * @retval #TBM_SURFACE_ERROR_NONE Success
272 * @retval #TBM_SURFACE_ERROR_INVALID_PARAMETER Invalid parameter
274 * @see tbm_surface_map()
278 #include <tbm_surface.h>
280 tbm_surface_h surface;
281 tbm_surface_info_s info;
284 surface = tbm_surface_create (128, 128, TBM_FORMAT_RGB332);
285 ret = tbm_surface_map (surface, TBM_SURF_OPTION_WRITE|TBM_SURF_OPTION_READ, &info);
289 tbm_surface_unmap (surface);
290 tbm_surface_destroy (surface);
293 int tbm_surface_unmap(tbm_surface_h surface);
296 * @brief Gets the information of the tbm_surface.
297 * @details The information of tbm_surface is assigned in #tbm_surface_info_s struct. \n
298 * The information of tbm_surface has width, height, format, bpp, size, number of planes and information of planes. \n
299 * The information of planes has stride, offset, size and pointer of plane.
301 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
303 * @param[in] surface The #tbm_surface_h
304 * @param[out] info The information of the tbm_surface
306 * @return #TBM_SURFACE_ERROR_NONE on success,
307 * otherwise an error status value
309 * @retval #TBM_SURFACE_ERROR_NONE Success
310 * @retval #TBM_SURFACE_ERROR_INVALID_PARAMETER Invalid parameter
311 * @retval #TBM_SURFACE_ERROR_INVALID_OPERATION Invalid operation
313 * @see tbm_surface_map()
317 #include <tbm_surface.h>
319 tbm_surface_h surface;
320 tbm_surface_info_s info;
323 surface = tbm_surface_create (128, 128, TBM_FORMAT_RGB332);
324 ret = tbm_surface_get_info (surface, &info);
328 tbm_surface_destroy (surface);
331 int tbm_surface_get_info(tbm_surface_h surface, tbm_surface_info_s *info);
334 * @brief Gets the width of the tbm_surface.
335 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
337 * @param[in] surface The #tbm_surface_h
339 * @return The width of the tbm_surface on success,
340 * otherwise an error status value
342 * @retval #TBM_SURFACE_ERROR_INVALID_PARAMETER Invalid parameter
346 #include <tbm_surface.h>
348 tbm_surface_h surface;
351 surface = tbm_surface_create (128, 128, TBM_FORMAT_RGB332);
355 width = tbm_surface_get_width (surface);
359 tbm_surface_destroy (surface);
362 int tbm_surface_get_width(tbm_surface_h surface);
365 * @brief Gets the height of the tbm_surface.
366 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
368 * @param[in] surface The #tbm_surface_h
370 * @return The height of the tbm_surface if this function succeeds,
371 * otherwise an error status value
373 * @retval #TBM_SURFACE_ERROR_INVALID_PARAMETER Invalid parameter
377 #include <tbm_surface.h>
379 tbm_surface_h surface;
382 surface = tbm_surface_create (128, 128, TBM_FORMAT_RGB332);
386 height = tbm_surface_get_height (surface);
390 tbm_surface_destroy (surface);
393 int tbm_surface_get_height(tbm_surface_h surface);
396 * @brief Gets the format of the tbm_surface.
397 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
399 * @remark The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
401 * @param[in] surface The #tbm_surface_h
403 * @return The format of the tbm_surface on success,
404 * otherwise @c 0 on failure
406 * @retval #tbm_format The format of surface
408 * @exception #TBM_SURFACE_ERROR_NONE Success
409 * @exception #TBM_SURFACE_ERROR_INVALID_PARAMETER Invalid parameter
413 #include <tbm_surface.h>
415 tbm_surface_s surface;
418 surface = tbm_surface_create (128, 128, TBM_FORMAT_RGB332);
422 format = tbm_surface_get_format (surface);
426 tbm_surface_destroy (surface);
429 tbm_format tbm_surface_get_format(tbm_surface_h surface);
437 #endif /* _TBM_SURFACE_H_ */