1 #ifndef _TBM_SURFACE_INTERNAL_H_
2 #define _TBM_SURFACE_INTERNAL_H_
4 #include <tbm_bufmgr.h>
8 * @brief Queries formats which the system can support.
9 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
10 * @remarks The formats must be released using free().
11 * @param[in] bufmgr : the buffer manager
12 * @param[out] *formats : format array which the system can support. This pointer has to be freed by user.
13 * @param[out] num : the number of formats.
14 * @return a tbm_surface_h if this function succeeds, otherwise NULL
17 #include <tbm_surface.h>
18 #include <tbm_surface_internal.h>
24 bufmgr = tbm_bufmgr_create (-1);
25 ret = tbm_surface_internal_query_surpported_foramts (bufmgr, &formats, &format_num);
30 tbm_surface_bufmgr_deinit (bufmgr);
33 int tbm_surface_internal_query_supported_formats(uint32_t **formats,
37 * @brief Creates the tbm_surface with memory type.
38 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
40 * #TBM_BO_DEFAULT is default memory: it depends on the backend\n
41 * #TBM_BO_SCANOUT is scanout memory\n
42 * #TBM_BO_NONCACHABLE is non-cachable memory\n
43 * #TBM_BO_WC is write-combine memory\n
44 * #TBM_BO_VENDOR vendor specific memory: it depends on the tbm backend\n
45 * @param[in] bufmgr : the buffer manager
46 * @param[in] width : the width of surface
47 * @param[in] height : the height of surface
48 * @param[in] format : the format of surface
49 * @param[in] flags : the flags of memory type
50 * @return a tbm_surface_h if this function succeeds, otherwise NULL
51 * @retval #tbm_surface_h
54 #include <tbm_surface.h>
55 #include <tbm_surface_internal.h>
59 tbm_surface_h surface;
63 bufmgr = tbm_bufmgr_create (bufmgr_fd);
64 surface = tbm_surface_internal_create_with_flags (128, 128, TBM_FORMAT_YUV420, TBM_BO_DEFAULT);
68 tbm_surface_destroy (surface);
69 tbm_surface_bufmgr_deinit (bufmgr);
72 tbm_surface_h tbm_surface_internal_create_with_flags(int width, int height,
73 int format, int flags);
76 * @brief Creates the tbm_surface with buffer objects.
77 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
78 * @param[in] bufmgr : the buffer manager
79 * @param[in] width : the width of surface
80 * @param[in] height : the height of surface
81 * @param[in] format : the format of surface
82 * @param[in] *bos : the array pointer of buffer objects
83 * @param[in] num : the number of buffer objects
84 * @return a tbm_surface_h if this function succeeds, otherwise NULL
85 * @retval #tbm_surface_h
88 #include <tbm_bufmgr.h>
89 #include <tbm_surface.h>
90 #include <tbm_surface_internal.h>
94 tbm_surface_h surface;
95 tbm_surface_info_s info;
100 bufmgr = tbm_bufmgr_init (bufmgr_fd);
101 bo[0] = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
105 info.format = TBM_FORMAT_ARGB8888;
109 info.planes[0].size = 65536;
110 info.planes[0].offset = 0;
111 info.planes[0].stride = 512;
113 surface = tbm_surface_internal_create_with_bos (&info, bo, 1);
117 tbm_surface_destroy (surface);
118 tbm_surface_bufmgr_deinit (bufmgr);
121 tbm_surface_h tbm_surface_internal_create_with_bos(tbm_surface_info_s *info,
122 tbm_bo *bos, int num);
125 * @brief Destroy the tbm surface
128 void tbm_surface_internal_destroy(tbm_surface_h surface);
131 * @brief reference the tbm surface
134 void tbm_surface_internal_ref(tbm_surface_h surface);
137 * @brief unreference the tbm surface
140 void tbm_surface_internal_unref(tbm_surface_h surface);
143 * @brief Gets the number of buffer objects associated with the tbm_surface.
144 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
145 * @param[in] surface : the tbm_surface_h
146 * @return the number of buffer objects associated with the tbm_surface_h, otherwise 0.
149 #include <tbm_surface.h>
150 #include <tbm_surface_internal.h>
152 tbm_surface_h surface;
155 surface = tbm_surface_create (128, 128, TBM_FORMAT_YUV420);
156 num_bos = tbm_surface_internal_get_num_bos (surface);
160 tbm_surface_destroy (surface);
163 int tbm_surface_internal_get_num_bos(tbm_surface_h surface);
166 * @brief Gets the buffor object by the bo_index.
167 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
168 * @param[in] surface : the tbm_surface_h
169 * @param[in] bo_idx : the bo index in the the tbm_surface
170 * @return the buffer object, otherwise NULL.
174 #include <tbm_surface.h>
175 #include <tbm_surface_internal.h>
177 tbm_surface_h surface;
181 surface = tbm_surface_create (128, 128, TBM_FORMAT_YUV420);
182 num_bos = tbm_surface_internal_get_num_bos (surface);
184 for (i=0 ; i < num_bos ; i++)
186 bo = tbm_surface_internal_get_bo (surface, i);
190 tbm_surface_destroy (surface);
193 tbm_bo tbm_surface_internal_get_bo(tbm_surface_h surface, int bo_idx);
196 * @brief Gets the size of the surface.
197 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
198 * @param[in] surface : the tbm_surface_h
199 * @return the size of tbm_surface, otherwise 0.
202 #include <tbm_surface.h>
203 #include <tbm_surface_internal.h>
205 tbm_surface_h surface;
208 surface = tbm_surface_create (128, 128, TBM_FORMAT_YUV420);
209 size = tbm_surface_internal_get_size (surface);
211 tbm_surface_destroy (surface);
214 unsigned int tbm_surface_internal_get_size(tbm_surface_h surface);
217 * @brief Gets size, offset and pitch data of plane by the plane_index.
218 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
219 * @param[in] surface : the tbm_surface_h
220 * @param[in] plane_idx : the bo index in the the tbm_surface
221 * @param[out] size : the size of plane in tbm_surface
222 * @param[out] offset : the offset of plane in tbm_surface
223 * @param[out] pitch : the pitch of plane in tbm_surface
224 * @return 1 if this function succeeds, otherwise 0.
227 #include <tbm_surface.h>
228 #include <tbm_surface_internal.h>
230 tbm_surface_h surface;
231 uint32_t size, offset, pitch;
234 surface = tbm_surface_create (128, 128, TBM_FORMAT_YUV420);
235 ret = tbm_surface_internal_get_plane_data (surface, 1, &size, &offset, &pitch);
239 tbm_surface_destroy (surface);
242 int tbm_surface_internal_get_plane_data(tbm_surface_h surface, int plane_idx,
243 uint32_t *size, uint32_t *offset, uint32_t *pitch);
246 * @brief Gets number of planes by the format.
247 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
248 * @param[in] format : the format of surface
249 * @return number of planes by the format, otherwise 0.
252 #include <tbm_surface.h>
253 #include <tbm_surface_internal.h>
257 num = tbm_surface_internal_get_num_planes (TBM_FORMAT_YUV420);
263 int tbm_surface_internal_get_num_planes(tbm_format format);
266 * @brief Gets bpp by the format.
267 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
268 * @param[in] format : the format of surface
269 * @return bpp by the format, otherwise 0.
272 #include <tbm_surface.h>
273 #include <tbm_surface_internal.h>
277 bpp = tbm_surface_internal_get_bpp (TBM_FORMAT_YUV420);
283 int tbm_surface_internal_get_bpp(tbm_format format);
286 * @brief Gets bo index of plane.
288 * @param[in] surface : the tbm_surface_h
289 * @param[in] plane_idx : the bo index in the tbm_surface
290 * @return bo index of plane, otherwise 0.
293 #include <tbm_surface.h>
294 #include <tbm_surface_internal.h>
297 tbm_surface_h surface;
299 surface = tbm_surface_create (128, 128, TBM_FORMAT_YUV420);
300 bo_idx = tbm_surface_internal_get_plane_bo_idx (surface, 0);
306 int tbm_surface_internal_get_plane_bo_idx(tbm_surface_h surface, int plane_idx);
309 * @brief Set the pid to the tbm_surface for debugging.
311 * @param[in] surface : the tbm_surface_h
312 * @param[in] pid : the pid
314 void tbm_surface_internal_set_debug_pid(tbm_surface_h surface,
318 * @brief Adds a user_data to the tbm surface.
320 * @param[in] surface : the tbm surface.
321 * @param[in] key : the key associated with the user_data
322 * @param[in] data_free_func : the function pointer to free the user_data
323 * @return 1 if this function succeeds, otherwise 0.
324 * @post the tbm_surface_data_free() will be called under certain conditions, after calling tbm_surface_internal_delete_user_data().
325 * @see tbm_surface_free()
326 * @see tbm_surface_set_user_data()
327 * @see tbm_surface_get_user_data()
328 * @see tbm_surface_delete_user_data()
330 int tbm_surface_internal_add_user_data(tbm_surface_h surface, unsigned long key,
331 tbm_data_free data_free_func);
334 * @brief Sets a user_date to the tbm surface.
336 * @param[in] surface : the tbm surface.
337 * @param[in] key : the key associated with the user_date
338 * @param[in] data : a pointer of the user_data
339 * @return 1 if this function succeeds, otherwise 0.
341 int tbm_surface_internal_set_user_data(tbm_surface_h surface, unsigned long key,
345 * @brief Gets a user_data from the tbm surface with the key.
347 * @param[in] surface : the tbm surface.
348 * @param[in] key : the key associated with the user_date
349 * @param[out] data : to get the user data
350 * @return 1 if this function succeeds, otherwise 0.
352 int tbm_surface_internal_get_user_data(tbm_surface_h surface, unsigned long key,
356 * @brief Deletes the user_data in the tbm surface.
358 * @param[in] surface : the tbm surface.
359 * @param[in] key : the key associated with the user_date
360 * @return 1 if this function succeeds, otherwise 0.
362 int tbm_surface_internal_delete_user_data(tbm_surface_h surface,
365 void tbm_surface_internal_dump_buffer(tbm_surface_h surface, const char *type);
367 #endif /* _TBM_SURFACE_INTERNAL_H_ */