tbm_module: add tbm_module_bo_lock and use it
[platform/core/uifw/libtbm.git] / src / tbm_bo.c
index e918436..d837067 100644 (file)
@@ -138,35 +138,23 @@ user_data_delete(tbm_user_data *user_data)
 static int
 _bo_lock(tbm_bo bo, int device, int opt)
 {
-       int ret = 1;
        tbm_error_e error;
+       int ret;
 
-       if (bo->bufmgr->use_hal_tbm) {
-               error = (tbm_error_e)hal_tbm_bo_lock((hal_tbm_bo *)bo->bo_data, device, opt);
-               if (error == TBM_ERROR_NOT_SUPPORTED) {
+       error = tbm_module_bo_lock(bo->bufmgr->module, bo, bo->bo_data, device, opt);
+       _tbm_set_last_result(error);
+       switch(error) {
+               case TBM_ERROR_NONE:
+                       ret = 1;
+                       break;
+               case TBM_ERROR_NOT_SUPPORTED:
+                       ret = 1;
                        _tbm_set_last_result(TBM_ERROR_NONE);
-               } else {
-                       if (error != TBM_ERROR_NONE) {
-                               TBM_WRN("fail to lock");
-                               _tbm_set_last_result(error);
-                               ret = 0;
-                       }
-               }
-       } else if (bo->bufmgr->backend_module_data) {
-               if (bo->bufmgr->bo_func->bo_lock) {
-                       error = bo->bufmgr->bo_func->bo_lock(bo->bo_data, device, opt);
-                       if (error != TBM_ERROR_NONE) {
-                               TBM_WRN("fail to lock");
-                               _tbm_set_last_result(error);
-                               ret = 0;
-                       }
-               }
-       } else {
-               if (bo->bufmgr->backend->bo_lock) {
-                       ret = bo->bufmgr->backend->bo_lock(bo, device, opt);
-                       if (!ret)
-                               _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION);
-               }
+                       break;
+               default:
+                       ret = 0;
+                       TBM_WRN("fail to lock. error:%d", error);
+                       break;
        }
 
        return ret;