utest: rename the ut to the utests
[platform/core/uifw/libtdm.git] / utests / stubs / tbm_surface_internal.h
1 #ifndef _TBM_SURFACE_INTERNAL_H_
2 #define _TBM_SURFACE_INTERNAL_H_
3
4 #include <tbm_bufmgr.h>
5
6
7 /**
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
15  * @par Example
16    @code
17    #include <tbm_surface.h>
18    #include <tbm_surface_internal.h>
19
20    tbm_bufmgr bufmgr;
21    uint32_t *formats;
22    uint32_t format_num;
23
24    bufmgr = tbm_bufmgr_create (-1);
25    ret = tbm_surface_internal_query_surpported_foramts (bufmgr, &formats, &format_num);
26
27    ...
28
29    free (foramts);
30    tbm_surface_bufmgr_deinit (bufmgr);
31    @endcode
32  */
33 int tbm_surface_internal_query_supported_formats(uint32_t **formats,
34                                                  uint32_t *num);
35
36 /**
37  * @brief Creates the tbm_surface with memory type.
38  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
39  * @details
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
52  * @par Example
53    @code
54    #include <tbm_surface.h>
55    #include <tbm_surface_internal.h>
56
57    int bufmgr_fd
58    tbm_bufmgr bufmgr;
59    tbm_surface_h surface;
60    uint32_t *format;
61    uint32_t format_num;
62
63    bufmgr = tbm_bufmgr_create (bufmgr_fd);
64    surface = tbm_surface_internal_create_with_flags (128, 128, TBM_FORMAT_YUV420, TBM_BO_DEFAULT);
65
66    ...
67
68    tbm_surface_destroy (surface);
69    tbm_surface_bufmgr_deinit (bufmgr);
70    @endcode
71  */
72 tbm_surface_h tbm_surface_internal_create_with_flags(int width, int height,
73                                                      int format, int flags);
74
75 /**
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
86  * @par Example
87    @code
88    #include <tbm_bufmgr.h>
89    #include <tbm_surface.h>
90    #include <tbm_surface_internal.h>
91
92    int bufmgr_fd
93    tbm_bufmgr bufmgr;
94    tbm_surface_h surface;
95    tbm_surface_info_s info;
96    uint32_t *format;
97    uint32_t format_num;
98    tbm_bo bo[1];
99
100    bufmgr = tbm_bufmgr_init (bufmgr_fd);
101    bo[0] = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
102
103    info.width = 128;
104    info.height = 128;
105    info.format = TBM_FORMAT_ARGB8888;
106    info.bpp = 32;
107    info.size = 65536;
108    info.num_planes = 1;
109    info.planes[0].size = 65536;
110    info.planes[0].offset = 0;
111    info.planes[0].stride = 512;
112
113    surface = tbm_surface_internal_create_with_bos (&info, bo, 1);
114
115    ...
116
117    tbm_surface_destroy (surface);
118    tbm_surface_bufmgr_deinit (bufmgr);
119    @endcode
120  */
121 tbm_surface_h tbm_surface_internal_create_with_bos(tbm_surface_info_s *info,
122                                                    tbm_bo *bos, int num);
123
124 /**
125  * @brief Destroy the tbm surface
126     TODO:
127  */
128 void tbm_surface_internal_destroy(tbm_surface_h surface);
129
130 /**
131  * @brief reference the tbm surface
132     TODO:
133  */
134 void tbm_surface_internal_ref(tbm_surface_h surface);
135
136 /**
137  * @brief unreference the tbm surface
138     TODO:
139  */
140 void tbm_surface_internal_unref(tbm_surface_h surface);
141
142 /**
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.
147  * @par Example
148    @code
149    #include <tbm_surface.h>
150    #include <tbm_surface_internal.h>
151
152    tbm_surface_h surface;
153    int num_bos;
154
155    surface = tbm_surface_create (128, 128, TBM_FORMAT_YUV420);
156    num_bos = tbm_surface_internal_get_num_bos (surface);
157
158    ...
159
160    tbm_surface_destroy (surface);
161    @endcode
162  */
163 int tbm_surface_internal_get_num_bos(tbm_surface_h surface);
164
165 /**
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.
171  * @retval #tbm_bo
172  * @par Example
173    @code
174    #include <tbm_surface.h>
175    #include <tbm_surface_internal.h>
176
177    tbm_surface_h surface;
178    int num_bos;
179    tbm_bo bo;
180
181    surface = tbm_surface_create (128, 128, TBM_FORMAT_YUV420);
182    num_bos = tbm_surface_internal_get_num_bos (surface);
183
184    for (i=0 ; i < num_bos ; i++)
185    {
186        bo = tbm_surface_internal_get_bo (surface, i);
187
188    ...
189
190    tbm_surface_destroy (surface);
191    @endcode
192  */
193 tbm_bo tbm_surface_internal_get_bo(tbm_surface_h surface, int bo_idx);
194
195 /**
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.
200  * @par Example
201    @code
202    #include <tbm_surface.h>
203    #include <tbm_surface_internal.h>
204
205    tbm_surface_h surface;
206    int size;
207
208    surface = tbm_surface_create (128, 128, TBM_FORMAT_YUV420);
209    size = tbm_surface_internal_get_size (surface);
210
211    tbm_surface_destroy (surface);
212    @endcode
213  */
214 unsigned int tbm_surface_internal_get_size(tbm_surface_h surface);
215
216 /**
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.
225  * @par Example
226    @code
227    #include <tbm_surface.h>
228    #include <tbm_surface_internal.h>
229
230    tbm_surface_h surface;
231    uint32_t size, offset, pitch;
232    int ret;
233
234    surface = tbm_surface_create (128, 128, TBM_FORMAT_YUV420);
235    ret = tbm_surface_internal_get_plane_data (surface, 1, &size, &offset, &pitch);
236
237    ...
238
239    tbm_surface_destroy (surface);
240    @endcode
241  */
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);
244
245 /**
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.
250  * @par Example
251    @code
252    #include <tbm_surface.h>
253    #include <tbm_surface_internal.h>
254
255    int num;
256
257    num = tbm_surface_internal_get_num_planes (TBM_FORMAT_YUV420);
258
259    ...
260
261    @endcode
262  */
263 int tbm_surface_internal_get_num_planes(tbm_format format);
264
265 /**
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.
270  * @par Example
271    @code
272    #include <tbm_surface.h>
273    #include <tbm_surface_internal.h>
274
275    int bpp;
276
277    bpp = tbm_surface_internal_get_bpp (TBM_FORMAT_YUV420);
278
279    ...
280
281    @endcode
282  */
283 int tbm_surface_internal_get_bpp(tbm_format format);
284
285 /**
286  * @brief Gets bo index of plane.
287  * @since_tizen 2.4
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.
291  * @par Example
292    @code
293    #include <tbm_surface.h>
294    #include <tbm_surface_internal.h>
295
296    int bo_idx;
297    tbm_surface_h surface;
298
299    surface = tbm_surface_create (128, 128, TBM_FORMAT_YUV420);
300    bo_idx = tbm_surface_internal_get_plane_bo_idx (surface, 0);
301
302    ...
303
304    @endcode
305  */
306 int tbm_surface_internal_get_plane_bo_idx(tbm_surface_h surface, int plane_idx);
307
308 /**
309  * @brief Set the pid to the tbm_surface for debugging.
310  * @since_tizen 3.0
311  * @param[in] surface : the tbm_surface_h
312  * @param[in] pid : the pid
313  */
314 void tbm_surface_internal_set_debug_pid(tbm_surface_h surface,
315                                         unsigned int pid);
316
317 /**
318  * @brief Adds a user_data to the tbm surface.
319  * @since_tizen 3.0
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()
329  */
330 int tbm_surface_internal_add_user_data(tbm_surface_h surface, unsigned long key,
331                                        tbm_data_free data_free_func);
332
333 /**
334  * @brief Sets a user_date to the tbm surface.
335  * @since_tizen 3.0
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.
340  */
341 int tbm_surface_internal_set_user_data(tbm_surface_h surface, unsigned long key,
342                                        void *data);
343
344 /**
345  * @brief Gets a user_data from the tbm surface with the key.
346  * @since_tizen 3.0
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.
351  */
352 int tbm_surface_internal_get_user_data(tbm_surface_h surface, unsigned long key,
353                                        void **data);
354
355 /**
356  * @brief Deletes the user_data in the tbm surface.
357  * @since_tizen 3.0
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.
361  */
362 int tbm_surface_internal_delete_user_data(tbm_surface_h surface,
363                                           unsigned long key);
364
365 void tbm_surface_internal_dump_buffer(tbm_surface_h surface, const char *type);
366
367 #endif                                                  /* _TBM_SURFACE_INTERNAL_H_ */