add bo_lock2 as a backend fucntion
authorSooChan Lim <sc1.lim@samsung.com>
Wed, 8 May 2013 10:39:44 +0000 (19:39 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Mon, 17 Jun 2013 01:34:58 +0000 (10:34 +0900)
Change-Id: I5272932d999910048a7ff7836a7bbe5458852a74

src/tbm_bufmgr.c
src/tbm_bufmgr_backend.h

index 6636cc2..9919c4b 100755 (executable)
@@ -311,7 +311,7 @@ _user_data_delete (tbm_user_data *user_data)
 }
 
 static int
-_bo_lock (tbm_bo bo)
+_bo_lock (tbm_bo bo, int device, int opt)
 {
     tbm_bufmgr bufmgr = bo->bufmgr;
     int ret = 0;
@@ -319,9 +319,15 @@ _bo_lock (tbm_bo bo)
     if (bufmgr->backend->flags&TBM_LOCK_CTRL_BACKEND &&
         bufmgr->backend->bo_lock)
     {
-        /* use backend lock */
+        /* use bo_lock2 backend lock */
         ret = bufmgr->backend->bo_lock (bo);
     }
+    if (bufmgr->backend->flags&TBM_LOCK_CTRL_BACKEND &&
+        bufmgr->backend->bo_lock2)
+    {
+        /* use bo_lock2 backend lock */
+        ret = bufmgr->backend->bo_lock2 (bo, device, opt);
+    }
     else
     {
         /* use tizen global lock */
@@ -350,7 +356,7 @@ _bo_unlock (tbm_bo bo)
 }
 
 static int
-_tbm_bo_lock (tbm_bo bo)
+_tbm_bo_lock (tbm_bo bo, int device, int opt)
 {
     tbm_bufmgr bufmgr = NULL;
     int old;
@@ -375,7 +381,7 @@ _tbm_bo_lock (tbm_bo bo)
     {
         case LOCK_TRY_ALWAYS:    /* LOCK_TRY_ALWAYS */
             pthread_mutex_unlock (&bufmgr->lock);
-            ret = _bo_lock (bo);
+            ret = _bo_lock (bo, device, opt);
             pthread_mutex_lock (&bufmgr->lock);
             if(ret)
                 bo->lock_cnt++;
@@ -387,7 +393,7 @@ _tbm_bo_lock (tbm_bo bo)
             if (bo->lock_cnt == 0)
             {
                 pthread_mutex_unlock (&bufmgr->lock);
-                ret = _bo_lock (bo);
+                ret = _bo_lock (bo, device, opt);
                 pthread_mutex_lock (&bufmgr->lock);
                 if (ret)
                     bo->lock_cnt++;
@@ -1161,7 +1167,7 @@ tbm_bo_map (tbm_bo bo, int device, int opt)
 
     pthread_mutex_lock (&bufmgr->lock);
 
-    _tbm_bo_lock (bo);
+    _tbm_bo_lock (bo, device, opt);
     bo_handle = bufmgr->backend->bo_map (bo, device, opt);
 
     if (bufmgr->use_map_cache == 1 && bo->map_cnt == 0)
index f1f5672..b0b3501 100755 (executable)
@@ -192,11 +192,20 @@ struct _tbm_bufmgr_backend
     */\r
     int           (*bo_unlock)         (tbm_bo bo);\r
 \r
+    /**\r
+    * @brief lock the buffer object with a device and an opt.\r
+    * @param[in] bo : the buffer object\r
+    * @param[in] device : the device type to get a handle\r
+    * @param[in] option : the option to access the buffer object\r
+    * @return 1 if this function succeeds, otherwise 0.\r
+    * @remark This function pointer could be null. (default: use the tizen global lock)\r
+    */\r
+    int           (*bo_lock2)           (tbm_bo bo, int device, int opt);\r
+\r
     /* Padding for future extension */\r
     void (*reserved1)    (void);\r
     void (*reserved2)    (void);\r
     void (*reserved3)    (void);\r
-    void (*reserved4)    (void);\r
 };\r
 \r
 /**\r