bufmgr: add tbm_bufmgr_server_init api 74/170774/4
authorSooChan Lim <sc1.lim@samsung.com>
Wed, 21 Feb 2018 10:56:02 +0000 (19:56 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Thu, 22 Feb 2018 07:54:36 +0000 (07:54 +0000)
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

src/tbm_bufmgr.c
src/tbm_bufmgr.h
src/tbm_bufmgr_backend.c
src/tbm_bufmgr_int.h

index 5f55aef..03aaa9d 100644 (file)
@@ -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;
index f37bff1..0112312 100644 (file)
@@ -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
index 9bbf53c..ad809ff 100644 (file)
@@ -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 */
index 32cf5a6..fc427cb 100644 (file)
@@ -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 */
 };
 
 /**