7 /* tbm error base : this error base is same as TIZEN_ERROR_TBM in tizen_error.h */
9 #define TBM_ERROR_BASE -0x02830000
14 * \brief Tizen Buffer Manager
18 * @brief Definition for the tizen buffer manager
19 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
21 typedef struct _tbm_bufmgr *tbm_bufmgr;
24 * @brief Definition for the tizen buffer object
25 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
27 typedef struct _tbm_bo *tbm_bo;
29 * @brief Definition for the key associated with the buffer object
30 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
32 typedef uint32_t tbm_key;
34 * @brief Definition for the file descripter of the system buffer manager
35 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
37 typedef int32_t tbm_fd;
42 * @brief Definition for the device type to get the default handle
43 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
45 #define TBM_DEVICE_DEFAULT 0
47 * @brief Definition for the device type to get the virtual memory
48 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
50 #define TBM_DEVICE_CPU 1
52 * @brief Definition for the device type to get the 2D memory handle
53 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
55 #define TBM_DEVICE_2D 2
57 * @brief Definition for the device type to get the 3D memory handle
58 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
60 #define TBM_DEVICE_3D 3
62 * @brief Definition for the device type to get the multimedia handle
63 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
65 #define TBM_DEVICE_MM 4
70 * @brief Definition for the access option to read
71 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
73 #define TBM_OPTION_READ (1 << 0)
75 * @brief Definition for the access option to write
76 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
78 #define TBM_OPTION_WRITE (1 << 1)
80 * @brief Definition for the vendor specific option that depends on the backend
81 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
83 #define TBM_OPTION_VENDOR (0xffff0000)
85 /* unneeded version 2.0 */
87 * @brief Definition for the cache invalidate
88 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
90 #define TBM_CACHE_INV 0x01
92 * @brief Definition for the cache clean
93 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
95 #define TBM_CACHE_CLN 0x02
96 /* unneeded version 2.0 */
99 * @brief tbm_bo_handle abstraction of the memory handle by TBM_DEVICE_TYPE
100 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
102 typedef union _tbm_bo_handle {
111 * @brief Enumeration of bo memory type
112 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
115 TBM_BO_DEFAULT = 0, /**< default memory: it depends on the backend */
116 TBM_BO_SCANOUT = (1 << 0), /**< scanout memory */
117 TBM_BO_NONCACHABLE = (1 << 1), /**< non-cachable memory */
118 TBM_BO_WC = (1 << 2), /**< write-combine memory */
119 TBM_BO_VENDOR = (0xffff0000), /**< vendor specific memory: it depends on the backend */
123 * @brief Enumeration for tbm error type.
127 TBM_ERROR_NONE = 0, /**< Successful */
128 TBM_BO_ERROR_GET_FD_FAILED = TBM_ERROR_BASE | 0x0101, /**< failed to get fd failed */
129 TBM_BO_ERROR_HEAP_ALLOC_FAILED = TBM_ERROR_BASE | 0x0102, /**< failed to allocate the heap memory */
130 TBM_BO_ERROR_LOAD_MODULE_FAILED = TBM_ERROR_BASE | 0x0103,/**< failed to load module*/
131 TBM_BO_ERROR_THREAD_INIT_FAILED = TBM_ERROR_BASE | 0x0104,/**< failed to initialize the pthread */
132 TBM_BO_ERROR_BO_ALLOC_FAILED = TBM_ERROR_BASE | 0x0105, /**< failed to allocate tbm_bo */
133 TBM_BO_ERROR_INIT_STATE_FAILED = TBM_ERROR_BASE | 0x0106, /**< failed to initialize the state of tbm_bo */
134 TBM_BO_ERROR_IMPORT_FAILED = TBM_ERROR_BASE | 0x0107, /**< failed to import the handle of tbm_bo */
135 TBM_BO_ERROR_IMPORT_FD_FAILED = TBM_ERROR_BASE | 0x0108, /**< failed to import fd of tbm_bo */
136 TBM_BO_ERROR_EXPORT_FAILED = TBM_ERROR_BASE | 0x0109, /**< failed to export the handle of the tbm_bo */
137 TBM_BO_ERROR_EXPORT_FD_FAILED = TBM_ERROR_BASE | 0x01010, /**< failed to export fd of tbm_bo */
138 TBM_BO_ERROR_GET_HANDLE_FAILED = TBM_ERROR_BASE | 0x0111, /**< failed to get the tbm_bo_handle */
139 TBM_BO_ERROR_LOCK_FAILED = TBM_ERROR_BASE | 0x0112, /**< failed to lock the tbm_bo */
140 TBM_BO_ERROR_MAP_FAILED = TBM_ERROR_BASE | 0x0113, /**< failed to map the tbm_bo to get the tbm_bo_handle */
141 TBM_BO_ERROR_UNMAP_FAILED = TBM_ERROR_BASE | 0x0114, /**< failed to unmap the tbm_bo */
142 TBM_BO_ERROR_SWAP_FAILED = TBM_ERROR_BASE | 0x0115, /**< failed to swap the tbm_bos */
143 TBM_BO_ERROR_DUP_FD_FAILED = TBM_ERROR_BASE | 0x0116, /**< failed to duplicate fd */
147 * @brief Enumeration of tbm buffer manager capability.
150 enum TBM_BUFMGR_CAPABILITY {
151 TBM_BUFMGR_CAPABILITY_NONE = 0, /**< Not Support capability*/
152 TBM_BUFMGR_CAPABILITY_SHARE_KEY = (1 << 0), /**< Support sharing buffer by tbm key */
153 TBM_BUFMGR_CAPABILITY_SHARE_FD = (1 << 1), /**< Support sharing buffer by tbm fd */
160 /* Functions for buffer manager */
163 * @brief Initializes the buffer manager.
164 * @details If fd is lower than zero, fd is get drm fd in tbm_bufmgr_init function\n
165 * The user can decide the lock type and cache flush type with the environment variables, which are BUFMGR_LOCK_TYPE and BUFMGR_MAP_CACHE.\n
167 * BUFMGR_LOCK default is once\n
168 * once : The previous bo which is locked is unlock when the new bo is trying to be locked\n
169 * always : The new bo is locked until the previous bo which is locked is unlocked\n
170 * never : Every bo is never locked.\n
172 * BUFMGR_MAP_CACHE default is true\n
173 * true : use map cache flushing\n
174 * false : to use map cache flushing
175 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
176 * @param[in] fd : file descripter of the system buffer manager
177 * @return a buffer manager
178 * @retval #tbm_bufmgr
179 * @see tbm_bufmgr_deinit();
182 #include <tbm_bufmgr.h>
185 setenv("BUFMGR_LOCK_TYPE", "once", 1);
186 setenv("BUFMGR_MAP_CACHE", "true", 1);
189 bufmgr = tbm_bufmgr_init (bufmgr_fd);
193 tbm_bufmgr_deinit (bufmgr);
196 tbm_bufmgr tbm_bufmgr_init(int fd);
199 * @brief Deinitializes the buffer manager.
200 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
201 * @param[in] bufmgr : the buffer manager
202 * @see tbm_bufmgr_init()
205 #include <tbm_bufmgr.h>
210 bufmgr = tbm_bufmgr_init (bufmgr_fd);
213 error = tbm_get_last_error ();
219 tbm_bufmgr_deinit (bufmgr);
222 void tbm_bufmgr_deinit(tbm_bufmgr bufmgr);
224 /* Functions for bo */
227 * @brief Allocates the buffer object.
228 * @details This function create tbm_bo and set reference count to 1.\n
229 * The user can craete tbm_bo with memory type flag #TBM_BO_FLAGS\n\n
230 * #TBM_BO_DEFAULT indecates default memory: it depends on the backend\n
231 * #TBM_BO_SCANOUT indecates scanout memory\n
232 * #TBM_BO_NONCACHABLE indecates non-cachable memory\n
233 * #TBM_BO_WC indecates write-combine memory\n
234 * #TBM_BO_VENDOR indecates vendor specific memory: it depends on the tbm backend
235 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
236 * @param[in] bufmgr : the buffer manager
237 * @param[in] size : the size of buffer object
238 * @param[in] flags : the flags of memory type
239 * @return a buffer object
243 #include <tbm_bufmgr.h>
250 bufmgr = tbm_bufmgr_init (bufmgr_fd);
251 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
254 error = tbm_get_last_error ();
260 tbm_bufmgr_deinit (bufmgr);
263 tbm_bo tbm_bo_alloc(tbm_bufmgr bufmgr, int size, int flags);
266 * @brief Increases the reference count of bo.
267 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
268 * @param[in] bo : the buffer object
269 * @return a buffer object
271 * @see tbm_bo_unref()
274 #include <tbm_bufmgr.h>
280 bufmgr = tbm_bufmgr_init (bufmgr_fd);
281 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
285 bo = tbm_bo_ref (bo);
289 tbm_bufmgr_deinit (bufmgr);
292 tbm_bo tbm_bo_ref(tbm_bo bo);
295 * @brief Decreases the reference count of bo
296 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
297 * @param[in] bo : the buffer object
299 * @see tbm_bo_alloc()
302 #include <tbm_bufmgr.h>
308 bufmgr = tbm_bufmgr_init (bufmgr_fd);
309 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
314 tbm_bufmgr_deinit (bufmgr);
317 void tbm_bo_unref(tbm_bo bo);
320 * @brief Maps the buffer object according to the device type and the option.
321 * @details Cache flushing and Locking is executed, while tbm_bo is mapping in the proper condition according to the device type and the access option.\n
322 * If the cache flush type of bufmgr set true, the map cache flushing is executed
323 * If the lock type of bufmgr set once, the previous bo which is locked is unlock when the new bo is trying to be locked.\n
324 * If the lock type of bufmgr set always, the new bo is locked until the previous bo which is locked is unlocked.\n
325 * If the lock type of bufmgr set never, Every bo is never locked.\n\n
326 * #TBM_DEVICE_DEFAULT indecates the default handle.\n
327 * #TBM_DEVICE_2D indecates the 2D memory handle.\n
328 * #TBM_DEVICE_3D indecates the 3D memory handle.\n
329 * #TBM_DEVICE_CPU indecates the virtual memory handle.\n
330 * #TBM_DEVICE_MM indecates the multimedia handle.\n\n
331 * #TBM_OPTION_READ indecates the accss option to read.\n
332 * #TBM_OPTION_WRITE indecates the access option to write.\n
333 * #TBM_OPTION_VENDOR indecates the vendor specific option that depends on the backend.
334 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
335 * @param[in] bo : the buffer object
336 * @param[in] device : the device type to get a handle
337 * @param[in] opt : the option to access the buffer object
338 * @return the handle of the buffer object
339 * @exception #TBM_ERROR_NONE Success
340 * @exception #TBM_ERROR_BO_LOCK_FAILED tbm_bo lock failed
341 * @exception #TBM_ERROR_BO_MAP_FAILED tbm_bo map failed
343 * @see tbm_bo_unmap()
346 #include <tbm_bufmgr.h>
351 tbm_bo_handle handle;
354 bufmgr = tbm_bufmgr_init (bufmgr_fd);
355 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
359 handle = tbm_bo_map (bo, TBM_DEVICE_2D, TBM_OPTION_READ|TBM_OPTION_WRITE);
360 if (handle.ptr == NULL)
362 error = tbm_get_last_error ();
370 tbm_bufmgr_deinit (bufmgr);
373 tbm_bo_handle tbm_bo_map(tbm_bo bo, int device, int opt);
376 * @brief Unmaps the buffer object.
377 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
378 * @param[in] bo : the buffer object
379 * @return 1 if this function succeeds, otherwise 0.
383 #include <tbm_bufmgr.h>
388 tbm_bo_handle handle;
390 bufmgr = tbm_bufmgr_init (bufmgr_fd);
391 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
395 handle = tbm_bo_map (bo, TBM_DEVICE_2D, TBM_OPTION_READ|TBM_OPTION_WRITE);
401 tbm_bufmgr_deinit (bufmgr);
404 int tbm_bo_unmap(tbm_bo bo);
407 * @brief Gets the tbm_bo_handle according to the device type.
408 * @details The tbm_bo_handle can be get without the map of the tbm_bo.\n
409 * In this case, TBM does not guarantee the lock and the cache flush of the tbm_bo.\n\n
410 * #TBM_DEVICE_DEFAULT indecates the default handle.\n
411 * #TBM_DEVICE_2D indecates the 2D memory handle.\n
412 * #TBM_DEVICE_3D indecates the 3D memory handle.\n
413 * #TBM_DEVICE_CPU indecates the virtual memory handle.\n
414 * #TBM_DEVICE_MM indecates the multimedia handle.
415 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
416 * @param[in] bo : the buffer object
417 * @param[in] device : the device type to get a handle
418 * @return the handle of the buffer object
419 * @retval #tbm_bo_handle
422 #include <tbm_bufmgr.h>
427 tbm_bo_handle handle;
430 bufmgr = tbm_bufmgr_init (bufmgr_fd);
431 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
435 handle = tbm_bo_get_handle (bo, TBM_DEVICE_2D);
436 if (handle.ptr == NULL)
438 error = tbm_get_last_error ();
445 tbm_bufmgr_deinit (bufmgr);
448 tbm_bo_handle tbm_bo_get_handle(tbm_bo bo, int device);
451 * @brief Exports the buffer object by key.
452 * @details The tbm_bo can be exported to the anther process with the unique key associated with the the tbm_bo.
453 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
454 * @param[in] bo : the buffer object
455 * @return key associated with the buffer object
457 * @see tbm_bo_import()
460 #include <tbm_bufmgr.h>
468 bufmgr = tbm_bufmgr_init (bufmgr_fd);
469 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
470 key = tbm_bo_export (bo);
473 error = tbm_get_last_error ();
480 tbm_bufmgr_deinit (bufmgr);
483 tbm_key tbm_bo_export(tbm_bo bo);
486 * @brief Exports the buffer object by fd.
487 * @details The tbm_bo can be exported to the anther process with the unique fd associated with the the tbm_bo.
488 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
489 * @remarks You must release the fd using close().
490 * @param[in] bo : the buffer object
491 * @return fd associated with the buffer object
493 * @see tbm_bo_import_fd()
496 #include <tbm_bufmgr.h>
504 bufmgr = tbm_bufmgr_init (bufmgr_fd);
505 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
506 bo_fd = tbm_bo_export (bo);
509 error = tbm_get_last_error ();
516 tbm_bufmgr_deinit (bufmgr);
519 tbm_fd tbm_bo_export_fd(tbm_bo bo);
522 * @brief Imports the buffer object associated with the key.
523 * @details The reference count of the tbm_bo is 1.
524 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
525 * @param[in] bufmgr : the buffer manager
526 * @param[in] key : the key associated with the buffer object
527 * @return a buffer object
529 * @see tbm_bo_export()
532 #include <tbm_bufmgr.h>
542 bufmgr = tbm_bufmgr_init (bufmgr_fd);
543 bo = tbm_bo_import (bufmgr, key);
546 error = tbm_get_last_error ();
553 tbm_bufmgr_deinit (bufmgr);
556 tbm_bo tbm_bo_import(tbm_bufmgr bufmgr, tbm_key key);
559 * @brief Imports the buffer object associated with the fd.
560 * @details The reference count of the tbm_bo is 1.
561 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
562 * @remarks You must release the fd using close().
563 * @param[in] bufmgr : the buffer manager
564 * @param[in] fd : the fd associated with the buffer object
565 * @return a buffer object
567 * @see tbm_bo_export_fd()
570 #include <tbm_bufmgr.h>
580 bufmgr = tbm_bufmgr_init (bufmgr_fd);
581 bo = tbm_bo_import_fd (bo_fd);
584 error = tbm_get_last_error ();
591 tbm_bufmgr_deinit (bufmgr);
594 tbm_bo tbm_bo_import_fd(tbm_bufmgr bufmgr, tbm_fd fd);
597 * @brief Gets the size of a bo.
598 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
599 * @param[in] bo : the buffer object
600 * @return 1 if this function succeeds, otherwise 0.
601 * @see tbm_bo_alloc()
604 #include <tbm_bufmgr.h>
611 bufmgr = tbm_bufmgr_init (bufmgr_fd);
612 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
613 size = tbm_bo_size (bo);
618 tbm_bufmgr_deinit (bufmgr);
621 int tbm_bo_size(tbm_bo bo);
624 * @brief Gets the state where the buffer object is locked.
625 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
626 * @param[in] bo : the buffer object
627 * @return 1 if this bo is locked, otherwise 0.
629 * @see tbm_bo_unmap()
632 #include <tbm_bufmgr.h>
638 bufmgr = tbm_bufmgr_init (bufmgr_fd);
639 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
643 if (tbm_bo_locked (bo))
649 tbm_bufmgr_deinit (bufmgr);
652 int tbm_bo_locked(tbm_bo bo);
655 * @brief Swaps the buffer object.
656 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
657 * @param[in] bo1 : the buffer object
658 * @param[in] bo2 : the buffer object
659 * @return 1 if this function succeeds, otherwise 0.
662 #include <tbm_bufmgr.h>
671 bufmgr = tbm_bufmgr_init (bufmgr_fd);
672 bo1 = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
673 bo2 = tbm_bo_alloc (bufmgr, 256 * 256, TBM_BO_DEFAULT);
677 ret = tbm_bo_swap (bo1, bo2);
680 error = tbm_get_last_error ();
688 tbm_bufmgr_deinit (bufmgr);
691 int tbm_bo_swap(tbm_bo bo1, tbm_bo bo2);
694 * @brief Called when the user data is deleted in buffer object.
695 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
696 * @param[in] user_data User_data to be passed to callback function
697 * @pre The callback must be registered using tbm_bo_add_user_data().\n
698 * tbm_bo_delete_user_data() must be called to invoke this callback.
699 * @see tbm_bo_add_user_data()
700 * @see tbm_bo_delete_user_data()
702 typedef void (*tbm_data_free) (void *user_data);
705 * @brief Adds a user_data to the buffer object.
706 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
707 * @param[in] bo : the buffer object
708 * @param[in] key : the key associated with the user_data
709 * @param[in] data_free_func : the function pointer to free the user_data
710 * @return 1 if this function succeeds, otherwise 0.
711 * @post tbm_data_free() will be called under certain conditions, after calling tbm_bo_delete_user_data().
712 * @see tbm_data_free()
713 * @see tbm_bo_set_user_data()
714 * @see tbm_bo_get_user_data()
715 * @see tbm_bo_delete_user_data()
718 #include <tbm_bufmgr.h>
720 void example_data_free (void *user_data)
722 char *data = (char*) user_data;
735 bufmgr = tbm_bufmgr_init (bufmgr_fd);
736 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
737 user_data = (char*) malloc (sizeof(char) * 128);
741 tbm_bo_add_user_data (bo, 1, example_data_free);
742 tbm_bo_set_user_data (bo, 1, user_data);
746 ret = tbm_bo_get_user_data (bo, 1, &get_data);
747 tbm_bo_delete_user_data (bo, 1);
752 tbm_bufmgr_deinit (bufmgr);
757 int tbm_bo_add_user_data(tbm_bo bo, unsigned long key,
758 tbm_data_free data_free_func);
761 * @brief Deletes the user_data in the buffer object.
762 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
763 * @param[in] bo : the buffer object
764 * @param[in] key : the key associated with the user_date
765 * @return 1 if this function succeeds, otherwise 0.
766 * @see tbm_bo_add_user_data()
767 * @see tbm_bo_get_user_data()
768 * @see tbm_bo_delete_user_data()
771 #include <tbm_bufmgr.h>
773 void example_data_free (void *user_data)
775 char *data = (char*) user_data;
788 bufmgr = tbm_bufmgr_init (bufmgr_fd);
789 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
790 user_data = (char*) malloc (sizeof(char) * 128);
794 tbm_bo_add_user_data (bo, 1, example_data_free);
795 tbm_bo_set_user_data (bo, 1, user_data);
799 ret = tbm_bo_get_user_data (bo, 1, &get_data);
800 tbm_bo_delete_user_data (bo, 1);
805 tbm_bufmgr_deinit (bufmgr);
809 int tbm_bo_delete_user_data(tbm_bo bo, unsigned long key);
812 * @brief Sets a user_date to the buffer object.
813 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
814 * @param[in] bo : the buffer object
815 * @param[in] key : the key associated with the user_date
816 * @param[in] data : a pointer of the user_data
817 * @return 1 if this function succeeds, otherwise 0.
818 * @see tbm_bo_add_user_data()
819 * @see tbm_bo_set_user_data()
820 * @see tbm_bo_delete_user_data()
823 #include <tbm_bufmgr.h>
825 void example_data_free (void *user_data)
827 char *data = (char*) user_data;
840 bufmgr = tbm_bufmgr_init (bufmgr_fd);
841 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
842 user_data = (char*) malloc (sizeof(char) * 128);
846 tbm_bo_add_user_data (bo, 1, example_data_free);
847 tbm_bo_set_user_data (bo, 1, user_data);
851 ret = tbm_bo_get_user_data (bo, 1, &get_data);
852 tbm_bo_delete_user_data (bo, 1);
857 tbm_bufmgr_deinit (bufmgr);
861 int tbm_bo_set_user_data(tbm_bo bo, unsigned long key, void *data);
864 * @brief Gets a user_data from the buffer object with the key.
865 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
866 * @param[in] bo : the buffer object
867 * @param[in] key : the key associated with the user_date
868 * @param[out] data : to get the user data
869 * @return 1 if this function succeeds, otherwise 0.
870 * @see tbm_bo_add_user_data()
871 * @see tbm_bo_set_user_data()
872 * @see tbm_bo_get_user_data()
875 #include <tbm_bufmgr.h>
877 void example_data_free (void *user_data)
879 char *data = (char*) user_data;
892 bufmgr = tbm_bufmgr_init (bufmgr_fd);
893 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
894 user_data = (char*) malloc (sizeof(char) * 128);
898 tbm_bo_add_user_data (bo, 1, example_data_free);
899 tbm_bo_set_user_data (bo, 1, user_data);
903 ret = tbm_bo_get_user_data (bo, 1, &get_data);
904 tbm_bo_delete_user_data (bo, 1);
909 tbm_bufmgr_deinit (bufmgr);
913 int tbm_bo_get_user_data(tbm_bo bo, unsigned long key, void **data);
916 * @brief Gets the latest tbm_error.
918 * @return the latest tbm_error
921 #include <tbm_bufmgr.h>
926 tbm_bo_handle handle;
929 bufmgr = tbm_bufmgr_init (bufmgr_fd);
930 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
933 error = tbm_get_last_error ();
939 handle = tbm_bo_map (bo, TBM_DEVICE_2D, TBM_OPTION_READ|TBM_OPTION_WRITE);
940 if (handle.ptr == NULL)
942 error = tbm_get_last_error ();
950 tbm_bufmgr_deinit (bufmgr);
953 tbm_error_e tbm_get_last_error(void);
956 * @brief Gets the tbm buffer capability.
958 * @param[in] bufmgr : the buffer manager
959 * @return the tbm bufmgr capability
962 #include <tbm_bufmgr.h>
966 unsigned int capability;
968 bufmgr = tbm_bufmgr_init (bufmgr_fd);
970 capability = tbm_bufmgr_get_capability (bufmgr);
972 tbm_bufmgr_deinit (bufmgr);
975 unsigned int tbm_bufmgr_get_capability(tbm_bufmgr bufmgr);
978 * @brief Gets the tbm bo flags.
980 * @param[in] bo : the buffer object
981 * @return the tbm bo flags
985 #include <tbm_bufmgr.h>
992 bufmgr = tbm_bufmgr_init (bufmgr_fd);
993 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
994 flags = tbm_bo_get_flags (bo);
999 tbm_bufmgr_deinit (bufmgr);
1003 int tbm_bo_get_flags(tbm_bo bo);
1006 * @brief Print out the information of tbm_bos.
1008 * @param[in] bufmgr : the buffer manager
1010 void tbm_bufmgr_debug_show(tbm_bufmgr bufmgr);
1013 * @brief Print out the trace of tbm_bos.
1015 * @param[in] bufmgr : the buffer manager
1016 * @param[in] onoff : 1 is on, and 0 is off
1018 void tbm_bufmgr_debug_trace(tbm_bufmgr bufmgr, int onoff);
1020 int tbm_bufmgr_bind_native_display(tbm_bufmgr bufmgr, void *NativeDisplay);
1025 #endif /* _TBM_BUFMGR_H_ */