From: SooChan Lim Date: Wed, 21 Feb 2018 10:56:02 +0000 (+0900) Subject: bufmgr: add tbm_bufmgr_server_init api X-Git-Tag: accepted/tizen/unified/20180223.062054~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b12858ea5932b576bfd84d4409baf391b6a32b72;p=platform%2Fcore%2Fuifw%2Flibtbm.git bufmgr: add tbm_bufmgr_server_init api The tbm_bufmgr_server_init is called by the display server. This api will be used instead of setting the TBM_DISPLAY_SERVER env variable. Change-Id: I94e3b338dc08b2f7b8482b623738b5728f24b426 --- diff --git a/src/tbm_bufmgr.c b/src/tbm_bufmgr.c index 5f55aef..03aaa9d 100644 --- a/src/tbm_bufmgr.c +++ b/src/tbm_bufmgr.c @@ -690,6 +690,12 @@ _tbm_bufmgr_init(int fd, int server) gBufMgr->fd = fd; + /* set the display_server flag before loading the backend module */ + if (server) { + TBM_LOG_I("The tbm_bufmgr(%p) is used by display server. Need to bind the native_display.\n", gBufMgr); + gBufMgr->display_server = 1; + } + /* load bufmgr priv from env */ if (!_tbm_load_module(gBufMgr, gBufMgr->fd)) { _tbm_set_last_result(TBM_BO_ERROR_LOAD_MODULE_FAILED); @@ -1803,6 +1809,16 @@ tbm_bufmgr_bind_native_display(tbm_bufmgr bufmgr, void *native_display) return 1; } +tbm_bufmgr +tbm_bufmgr_server_init(void) +{ + tbm_bufmgr bufmgr; + + bufmgr = _tbm_bufmgr_init(-1, 1); + + return bufmgr; +} + int tbm_bufmgr_get_fd_limit(void) { struct rlimit lim; diff --git a/src/tbm_bufmgr.h b/src/tbm_bufmgr.h index f37bff1..0112312 100644 --- a/src/tbm_bufmgr.h +++ b/src/tbm_bufmgr.h @@ -1030,6 +1030,13 @@ int tbm_bo_get_flags(tbm_bo bo); int tbm_bufmgr_bind_native_display(tbm_bufmgr bufmgr, void *native_display); /** + * @brief Initializes the buffer manager at the display server. + * @details use this api to initialize the tbm_bufmgr at the display server. + * @since_tizen 5.0 + */ +tbm_bufmgr tbm_bufmgr_server_init(void); + +/** * @brief Print out the information of tbm_bos. * @since_tizen 3.0 * @param[in] bufmgr : the buffer manager diff --git a/src/tbm_bufmgr_backend.c b/src/tbm_bufmgr_backend.c index 9bbf53c..ad809ff 100644 --- a/src/tbm_bufmgr_backend.c +++ b/src/tbm_bufmgr_backend.c @@ -112,10 +112,17 @@ int tbm_backend_is_display_server(void) { const char *value; - value = (const char*)getenv("TBM_DISPLAY_SERVER"); - if (!value) + if (gBufMgr == NULL) { + TBM_LOG_E("error: no gBufMgr.\n"); return 0; + } - return 1; + /* TODO: TBM_DISPLAY_SERVER will be removed */ + value = (const char*)getenv("TBM_DISPLAY_SERVER"); + + if (value || gBufMgr->display_server) + return 1; + + return 0; } /* LCOV_EXCL_STOP */ diff --git a/src/tbm_bufmgr_int.h b/src/tbm_bufmgr_int.h index 32cf5a6..fc427cb 100644 --- a/src/tbm_bufmgr_int.h +++ b/src/tbm_bufmgr_int.h @@ -56,6 +56,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define DEBUG #ifdef DEBUG extern int bDebug; +extern tbm_bufmgr gBufMgr; #define TBM_DBG(...) { if (bDebug&0x1) TBM_LOG_D(__VA_ARGS__); } #define TBM_DBG_LOCK(...) { if (bDebug&0x2) TBM_LOG_D(__VA_ARGS__); } @@ -249,6 +250,7 @@ struct _tbm_bufmgr { struct list_head debug_key_list; /* list of debug data key list belonging to bufmgr */ void *module_data; tbm_bufmgr_backend backend; /* bufmgr backend */ + int display_server; /* used by display server */ }; /**