- if (bo1->bufmgr->backend->bo_size(bo1) != bo2->bufmgr->backend->bo_size(bo2)) {
- _tbm_set_last_result(TBM_BO_ERROR_SWAP_FAILED);
- TBM_ERR("error: bo1(%p) bo2(%p)\n", bo1, bo2);
- _tbm_bo_mutex_unlock();
- return 0;
+ if (bo1->bufmgr->use_hal_tbm) {
+ size1 = hal_tbm_bo_get_size((hal_tbm_bo *)bo1->bo_data, (hal_tbm_error *)&error1);
+ if (error1 != TBM_ERROR_NONE) {
+ TBM_ERR("fail to get the size of bo1.(%d)", error1);
+ _tbm_set_last_result(error1);
+ goto fail;
+ }
+ size2 = hal_tbm_bo_get_size((hal_tbm_bo *)bo2->bo_data, (hal_tbm_error *)&error2);
+ if (error2 != TBM_ERROR_NONE) {
+ TBM_ERR("fail to get the size of bo1.(%d)", error2);
+ _tbm_set_last_result(error2);
+ goto fail;
+ }
+ } else if (bo1->bufmgr->backend_module_data) {
+ size1 = bo1->bufmgr->bo_func->bo_get_size(bo1->bo_data, &error1);
+ if (error1 != TBM_ERROR_NONE) {
+ TBM_ERR("fail to get the size of bo1.(%d)", error1);
+ _tbm_set_last_result(error1);
+ goto fail;
+ }
+ size2 = bo2->bufmgr->bo_func->bo_get_size(bo2->bo_data, &error2);
+ if (error2 != TBM_ERROR_NONE) {
+ TBM_ERR("fail to get the size of bo2.(%d)", error2);
+ _tbm_set_last_result(error2);
+ goto fail;
+ }
+ } else {
+ size1 = bo1->bufmgr->backend->bo_size(bo1);
+ size2 = bo2->bufmgr->backend->bo_size(bo2);
+ }
+
+ if (size1 != size2) {
+ TBM_ERR("error: bo1 size(%d) and bo2 size(%d) is different.", size1, size2);
+ _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION);
+ goto fail;