/* LCOV_EXCL_STOP */
}
- if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
- LIST_FOR_EACH_ENTRY(bo2, &bufmgr->bo_list, item_link) {
- if (bo2->bo_data == bo->bo_data) {
- TBM_TRACE_BO("find bo(%p) ref(%d) key(%d) flag(%s) in list",
- bo2, bo2->ref_cnt, key, _tbm_flag_to_str(bo2->flags));
- bo2->ref_cnt++;
- free(bo);
- _tbm_bufmgr_mutex_unlock();
- return bo2;
- }
- }
+ // return the existed bo2 if bo->bo_data and bo2->bo_data is the same
+ bo2 = tbm_bufmgr_internal_find_bo(bufmgr, bo);
+ if (bo2) {
+ TBM_TRACE_BO("find bo(%p) ref(%d) key(%d) flag(%s) in list",
+ bo2, bo2->ref_cnt, key, _tbm_flag_to_str(bo2->flags));
+ bo2->ref_cnt++;
+ free(bo);
+ _tbm_bufmgr_mutex_unlock();
+ return bo2;
}
if (bufmgr->use_hal_tbm) {
/* LCOV_EXCL_STOP */
}
- if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
- LIST_FOR_EACH_ENTRY(bo2, &bufmgr->bo_list, item_link) {
- if (bo2->bo_data == bo->bo_data) {
- TBM_TRACE_BO("find bo(%p) ref(%d) fd(%d) flag(%s) in list\n",
- bo2, bo2->ref_cnt, fd, _tbm_flag_to_str(bo2->flags));
- bo2->ref_cnt++;
- free(bo);
- _tbm_bufmgr_mutex_unlock();
- return bo2;
- }
- }
+ // return the existed bo2 if bo->bo_data and bo2->bo_data is the same
+ bo2 = tbm_bufmgr_internal_find_bo(bufmgr, bo);
+ if (bo2) {
+ TBM_TRACE_BO("find bo(%p) ref(%d) fd(%d) flag(%s) in list",
+ bo2, bo2->ref_cnt, fd, _tbm_flag_to_str(bo2->flags));
+ bo2->ref_cnt++;
+ free(bo);
+ _tbm_bufmgr_mutex_unlock();
+ return bo2;
}
if (bufmgr->use_hal_tbm) {
{
return gBufMgr;
}
+
+
+tbm_bo
+tbm_bufmgr_internal_find_bo(tbm_bufmgr bufmgr, tbm_bo bo)
+{
+ tbm_bo bo2 = NULL;
+
+ TBM_RETURN_VAL_IF_FAIL(TBM_BUFMGR_IS_VALID(gBufMgr), NULL);
+ TBM_RETURN_VAL_IF_FAIL(bufmgr == gBufMgr, NULL);
+
+ if (LIST_IS_EMPTY(&bufmgr->bo_list))
+ return NULL;
+
+ LIST_FOR_EACH_ENTRY(bo2, &bufmgr->bo_list, item_link) {
+ if (bo2->bo_data == bo->bo_data) {
+ return bo2;
+ }
+ }
+
+ return NULL;
+}
+
/* LCOV_EXCL_STOP */
/* functions for mutex */
void _tbm_bufmgr_mutex_lock(void);
void _tbm_bufmgr_mutex_unlock(void);
+tbm_bo tbm_bufmgr_internal_find_bo(tbm_bufmgr bufmgr, tbm_bo bo);
tbm_bo tbm_bo_alloc_with_format(tbm_bufmgr bufmgr, int format, int bo_idx, int width, int bpp, int height, tbm_bo_memory_type flags, tbm_error_e *error);
tbm_bo tbm_bo_alloc_with_bo_data(tbm_bufmgr bufmgr, tbm_backend_bo_data *bo_data, int flags);