Don't use unneeded backend function if backend package use libtbm 2.0 version 37/59737/1
authorChangyeon Lee <cyeon.lee@samsung.com>
Mon, 15 Feb 2016 06:05:52 +0000 (15:05 +0900)
committerChangyeon Lee <cyeon.lee@samsung.com>
Thu, 18 Feb 2016 05:02:00 +0000 (14:02 +0900)
Change-Id: I49979865a06d2748a66c6cb4bcd220dfd47dce42
Signed-off-by: Changyeon Lee <cyeon.lee@samsung.com>
src/tbm_bufmgr.c
src/tbm_bufmgr.h
src/tbm_bufmgr_backend.c
src/tbm_bufmgr_backend.h
src/tbm_bufmgr_int.h
src/tbm_surface_internal.c

index 7916afe..4ea8c79 100644 (file)
@@ -51,6 +51,7 @@ int bDebug = 0;
 #define SUFFIX_LIB    ".so"
 #define DEFAULT_LIB   PREFIX_LIB"default"SUFFIX_LIB
 
+/* unneeded version 2.0 */
 #define BO_IS_CACHEABLE(bo) ((bo->flags & TBM_BO_NONCACHABLE) ? 0 : 1)
 #define DEVICE_IS_CACHE_AWARE(device) ((device == TBM_DEVICE_CPU) ? (1) : (0))
 
@@ -61,6 +62,7 @@ int bDebug = 0;
 #define CACHE_OP_CREATE     (-1)
 #define CACHE_OP_ATTACH     (-2)
 #define CACHE_OP_IMPORT     (-3)
+/* unneeded version 2.0 */
 
 /* values to indicate unspecified fields in XF86ModReqInfo. */
 #define MAJOR_UNSPEC        0xFF
@@ -80,11 +82,13 @@ enum {
        LOCK_TRY_NEVER
 };
 
+/* unneeded version 2.0 */
 enum {
        DEVICE_NONE = 0,
        DEVICE_CA,                                      /* cache aware device */
        DEVICE_CO                                       /* cache oblivious device */
 };
+/* unneeded version 2.0 */
 
 pthread_mutex_t gLock = PTHREAD_MUTEX_INITIALIZER;
 tbm_bufmgr gBufMgr = NULL;
@@ -146,6 +150,8 @@ static void _tbm_util_get_appname_from_pid(long pid, char *str)
        snprintf(str, sizeof(cmdline), "%s", cmdline);
 }
 
+
+/* unneeded version 2.0 */
 static inline int _tgl_init(int fd, unsigned int key)
 {
        struct tgl_attribute attr;
@@ -244,6 +250,7 @@ static inline unsigned int _tgl_get_data(int fd, unsigned int key, unsigned int
 
        return arg.data1;
 }
+/* unneeded version 2.0 */
 
 tbm_user_data *user_data_lookup(struct list_head *user_data_list, unsigned long key)
 {
@@ -292,7 +299,7 @@ static int _bo_lock(tbm_bo bo, int device, int opt)
        tbm_bufmgr bufmgr = bo->bufmgr;
        int ret = 0;
 
-       if (TBM_LOCK_CTRL_BACKEND_VALID(bufmgr->backend->flags)) {
+       if (bufmgr->use_2_0) {
                if (bufmgr->backend->bo_lock2) {
                        /* use bo_lock2 backend lock */
                        ret = bufmgr->backend->bo_lock2(bo, device, opt);
@@ -305,8 +312,22 @@ static int _bo_lock(tbm_bo bo, int device, int opt)
                                getpid(), __FUNCTION__, __LINE__);
                }
        } else {
-               /* use tizen global lock */
-               ret = _tgl_lock(bufmgr->lock_fd, bo->tgl_key);
+               if (TBM_LOCK_CTRL_BACKEND_VALID(bufmgr->backend->flags)) {
+                       if (bufmgr->backend->bo_lock2) {
+                               /* use bo_lock2 backend lock */
+                               ret = bufmgr->backend->bo_lock2(bo, device, opt);
+                       } else if (bufmgr->backend->bo_lock) {
+                               /* use bo_lock backend lock */
+                               ret = bufmgr->backend->bo_lock(bo);
+                       } else {
+                               TBM_LOG("[libtbm:%d] "
+                                       "error %s:%d no backend lock functions\n",
+                                       getpid(), __FUNCTION__, __LINE__);
+                       }
+               } else {
+                       /* use tizen global lock */
+                       ret = _tgl_lock(bufmgr->lock_fd, bo->tgl_key);
+               }
        }
 
        return ret;
@@ -316,7 +337,7 @@ static void _bo_unlock(tbm_bo bo)
 {
        tbm_bufmgr bufmgr = bo->bufmgr;
 
-       if (TBM_LOCK_CTRL_BACKEND_VALID(bufmgr->backend->flags)) {
+       if (bufmgr->use_2_0) {
                if (bufmgr->backend->bo_unlock) {
                        /* use backend unlock */
                        bufmgr->backend->bo_unlock(bo);
@@ -325,9 +346,21 @@ static void _bo_unlock(tbm_bo bo)
                                "error %s:%d no backend unlock functions\n",
                                getpid(), __FUNCTION__, __LINE__);
                }
-       } else {
-               /* use tizen global unlock */
-               _tgl_unlock(bufmgr->lock_fd, bo->tgl_key);
+       }
+       else {
+               if (TBM_LOCK_CTRL_BACKEND_VALID(bufmgr->backend->flags)) {
+                       if (bufmgr->backend->bo_unlock) {
+                               /* use backend unlock */
+                               bufmgr->backend->bo_unlock(bo);
+                       } else {
+                               TBM_LOG("[libtbm:%d] "
+                                       "error %s:%d no backend unlock functions\n",
+                                       getpid(), __FUNCTION__, __LINE__);
+                       }
+               } else {
+                       /* use tizen global unlock */
+                       _tgl_unlock(bufmgr->lock_fd, bo->tgl_key);
+               }
        }
 }
 
@@ -593,8 +626,10 @@ static void _tbm_bo_unref(tbm_bo bo)
                        _bo_unlock(bo);
                }
 
-               /* Destroy Global Lock */
-               _tbm_bo_destroy_state(bo);
+               if (!bufmgr->use_2_0) {
+                       /* Destroy Global Lock */
+                       _tbm_bo_destroy_state(bo);
+               }
 
                /* call the bo_free */
                bufmgr->backend->bo_free(bo);
@@ -892,6 +927,11 @@ tbm_bufmgr tbm_bufmgr_init(int fd)
                        DBG("TBM ");
                }
 
+               if (backend_flag & TBM_USE_2_0_BACKEND) {
+                       gBufMgr->use_2_0 = 1;
+                       DBG("USE 2.0 backend");
+               }
+
                DBG("\n");
        }
 
@@ -915,22 +955,33 @@ tbm_bufmgr tbm_bufmgr_init(int fd)
                return NULL;
        }
 
-       /* intialize the tizen global status */
-       if (!_tbm_bufmgr_init_state(gBufMgr)) {
-               _tbm_set_last_result(TBM_BO_ERROR_INIT_STATE_FAILED);
-               TBM_LOG("[libtbm:%d] " "error: Fail to init state\n", getpid());
-               gBufMgr->backend->bufmgr_deinit(gBufMgr->backend->priv);
-               tbm_backend_free(gBufMgr->backend);
-               pthread_mutex_destroy(&gBufMgr->lock);
-               dlclose(gBufMgr->module_data);
+       if (!gBufMgr->use_2_0) {
+               /* intialize the tizen global status */
+               if (!_tbm_bufmgr_init_state(gBufMgr)) {
+                       _tbm_set_last_result(TBM_BO_ERROR_INIT_STATE_FAILED);
+                       TBM_LOG("[libtbm:%d] " "error: Fail to init state\n", getpid());
+                       gBufMgr->backend->bufmgr_deinit(gBufMgr->backend->priv);
+                       tbm_backend_free(gBufMgr->backend);
+                       pthread_mutex_destroy(&gBufMgr->lock);
+                       dlclose(gBufMgr->module_data);
 
-               if (gBufMgr->fd > 0)
-                       close(gBufMgr->fd);
+                       if (gBufMgr->fd > 0)
+                               close(gBufMgr->fd);
 
-               free(gBufMgr);
-               gBufMgr = NULL;
-               pthread_mutex_unlock(&gLock);
-               return NULL;
+                       free(gBufMgr);
+                       gBufMgr = NULL;
+                       pthread_mutex_unlock(&gLock);
+                       return NULL;
+               }
+
+               /* setup the map_cache */
+               env = getenv("BUFMGR_MAP_CACHE");
+               if (env && !strcmp(env, "false"))
+                       gBufMgr->use_map_cache = 0;
+               else
+                       gBufMgr->use_map_cache = 1;
+               DBG("[libtbm:%d] BUFMGR_MAP_CACHE=%s\n",
+                       getpid(), env ? env : "default:true");
        }
 
        /* setup the lock_type */
@@ -947,15 +998,6 @@ tbm_bufmgr tbm_bufmgr_init(int fd)
        DBG("[libtbm:%d] BUFMGR_LOCK_TYPE=%s\n",
                getpid(), env ? env : "default:once");
 
-       /* setup the map_cache */
-       env = getenv("BUFMGR_MAP_CACHE");
-       if (env && !strcmp(env, "false"))
-               gBufMgr->use_map_cache = 0;
-       else
-               gBufMgr->use_map_cache = 1;
-       DBG("[libtbm:%d] BUFMGR_MAP_CACHE=%s\n",
-               getpid(), env ? env : "default:true");
-
        /* intialize bo_list */
        LIST_INITHEAD(&gBufMgr->bo_list);
 
@@ -1008,8 +1050,10 @@ void tbm_bufmgr_deinit(tbm_bufmgr bufmgr)
                }
        }
 
-       /* destroy the tizen global status */
-       _tbm_bufmgr_destroy_state(bufmgr);
+       if (!bufmgr->use_2_0) {
+               /* destroy the tizen global status */
+               _tbm_bufmgr_destroy_state(bufmgr);
+       }
 
        /* destroy bufmgr priv */
        bufmgr->backend->bufmgr_deinit(bufmgr->backend->priv);
@@ -1106,16 +1150,19 @@ tbm_bo tbm_bo_alloc(tbm_bufmgr bufmgr, int size, int flags)
 
        bo->ref_cnt = 1;
        bo->flags = flags;
-       bo->tgl_key = INITIAL_KEY;
        bo->priv = bo_priv;
-       bo->default_handle.u32 = 0;
 
-       /* init bo state */
-       if (!_tbm_bo_init_state(bo, CACHE_OP_CREATE)) {
-               _tbm_set_last_result(TBM_BO_ERROR_INIT_STATE_FAILED);
-               _tbm_bo_unref(bo);
-               pthread_mutex_unlock(&bufmgr->lock);
-               return NULL;
+       if (!bufmgr->use_2_0) {
+               bo->tgl_key = INITIAL_KEY;
+               bo->default_handle.u32 = 0;
+
+               /* init bo state */
+               if (!_tbm_bo_init_state(bo, CACHE_OP_CREATE)) {
+                       _tbm_set_last_result(TBM_BO_ERROR_INIT_STATE_FAILED);
+                       _tbm_bo_unref(bo);
+                       pthread_mutex_unlock(&bufmgr->lock);
+                       return NULL;
+               }
        }
 
        LIST_INITHEAD(&bo->user_data_list);
@@ -1138,17 +1185,19 @@ tbm_bo tbm_bo_import(tbm_bufmgr bufmgr, unsigned int key)
 
        pthread_mutex_lock(&bufmgr->lock);
 
-       /* find bo in list */
-       if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
-               LIST_FOR_EACH_ENTRY_SAFE(bo2, tmp, &bufmgr->bo_list, item_link) {
-                       if (bo2->tgl_key == key) {
-                               DBG("[libtbm:%d] "
-                                       "find bo(%p, ref:%d key:%d) in list \n",
-                                       getpid(), bo2, bo2->ref_cnt, bo2->tgl_key);
-
-                               bo2->ref_cnt++;
-                               pthread_mutex_unlock(&bufmgr->lock);
-                               return bo2;
+       if (!bufmgr->use_2_0) {
+               /* find bo in list */
+               if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
+                       LIST_FOR_EACH_ENTRY_SAFE(bo2, tmp, &bufmgr->bo_list, item_link) {
+                               if (bo2->tgl_key == key) {
+                                       DBG("[libtbm:%d] "
+                                               "find bo(%p, ref:%d key:%d) in list \n",
+                                               getpid(), bo2, bo2->ref_cnt, bo2->tgl_key);
+
+                                       bo2->ref_cnt++;
+                                       pthread_mutex_unlock(&bufmgr->lock);
+                                       return bo2;
+                               }
                        }
                }
        }
@@ -1169,24 +1218,44 @@ tbm_bo tbm_bo_import(tbm_bufmgr bufmgr, unsigned int key)
                return NULL;
        }
 
+       if (bufmgr->use_2_0) {
+               if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
+                       LIST_FOR_EACH_ENTRY_SAFE(bo2, tmp, &bufmgr->bo_list, item_link) {
+                               if (bo2->priv == bo_priv) {
+                                       DBG("[libtbm:%d] "
+                                               "find bo(%p, ref:%d key:%d) in list \n",
+                                               getpid(), bo2, bo2->ref_cnt, bo2->tgl_key);
+
+                                       bo2->ref_cnt++;
+                                       free(bo);
+                                       pthread_mutex_unlock(&bufmgr->lock);
+                                       return bo2;
+                               }
+                       }
+               }
+       }
+
        bo->ref_cnt = 1;
-       bo->tgl_key = INITIAL_KEY;
        bo->priv = bo_priv;
-       bo->default_handle.u32 = 0;
+
+       if (!bufmgr->use_2_0) {
+               bo->tgl_key = INITIAL_KEY;
+               bo->default_handle.u32 = 0;
+
+               /* init bo state */
+               if (!_tbm_bo_init_state(bo, CACHE_OP_IMPORT)) {
+                       _tbm_set_last_result(TBM_BO_ERROR_INIT_STATE_FAILED);
+                       _tbm_bo_unref(bo);
+                       pthread_mutex_unlock(&bufmgr->lock);
+                       return NULL;
+               }
+       }
 
        if (bufmgr->backend->bo_get_flags)
                bo->flags = bufmgr->backend->bo_get_flags(bo);
        else
                bo->flags = TBM_BO_DEFAULT;
 
-       /* init bo state */
-       if (!_tbm_bo_init_state(bo, CACHE_OP_IMPORT)) {
-               _tbm_set_last_result(TBM_BO_ERROR_INIT_STATE_FAILED);
-               _tbm_bo_unref(bo);
-               pthread_mutex_unlock(&bufmgr->lock);
-               return NULL;
-       }
-
        LIST_INITHEAD(&bo->user_data_list);
 
        LIST_ADD(&bo->item_link, &bufmgr->bo_list);
@@ -1208,19 +1277,21 @@ tbm_bo tbm_bo_import_fd(tbm_bufmgr bufmgr, tbm_fd fd)
 
        pthread_mutex_lock(&bufmgr->lock);
 
-       default_handle = bufmgr->backend->fd_to_handle(bufmgr, fd, TBM_DEVICE_DEFAULT);
+       if (!bufmgr->use_2_0) {
+               default_handle = bufmgr->backend->fd_to_handle(bufmgr, fd, TBM_DEVICE_DEFAULT);
 
-       /* find bo in list */
-       if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
-               LIST_FOR_EACH_ENTRY_SAFE(bo2, tmp, &bufmgr->bo_list, item_link) {
-                       if (bo2->default_handle.u32 == default_handle.u32) {
-                               DBG("[libtbm:%d] "
-                                       "find bo(%p, ref:%d handle:%d) in list \n",
-                                       getpid(), bo2, bo2->ref_cnt, bo2->default_handle.u32);
-
-                               bo2->ref_cnt++;
-                               pthread_mutex_unlock(&bufmgr->lock);
-                               return bo2;
+               /* find bo in list */
+               if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
+                       LIST_FOR_EACH_ENTRY_SAFE(bo2, tmp, &bufmgr->bo_list, item_link) {
+                               if (bo2->default_handle.u32 == default_handle.u32) {
+                                       DBG("[libtbm:%d] "
+                                               "find bo(%p, ref:%d handle:%d) in list \n",
+                                               getpid(), bo2, bo2->ref_cnt, bo2->default_handle.u32);
+
+                                       bo2->ref_cnt++;
+                                       pthread_mutex_unlock(&bufmgr->lock);
+                                       return bo2;
+                               }
                        }
                }
        }
@@ -1241,24 +1312,44 @@ tbm_bo tbm_bo_import_fd(tbm_bufmgr bufmgr, tbm_fd fd)
                return NULL;
        }
 
+       if (bufmgr->use_2_0) {
+               if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
+                       LIST_FOR_EACH_ENTRY_SAFE(bo2, tmp, &bufmgr->bo_list, item_link) {
+                               if (bo2->priv == bo_priv) {
+                                       DBG("[libtbm:%d] "
+                                               "find bo(%p, ref:%d key:%d) in list \n",
+                                               getpid(), bo2, bo2->ref_cnt, bo2->tgl_key);
+
+                                       bo2->ref_cnt++;
+                                       free(bo);
+                                       pthread_mutex_unlock(&bufmgr->lock);
+                                       return bo2;
+                               }
+                       }
+               }
+       }
+
        bo->ref_cnt = 1;
-       bo->tgl_key = INITIAL_KEY;
        bo->priv = bo_priv;
-       bo->default_handle.u32 = 0;
+
+       if (!bufmgr->use_2_0) {
+               bo->tgl_key = INITIAL_KEY;
+               bo->default_handle.u32 = 0;
+
+               /* init bo state */
+               if (!_tbm_bo_init_state(bo, CACHE_OP_IMPORT)) {
+                       _tbm_set_last_result(TBM_BO_ERROR_INIT_STATE_FAILED);
+                       _tbm_bo_unref(bo);
+                       pthread_mutex_unlock(&bufmgr->lock);
+                       return NULL;
+               }
+       }
 
        if (bufmgr->backend->bo_get_flags)
                bo->flags = bufmgr->backend->bo_get_flags(bo);
        else
                bo->flags = TBM_BO_DEFAULT;
 
-       /* init bo state */
-       if (!_tbm_bo_init_state(bo, CACHE_OP_IMPORT)) {
-               _tbm_set_last_result(TBM_BO_ERROR_INIT_STATE_FAILED);
-               _tbm_bo_unref(bo);
-               pthread_mutex_unlock(&bufmgr->lock);
-               return NULL;
-       }
-
        LIST_INITHEAD(&bo->user_data_list);
 
        LIST_ADD(&bo->item_link, &bufmgr->bo_list);
@@ -1342,8 +1433,6 @@ tbm_bo_handle tbm_bo_map(tbm_bo bo, int device, int opt)
 
        pthread_mutex_lock(&bufmgr->lock);
 
-       bo_handle = bufmgr->backend->bo_get_handle(bo, device);
-
        if (!_tbm_bo_lock(bo, device, opt)) {
                _tbm_set_last_result(TBM_BO_ERROR_LOCK_FAILED);
                TBM_LOG("[libtbm:%d] "
@@ -1365,8 +1454,10 @@ tbm_bo_handle tbm_bo_map(tbm_bo bo, int device, int opt)
                return (tbm_bo_handle) NULL;
        }
 
-       if (bufmgr->use_map_cache == 1 && bo->map_cnt == 0)
-               _tbm_bo_set_state(bo, device, opt);
+       if (!bufmgr->use_2_0) {
+               if (bufmgr->use_map_cache == 1 && bo->map_cnt == 0)
+                       _tbm_bo_set_state(bo, device, opt);
+       }
 
        /* increase the map_count */
        bo->map_cnt++;
@@ -1398,8 +1489,10 @@ int tbm_bo_unmap(tbm_bo bo)
        /* decrease the map_count */
        bo->map_cnt--;
 
-       if (bo->map_cnt == 0)
-               _tbm_bo_save_state(bo);
+       if (!bufmgr->use_2_0) {
+               if (bo->map_cnt == 0)
+                       _tbm_bo_save_state(bo);
+       }
 
        _tbm_bo_unlock(bo);
 
@@ -1425,13 +1518,15 @@ int tbm_bo_swap(tbm_bo bo1, tbm_bo bo2)
                return 0;
        }
 
-       tmp_key = bo1->tgl_key;
-       bo1->tgl_key = bo2->tgl_key;
-       bo2->tgl_key = tmp_key;
+       if (!bo1->bufmgr->use_2_0) {
+               tmp_key = bo1->tgl_key;
+               bo1->tgl_key = bo2->tgl_key;
+               bo2->tgl_key = tmp_key;
 
-       tmp_defualt_handle = bo1->default_handle;
-       bo1->default_handle = bo2->default_handle;
-       bo2->default_handle = tmp_defualt_handle;
+               tmp_defualt_handle = bo1->default_handle;
+               bo1->default_handle = bo2->default_handle;
+               bo2->default_handle = tmp_defualt_handle;
+       }
 
        temp = bo1->priv;
        bo1->priv = bo2->priv;
index 82e403d..7e0930b 100644 (file)
@@ -95,17 +95,6 @@ typedef int32_t tbm_fd;
  */
 #define TBM_DEVICE_MM        4
 
-/**
- * @brief Definition for the cache invalidate
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- */
-#define TBM_CACHE_INV            0x01
-/**
- * @brief Definition for the cache clean
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- */
-#define TBM_CACHE_CLN            0x02
-
 /* TBM_OPTION */
 
 /**
@@ -124,6 +113,19 @@ typedef int32_t tbm_fd;
  */
 #define TBM_OPTION_VENDOR    (0xffff0000)
 
+/* unneeded version 2.0 */
+/**
+ * @brief Definition for the cache invalidate
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
+#define TBM_CACHE_INV            0x01
+/**
+ * @brief Definition for the cache clean
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
+#define TBM_CACHE_CLN            0x02
+/* unneeded version 2.0 */
+
 /**
  * @brief tbm_bo_handle abstraction of the memory handle by TBM_DEVICE_TYPE
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
index bdf32e6..907c993 100644 (file)
@@ -73,10 +73,12 @@ int tbm_backend_init(tbm_bufmgr bufmgr, tbm_bufmgr_backend backend)
 
        flags = backend->flags;
        /* check the backend flags */
-       if (flags & TBM_CACHE_CTRL_BACKEND) {
-               if (!backend->bo_cache_flush) {
-                       TBM_LOG("[libtbm:%d] " "error (%s): TBM_FLAG_CACHE_CTRL_TBM needs backend->bo_cache_flush\n", getpid(), __FUNCTION__);
-                       return 0;
+       if (!(flags & TBM_USE_2_0_BACKEND)) {
+               if (flags & TBM_CACHE_CTRL_BACKEND) {
+                       if (!backend->bo_cache_flush) {
+                               TBM_LOG("[libtbm:%d] " "error (%s): TBM_FLAG_CACHE_CTRL_TBM needs backend->bo_cache_flush\n", getpid(), __FUNCTION__);
+                               return 0;
+                       }
                }
        }
 
index 711dd4c..dba8966 100644 (file)
@@ -63,6 +63,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define TBM_ABI_VERSION        SET_ABI_VERSION(1, 1) /**< current abi vertion  */
 
+/* unneeded version 2.0 */
 /* TBM_CACHE */
 #define TBM_CACHE_INV       0x01 /**< cache invalidate  */
 #define TBM_CACHE_CLN       0x02 /**< cache clean */
@@ -80,6 +81,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  * TBM_LOCK_CTRL_BACKEND indicates  that the backend control the lock of bos.
  */
 #define TBM_LOCK_CTRL_BACKEND    (1 << 1)
+/* unneeded version 2.0 */
+
+#define TBM_USE_2_0_BACKEND      (1 << 2)
 
 typedef struct _tbm_bufmgr_backend *tbm_bufmgr_backend;
 
@@ -164,6 +168,7 @@ struct _tbm_bufmgr_backend {
     */
        int (*bo_unmap) (tbm_bo bo);
 
+       /* version 2.0 dosen't need to backend function bo_cache_flush */
        /**
     * @brief flush the cache of the buffer object.
     * @param[in] bo : the buffer object
@@ -172,6 +177,7 @@ struct _tbm_bufmgr_backend {
     */
        int (*bo_cache_flush) (tbm_bo bo, int flags);
 
+       /* version 2.0 dosen't need to backend function bo_get_global_key */
        /**
     * @brief get the global key associated with the buffer object.
     * @param[in] bo : the buffer object
@@ -213,6 +219,7 @@ struct _tbm_bufmgr_backend {
     */
        int (*surface_supported_format) (uint32_t ** formats, uint32_t * num);
 
+       /* version 2.0 dosen't need to backend function surface get size*/
        /**
     * @brief get the size of the surface with a format.
     * @param[in] surface : the surface
@@ -259,6 +266,8 @@ struct _tbm_bufmgr_backend {
     */
         tbm_fd(*bo_export_fd) (tbm_bo bo);
 
+
+       /* version 2.0 dosen't need to backend function fd_to_handle */
        /**
     * @brief get the tbm_bo_handle according to the device type and the prime fd.
     * @param[in] bufmgr : the tizen buffer manager
index 8c7ad56..8c41b22 100644 (file)
@@ -88,6 +88,15 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
                                                surf->item_link.next && \
                                                surf->item_link.next->prev == &surf->item_link)
 
+#define TBM_DEBUG(fmt, ...)   fprintf(stderr, "[TBM:DEBUG(%d)] " fmt, getpid(), ##__VA_ARGS__)
+#define TBM_LOG(fmt, ...)  fprintf(stderr, "[TBM(%d):%s] " fmt, getpid(), __func__, ##__VA_ARGS__)
+
+struct list_head {
+       struct list_head *prev;
+       struct list_head *next;
+};
+
+/* unneeded version 2.0 */
 #define TBM_ALL_CTRL_BACKEND_VALID(flags) \
                ((flags&TBM_CACHE_CTRL_BACKEND) &&\
                (flags&TBM_LOCK_CTRL_BACKEND))
@@ -96,16 +105,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define TBM_LOCK_CTRL_BACKEND_VALID(flags) \
                (flags&TBM_LOCK_CTRL_BACKEND)
 
-#define TBM_DEBUG(fmt, ...)   fprintf(stderr, "[TBM:DEBUG(%d)] " fmt, getpid(), ##__VA_ARGS__)
-#define TBM_LOG(fmt, ...)  fprintf(stderr, "[TBM(%d):%s] " fmt, getpid(), __func__, ##__VA_ARGS__)
-
 typedef union _tbm_bo_cache_state tbm_bo_cache_state;
 
-struct list_head {
-       struct list_head *prev;
-       struct list_head *next;
-};
-
 union _tbm_bo_cache_state {
        unsigned int val;
        struct {
@@ -115,6 +116,7 @@ union _tbm_bo_cache_state {
                unsigned int isDirtied:2;
        } data;
 };
+/* unneeded version 2.0 */
 
 /**
  * @brief tbm_bo : buffer object of Tizen Buffer Manager
@@ -126,23 +128,26 @@ struct _tbm_bo {
 
        int flags;                                      /* TBM_BO_FLAGS :bo memory type */
 
-       unsigned int tgl_key;           /*global key for tizen global lock */
-
-       /* for cache control */
-       unsigned int map_cnt;           /* device map count */
-       tbm_bo_cache_state cache_state; /*cache state */
-
-       int lock_cnt;                           /* lock count of bo */
-
        struct list_head user_data_list;        /* list of the user_date in bo */
 
        void *priv;                                     /* bo private */
 
        struct list_head item_link;     /* link of bo */
 
+       tbm_surface_h surface; /* tbm_surface */
+
+       int lock_cnt;                           /* lock count of bo */
+
+       unsigned int map_cnt;           /* device map count */
+
+       /* unneeded version 2.0 */
        tbm_bo_handle default_handle; /*default handle */
 
-       tbm_surface_h surface; /* tbm_surface */
+       unsigned int tgl_key;           /*global key for tizen global lock */
+
+       /* for cache control */
+       tbm_bo_cache_state cache_state; /*cache state */
+       /* unneeded version 2.0 */
 };
 
 /**
@@ -156,14 +161,8 @@ struct _tbm_bufmgr {
 
        int fd;                                         /* bufmgr fd */
 
-       int fd_flag;                            /* flag set 1 when bufmgr fd open in tbm_bufmgr_init */
-
-       int lock_fd;                            /* fd of tizen global lock */
-
        int lock_type;                          /* lock_type of bufmgr */
 
-       int use_map_cache;                      /* flag to use the map_cahce */
-
        struct list_head bo_list;       /* list of bos belonging to bufmgr */
 
        struct list_head surf_list;     /* list of surfaces belonging to bufmgr */
@@ -171,6 +170,16 @@ struct _tbm_bufmgr {
        void *module_data;
 
        tbm_bufmgr_backend backend;     /* bufmgr backend */
+
+       int use_2_0;
+
+       /* unneeded version 2.0 */
+       int lock_fd;                            /* fd of tizen global lock */
+
+       int fd_flag;                            /* flag set 1 when bufmgr fd open in tbm_bufmgr_init */
+
+       int use_map_cache;                      /* flag to use the map_cahce */
+       /* unneeded version 2.0 */
 };
 
 /**
index ada4e5d..6a394b7 100644 (file)
@@ -208,27 +208,6 @@ static void _deinit_surface_bufmgr()
        g_surface_bufmgr = NULL;
 }
 
-static int _tbm_surface_internal_query_size(tbm_surface_h surface)
-{
-       TBM_RETURN_VAL_IF_FAIL(surface, 0);
-
-       struct _tbm_surface *surf = (struct _tbm_surface *)surface;
-       struct _tbm_bufmgr *mgr = surf->bufmgr;
-       int size = 0;
-
-       TBM_RETURN_VAL_IF_FAIL(mgr != NULL, 0);
-       TBM_RETURN_VAL_IF_FAIL(surf->info.width > 0, 0);
-       TBM_RETURN_VAL_IF_FAIL(surf->info.height > 0, 0);
-       TBM_RETURN_VAL_IF_FAIL(surf->info.format > 0, 0);
-
-       if (!mgr->backend->surface_get_size)
-               return 0;
-
-       size = mgr->backend->surface_get_size(surf, surf->info.width, surf->info.height, surf->info.format);
-
-       return size;
-}
-
 static int _tbm_surface_internal_query_plane_data(tbm_surface_h surface, int plane_idx, uint32_t * size, uint32_t * offset, uint32_t * pitch, int *bo_idx)
 {
        TBM_RETURN_VAL_IF_FAIL(surface, 0);
@@ -534,7 +513,6 @@ tbm_surface_h tbm_surface_internal_create_with_flags(int width, int height, int
        surf->info.height = height;
        surf->info.format = format;
        surf->info.bpp = tbm_surface_internal_get_bpp(format);
-       surf->info.size = _tbm_surface_internal_query_size(surf);
        surf->info.num_planes = tbm_surface_internal_get_num_planes(format);
        surf->num_bos = _tbm_surface_internal_query_num_bos(format);
        surf->refcnt = 1;
@@ -548,6 +526,9 @@ tbm_surface_h tbm_surface_internal_create_with_flags(int width, int height, int
                surf->planes_bo_idx[i] = bo_idx;
        }
 
+       for (i = 0; i < surf->info.num_planes; i++)
+               surf->info.size += surf->info.planes[i].size;
+
        surf->flags = flags;
 
        for (i = 0; i < surf->num_bos; i++) {