1 /**************************************************************************
5 Copyright 2012 Samsung Electronics co., Ltd. All Rights Reserved.
7 Contact: SooChan Lim <sc1.lim@samsung.com>, Sangjin Lee <lsj119@samsung.com>
8 Boram Park <boram1288.park@samsung.com>, Changyeon Lee <cyeon.lee@samsung.com>
10 Permission is hereby granted, free of charge, to any person obtaining a
11 copy of this software and associated documentation files (the
12 "Software"), to deal in the Software without restriction, including
13 without limitation the rights to use, copy, modify, merge, publish,
14 distribute, sub license, and/or sell copies of the Software, and to
15 permit persons to whom the Software is furnished to do so, subject to
16 the following conditions:
18 The above copyright notice and this permission notice (including the
19 next paragraph) shall be included in all copies or substantial portions
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
25 IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
27 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
28 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 **************************************************************************/
32 #ifndef _TBM_BUFMGR_H_
33 #define _TBM_BUFMGR_H_
38 /* tbm error base : this error base is same as TIZEN_ERROR_TBM in tizen_error.h */
39 #ifndef TBM_ERROR_BASE
40 #define TBM_ERROR_BASE -0x02830000
45 * \brief Tizen Buffer Manager
49 * @brief Definition for the tizen buffer manager
50 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
52 typedef struct _tbm_bufmgr *tbm_bufmgr;
55 * @brief Definition for the tizen buffer object
56 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
58 typedef struct _tbm_bo *tbm_bo;
60 * @brief Definition for the key associated with the buffer object
61 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
63 typedef uint32_t tbm_key;
65 * @brief Definition for the file descripter of the system buffer manager
66 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
68 typedef int32_t tbm_fd;
73 * @brief Definition for the device type to get the default handle
74 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
76 #define TBM_DEVICE_DEFAULT 0
78 * @brief Definition for the device type to get the virtual memory
79 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
81 #define TBM_DEVICE_CPU 1
83 * @brief Definition for the device type to get the 2D memory handle
84 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
86 #define TBM_DEVICE_2D 2
88 * @brief Definition for the device type to get the 3D memory handle
89 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
91 #define TBM_DEVICE_3D 3
93 * @brief Definition for the device type to get the multimedia handle
94 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
96 #define TBM_DEVICE_MM 4
101 * @brief Definition for the access option to read
102 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
104 #define TBM_OPTION_READ (1 << 0)
106 * @brief Definition for the access option to write
107 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
109 #define TBM_OPTION_WRITE (1 << 1)
111 * @brief Definition for the vendor specific option that depends on the backend
112 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
114 #define TBM_OPTION_VENDOR (0xffff0000)
117 * @brief tbm_bo_handle abstraction of the memory handle by TBM_DEVICE_TYPE
118 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
120 typedef union _tbm_bo_handle {
129 * @brief Enumeration of bo memory type
130 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
133 TBM_BO_DEFAULT = 0, /**< default memory: it depends on the backend */
134 TBM_BO_SCANOUT = (1 << 0), /**< scanout memory */
135 TBM_BO_NONCACHABLE = (1 << 1), /**< non-cachable memory */
136 TBM_BO_WC = (1 << 2), /**< write-combine memory */
137 TBM_BO_VENDOR = (0xffff0000), /**< vendor specific memory: it depends on the backend */
141 * @brief Enumeration for tbm error type.
145 TBM_ERROR_NONE = 0, /**< Successful */
146 TBM_BO_ERROR_GET_FD_FAILED = TBM_ERROR_BASE | 0x0101, /**< failed to get fd failed */
147 TBM_BO_ERROR_HEAP_ALLOC_FAILED = TBM_ERROR_BASE | 0x0102, /**< failed to allocate the heap memory */
148 TBM_BO_ERROR_LOAD_MODULE_FAILED = TBM_ERROR_BASE | 0x0103,/**< failed to load module*/
149 TBM_BO_ERROR_THREAD_INIT_FAILED = TBM_ERROR_BASE | 0x0104,/**< failed to initialize the pthread */
150 TBM_BO_ERROR_BO_ALLOC_FAILED = TBM_ERROR_BASE | 0x0105, /**< failed to allocate tbm_bo */
151 TBM_BO_ERROR_INIT_STATE_FAILED = TBM_ERROR_BASE | 0x0106, /**< failed to initialize the state of tbm_bo */
152 TBM_BO_ERROR_IMPORT_FAILED = TBM_ERROR_BASE | 0x0107, /**< failed to import the handle of tbm_bo */
153 TBM_BO_ERROR_IMPORT_FD_FAILED = TBM_ERROR_BASE | 0x0108, /**< failed to import fd of tbm_bo */
154 TBM_BO_ERROR_EXPORT_FAILED = TBM_ERROR_BASE | 0x0109, /**< failed to export the handle of the tbm_bo */
155 TBM_BO_ERROR_EXPORT_FD_FAILED = TBM_ERROR_BASE | 0x01010, /**< failed to export fd of tbm_bo */
156 TBM_BO_ERROR_GET_HANDLE_FAILED = TBM_ERROR_BASE | 0x0111, /**< failed to get the tbm_bo_handle */
157 TBM_BO_ERROR_LOCK_FAILED = TBM_ERROR_BASE | 0x0112, /**< failed to lock the tbm_bo */
158 TBM_BO_ERROR_MAP_FAILED = TBM_ERROR_BASE | 0x0113, /**< failed to map the tbm_bo to get the tbm_bo_handle */
159 TBM_BO_ERROR_UNMAP_FAILED = TBM_ERROR_BASE | 0x0114, /**< failed to unmap the tbm_bo */
160 TBM_BO_ERROR_SWAP_FAILED = TBM_ERROR_BASE | 0x0115, /**< failed to swap the tbm_bos */
161 TBM_BO_ERROR_DUP_FD_FAILED = TBM_ERROR_BASE | 0x0116, /**< failed to duplicate fd */
165 * @brief Enumeration of tbm buffer manager capability.
168 enum TBM_BUFMGR_CAPABILITY {
169 TBM_BUFMGR_CAPABILITY_NONE = 0, /**< Not Support capability*/
170 TBM_BUFMGR_CAPABILITY_SHARE_KEY = (1 << 0), /**< Support sharing buffer by tbm key */
171 TBM_BUFMGR_CAPABILITY_SHARE_FD = (1 << 1), /**< Support sharing buffer by tbm fd */
178 /* Functions for buffer manager */
181 * @brief Initializes the buffer manager.
182 * @details If fd is lower than zero, fd is get drm fd in tbm_bufmgr_init function\n
183 * 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
185 * BUFMGR_LOCK default is once\n
186 * once : The previous bo which is locked is unlock when the new bo is trying to be locked\n
187 * always : The new bo is locked until the previous bo which is locked is unlocked\n
188 * never : Every bo is never locked.\n
190 * BUFMGR_MAP_CACHE default is true\n
191 * true : use map cache flushing\n
192 * false : to use map cache flushing
193 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
194 * @param[in] fd : file descripter of the system buffer manager
195 * @return a buffer manager
196 * @retval #tbm_bufmgr
197 * @see tbm_bufmgr_deinit();
200 #include <tbm_bufmgr.h>
203 setenv("BUFMGR_LOCK_TYPE", "once", 1);
204 setenv("BUFMGR_MAP_CACHE", "true", 1);
207 bufmgr = tbm_bufmgr_init (bufmgr_fd);
211 tbm_bufmgr_deinit (bufmgr);
214 tbm_bufmgr tbm_bufmgr_init(int fd);
217 * @brief Deinitializes the buffer manager.
218 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
219 * @param[in] bufmgr : the buffer manager
220 * @see tbm_bufmgr_init()
223 #include <tbm_bufmgr.h>
228 bufmgr = tbm_bufmgr_init (bufmgr_fd);
231 error = tbm_get_last_error ();
237 tbm_bufmgr_deinit (bufmgr);
240 void tbm_bufmgr_deinit(tbm_bufmgr bufmgr);
242 /* Functions for bo */
245 * @brief Allocates the buffer object.
246 * @details This function create tbm_bo and set reference count to 1.\n
247 * The user can craete tbm_bo with memory type flag #TBM_BO_FLAGS\n\n
248 * #TBM_BO_DEFAULT indecates default memory: it depends on the backend\n
249 * #TBM_BO_SCANOUT indecates scanout memory\n
250 * #TBM_BO_NONCACHABLE indecates non-cachable memory\n
251 * #TBM_BO_WC indecates write-combine memory\n
252 * #TBM_BO_VENDOR indecates vendor specific memory: it depends on the tbm backend
253 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
254 * @param[in] bufmgr : the buffer manager
255 * @param[in] size : the size of buffer object
256 * @param[in] flags : the flags of memory type
257 * @return a buffer object
261 #include <tbm_bufmgr.h>
268 bufmgr = tbm_bufmgr_init (bufmgr_fd);
269 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
272 error = tbm_get_last_error ();
278 tbm_bufmgr_deinit (bufmgr);
281 tbm_bo tbm_bo_alloc(tbm_bufmgr bufmgr, int size, int flags);
284 * @brief Increases the reference count of bo.
285 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
286 * @param[in] bo : the buffer object
287 * @return a buffer object
289 * @see tbm_bo_unref()
292 #include <tbm_bufmgr.h>
298 bufmgr = tbm_bufmgr_init (bufmgr_fd);
299 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
303 bo = tbm_bo_ref (bo);
307 tbm_bufmgr_deinit (bufmgr);
310 tbm_bo tbm_bo_ref(tbm_bo bo);
313 * @brief Decreases the reference count of bo
314 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
315 * @param[in] bo : the buffer object
317 * @see tbm_bo_alloc()
320 #include <tbm_bufmgr.h>
326 bufmgr = tbm_bufmgr_init (bufmgr_fd);
327 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
332 tbm_bufmgr_deinit (bufmgr);
335 void tbm_bo_unref(tbm_bo bo);
338 * @brief Maps the buffer object according to the device type and the option.
339 * @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
340 * If the cache flush type of bufmgr set true, the map cache flushing is executed
341 * 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
342 * If the lock type of bufmgr set always, the new bo is locked until the previous bo which is locked is unlocked.\n
343 * If the lock type of bufmgr set never, Every bo is never locked.\n\n
344 * #TBM_DEVICE_DEFAULT indecates the default handle.\n
345 * #TBM_DEVICE_2D indecates the 2D memory handle.\n
346 * #TBM_DEVICE_3D indecates the 3D memory handle.\n
347 * #TBM_DEVICE_CPU indecates the virtual memory handle.\n
348 * #TBM_DEVICE_MM indecates the multimedia handle.\n\n
349 * #TBM_OPTION_READ indecates the accss option to read.\n
350 * #TBM_OPTION_WRITE indecates the access option to write.\n
351 * #TBM_OPTION_VENDOR indecates the vendor specific option that depends on the backend.
352 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
353 * @param[in] bo : the buffer object
354 * @param[in] device : the device type to get a handle
355 * @param[in] opt : the option to access the buffer object
356 * @return the handle of the buffer object
357 * @exception #TBM_ERROR_NONE Success
358 * @exception #TBM_ERROR_BO_LOCK_FAILED tbm_bo lock failed
359 * @exception #TBM_ERROR_BO_MAP_FAILED tbm_bo map failed
361 * @see tbm_bo_unmap()
364 #include <tbm_bufmgr.h>
369 tbm_bo_handle handle;
372 bufmgr = tbm_bufmgr_init (bufmgr_fd);
373 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
377 handle = tbm_bo_map (bo, TBM_DEVICE_2D, TBM_OPTION_READ|TBM_OPTION_WRITE);
378 if (handle.ptr == NULL)
380 error = tbm_get_last_error ();
388 tbm_bufmgr_deinit (bufmgr);
391 tbm_bo_handle tbm_bo_map(tbm_bo bo, int device, int opt);
394 * @brief Unmaps the buffer object.
395 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
396 * @param[in] bo : the buffer object
397 * @return 1 if this function succeeds, otherwise 0.
401 #include <tbm_bufmgr.h>
406 tbm_bo_handle handle;
408 bufmgr = tbm_bufmgr_init (bufmgr_fd);
409 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
413 handle = tbm_bo_map (bo, TBM_DEVICE_2D, TBM_OPTION_READ|TBM_OPTION_WRITE);
419 tbm_bufmgr_deinit (bufmgr);
422 int tbm_bo_unmap(tbm_bo bo);
425 * @brief Gets the tbm_bo_handle according to the device type.
426 * @details The tbm_bo_handle can be get without the map of the tbm_bo.\n
427 * In this case, TBM does not guarantee the lock and the cache flush of the tbm_bo.\n\n
428 * #TBM_DEVICE_DEFAULT indecates the default handle.\n
429 * #TBM_DEVICE_2D indecates the 2D memory handle.\n
430 * #TBM_DEVICE_3D indecates the 3D memory handle.\n
431 * #TBM_DEVICE_CPU indecates the virtual memory handle.\n
432 * #TBM_DEVICE_MM indecates the multimedia handle.
433 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
434 * @param[in] bo : the buffer object
435 * @param[in] device : the device type to get a handle
436 * @return the handle of the buffer object
437 * @retval #tbm_bo_handle
440 #include <tbm_bufmgr.h>
445 tbm_bo_handle handle;
448 bufmgr = tbm_bufmgr_init (bufmgr_fd);
449 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
453 handle = tbm_bo_get_handle (bo, TBM_DEVICE_2D);
454 if (handle.ptr == NULL)
456 error = tbm_get_last_error ();
463 tbm_bufmgr_deinit (bufmgr);
466 tbm_bo_handle tbm_bo_get_handle(tbm_bo bo, int device);
469 * @brief Exports the buffer object by key.
470 * @details The tbm_bo can be exported to the anther process with the unique key associated with the the tbm_bo.
471 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
472 * @param[in] bo : the buffer object
473 * @return key associated with the buffer object
475 * @see tbm_bo_import()
478 #include <tbm_bufmgr.h>
486 bufmgr = tbm_bufmgr_init (bufmgr_fd);
487 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
488 key = tbm_bo_export (bo);
491 error = tbm_get_last_error ();
498 tbm_bufmgr_deinit (bufmgr);
501 tbm_key tbm_bo_export(tbm_bo bo);
504 * @brief Exports the buffer object by fd.
505 * @details The tbm_bo can be exported to the anther process with the unique fd associated with the the tbm_bo.
506 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
507 * @remarks You must release the fd using close().
508 * @param[in] bo : the buffer object
509 * @return fd associated with the buffer object
511 * @see tbm_bo_import_fd()
514 #include <tbm_bufmgr.h>
522 bufmgr = tbm_bufmgr_init (bufmgr_fd);
523 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
524 bo_fd = tbm_bo_export (bo);
527 error = tbm_get_last_error ();
534 tbm_bufmgr_deinit (bufmgr);
537 tbm_fd tbm_bo_export_fd(tbm_bo bo);
540 * @brief Imports the buffer object associated with the key.
541 * @details The reference count of the tbm_bo is 1.
542 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
543 * @param[in] bufmgr : the buffer manager
544 * @param[in] key : the key associated with the buffer object
545 * @return a buffer object
547 * @see tbm_bo_export()
550 #include <tbm_bufmgr.h>
560 bufmgr = tbm_bufmgr_init (bufmgr_fd);
561 bo = tbm_bo_import (bufmgr, key);
564 error = tbm_get_last_error ();
571 tbm_bufmgr_deinit (bufmgr);
574 tbm_bo tbm_bo_import(tbm_bufmgr bufmgr, tbm_key key);
577 * @brief Imports the buffer object associated with the fd.
578 * @details The reference count of the tbm_bo is 1.
579 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
580 * @remarks You must release the fd using close().
581 * @param[in] bufmgr : the buffer manager
582 * @param[in] fd : the fd associated with the buffer object
583 * @return a buffer object
585 * @see tbm_bo_export_fd()
588 #include <tbm_bufmgr.h>
598 bufmgr = tbm_bufmgr_init (bufmgr_fd);
599 bo = tbm_bo_import_fd (bo_fd);
602 error = tbm_get_last_error ();
609 tbm_bufmgr_deinit (bufmgr);
612 tbm_bo tbm_bo_import_fd(tbm_bufmgr bufmgr, tbm_fd fd);
615 * @brief Gets the size of a bo.
616 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
617 * @param[in] bo : the buffer object
618 * @return 1 if this function succeeds, otherwise 0.
619 * @see tbm_bo_alloc()
622 #include <tbm_bufmgr.h>
629 bufmgr = tbm_bufmgr_init (bufmgr_fd);
630 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
631 size = tbm_bo_size (bo);
636 tbm_bufmgr_deinit (bufmgr);
639 int tbm_bo_size(tbm_bo bo);
642 * @brief Gets the state where the buffer object is locked.
643 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
644 * @param[in] bo : the buffer object
645 * @return 1 if this bo is locked, otherwise 0.
647 * @see tbm_bo_unmap()
650 #include <tbm_bufmgr.h>
656 bufmgr = tbm_bufmgr_init (bufmgr_fd);
657 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
661 if (tbm_bo_locked (bo))
667 tbm_bufmgr_deinit (bufmgr);
670 int tbm_bo_locked(tbm_bo bo);
673 * @brief Swaps the buffer object.
674 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
675 * @param[in] bo1 : the buffer object
676 * @param[in] bo2 : the buffer object
677 * @return 1 if this function succeeds, otherwise 0.
680 #include <tbm_bufmgr.h>
689 bufmgr = tbm_bufmgr_init (bufmgr_fd);
690 bo1 = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
691 bo2 = tbm_bo_alloc (bufmgr, 256 * 256, TBM_BO_DEFAULT);
695 ret = tbm_bo_swap (bo1, bo2);
698 error = tbm_get_last_error ();
706 tbm_bufmgr_deinit (bufmgr);
709 int tbm_bo_swap(tbm_bo bo1, tbm_bo bo2);
712 * @brief Called when the user data is deleted in buffer object.
713 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
714 * @param[in] user_data User_data to be passed to callback function
715 * @pre The callback must be registered using tbm_bo_add_user_data().\n
716 * tbm_bo_delete_user_data() must be called to invoke this callback.
717 * @see tbm_bo_add_user_data()
718 * @see tbm_bo_delete_user_data()
720 typedef void (*tbm_data_free) (void *user_data);
723 * @brief Adds a user_data to the buffer object.
724 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
725 * @param[in] bo : the buffer object
726 * @param[in] key : the key associated with the user_data
727 * @param[in] data_free_func : the function pointer to free the user_data
728 * @return 1 if this function succeeds, otherwise 0.
729 * @post tbm_data_free() will be called under certain conditions, after calling tbm_bo_delete_user_data().
730 * @see tbm_data_free()
731 * @see tbm_bo_set_user_data()
732 * @see tbm_bo_get_user_data()
733 * @see tbm_bo_delete_user_data()
736 #include <tbm_bufmgr.h>
738 void example_data_free (void *user_data)
740 char *data = (char*) user_data;
753 bufmgr = tbm_bufmgr_init (bufmgr_fd);
754 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
755 user_data = (char*) malloc (sizeof(char) * 128);
759 tbm_bo_add_user_data (bo, 1, example_data_free);
760 tbm_bo_set_user_data (bo, 1, user_data);
764 ret = tbm_bo_get_user_data (bo, 1, &get_data);
765 tbm_bo_delete_user_data (bo, 1);
770 tbm_bufmgr_deinit (bufmgr);
775 int tbm_bo_add_user_data(tbm_bo bo, unsigned long key,
776 tbm_data_free data_free_func);
779 * @brief Deletes the user_data in the buffer object.
780 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
781 * @param[in] bo : the buffer object
782 * @param[in] key : the key associated with the user_date
783 * @return 1 if this function succeeds, otherwise 0.
784 * @see tbm_bo_add_user_data()
785 * @see tbm_bo_get_user_data()
786 * @see tbm_bo_delete_user_data()
789 #include <tbm_bufmgr.h>
791 void example_data_free (void *user_data)
793 char *data = (char*) user_data;
806 bufmgr = tbm_bufmgr_init (bufmgr_fd);
807 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
808 user_data = (char*) malloc (sizeof(char) * 128);
812 tbm_bo_add_user_data (bo, 1, example_data_free);
813 tbm_bo_set_user_data (bo, 1, user_data);
817 ret = tbm_bo_get_user_data (bo, 1, &get_data);
818 tbm_bo_delete_user_data (bo, 1);
823 tbm_bufmgr_deinit (bufmgr);
827 int tbm_bo_delete_user_data(tbm_bo bo, unsigned long key);
830 * @brief Sets a user_date to the buffer object.
831 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
832 * @param[in] bo : the buffer object
833 * @param[in] key : the key associated with the user_date
834 * @param[in] data : a pointer of the user_data
835 * @return 1 if this function succeeds, otherwise 0.
836 * @see tbm_bo_add_user_data()
837 * @see tbm_bo_set_user_data()
838 * @see tbm_bo_delete_user_data()
841 #include <tbm_bufmgr.h>
843 void example_data_free (void *user_data)
845 char *data = (char*) user_data;
858 bufmgr = tbm_bufmgr_init (bufmgr_fd);
859 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
860 user_data = (char*) malloc (sizeof(char) * 128);
864 tbm_bo_add_user_data (bo, 1, example_data_free);
865 tbm_bo_set_user_data (bo, 1, user_data);
869 ret = tbm_bo_get_user_data (bo, 1, &get_data);
870 tbm_bo_delete_user_data (bo, 1);
875 tbm_bufmgr_deinit (bufmgr);
879 int tbm_bo_set_user_data(tbm_bo bo, unsigned long key, void *data);
882 * @brief Gets a user_data from the buffer object with the key.
883 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
884 * @param[in] bo : the buffer object
885 * @param[in] key : the key associated with the user_date
886 * @param[out] data : to get the user data
887 * @return 1 if this function succeeds, otherwise 0.
888 * @see tbm_bo_add_user_data()
889 * @see tbm_bo_set_user_data()
890 * @see tbm_bo_get_user_data()
893 #include <tbm_bufmgr.h>
895 void example_data_free (void *user_data)
897 char *data = (char*) user_data;
910 bufmgr = tbm_bufmgr_init (bufmgr_fd);
911 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
912 user_data = (char*) malloc (sizeof(char) * 128);
916 tbm_bo_add_user_data (bo, 1, example_data_free);
917 tbm_bo_set_user_data (bo, 1, user_data);
921 ret = tbm_bo_get_user_data (bo, 1, &get_data);
922 tbm_bo_delete_user_data (bo, 1);
927 tbm_bufmgr_deinit (bufmgr);
931 int tbm_bo_get_user_data(tbm_bo bo, unsigned long key, void **data);
934 * @brief Gets the latest tbm_error.
936 * @return the latest tbm_error
939 #include <tbm_bufmgr.h>
944 tbm_bo_handle handle;
947 bufmgr = tbm_bufmgr_init (bufmgr_fd);
948 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
951 error = tbm_get_last_error ();
957 handle = tbm_bo_map (bo, TBM_DEVICE_2D, TBM_OPTION_READ|TBM_OPTION_WRITE);
958 if (handle.ptr == NULL)
960 error = tbm_get_last_error ();
968 tbm_bufmgr_deinit (bufmgr);
971 tbm_error_e tbm_get_last_error(void);
974 * @brief Gets the tbm buffer capability.
976 * @param[in] bufmgr : the buffer manager
977 * @return the tbm bufmgr capability
980 #include <tbm_bufmgr.h>
984 unsigned int capability;
986 bufmgr = tbm_bufmgr_init (bufmgr_fd);
988 capability = tbm_bufmgr_get_capability (bufmgr);
990 tbm_bufmgr_deinit (bufmgr);
993 unsigned int tbm_bufmgr_get_capability(tbm_bufmgr bufmgr);
996 * @brief Gets the tbm bo flags.
998 * @param[in] bo : the buffer object
999 * @return the tbm bo flags
1003 #include <tbm_bufmgr.h>
1010 bufmgr = tbm_bufmgr_init (bufmgr_fd);
1011 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
1012 flags = tbm_bo_get_flags (bo);
1017 tbm_bufmgr_deinit (bufmgr);
1021 int tbm_bo_get_flags(tbm_bo bo);
1024 * @brief Print out the information of tbm_bos.
1026 * @param[in] bufmgr : the buffer manager
1028 void tbm_bufmgr_debug_show(tbm_bufmgr bufmgr);
1031 * @brief Print out the trace of tbm_bos.
1033 * @param[in] bufmgr : the buffer manager
1034 * @param[in] onoff : 1 is on, and 0 is off
1036 void tbm_bufmgr_debug_trace(tbm_bufmgr bufmgr, int onoff);
1038 int tbm_bufmgr_bind_native_display(tbm_bufmgr bufmgr, void *NativeDisplay);
1043 #endif /* _TBM_BUFMGR_H_ */