tbm_module: make tbm_module_bufmgr_bind_native_display
[platform/core/uifw/libtbm.git] / src / tbm_backend.c
index cd241b2..4da842c 100644 (file)
@@ -38,13 +38,18 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 int
 tbm_backend_bufmgr_query_display_server(tbm_bufmgr bufmgr, tbm_error_e *error)
 {
+       const char *value;
+
        if (!bufmgr) {
                if (error)
                        *error = TBM_ERROR_INVALID_PARAMETER;
                return 0;
        }
 
-       if (gBufMgr->display_server) {
+       /* TODO: TBM_DISPLAY_SERVER will be removed */
+       value = (const char*)getenv("TBM_DISPLAY_SERVER");
+
+       if (value || gBufMgr->display_server) {
                if (error)
                        *error = TBM_ERROR_NONE;
                return 1;
@@ -90,7 +95,10 @@ tbm_backend_bufmgr_register_bufmgr_func(tbm_bufmgr bufmgr, tbm_backend_bufmgr_fu
        TBM_RETURN_VAL_IF_FAIL(bufmgr, TBM_ERROR_INVALID_PARAMETER);
        TBM_RETURN_VAL_IF_FAIL(func, TBM_ERROR_INVALID_PARAMETER);
 
-       bufmgr->bufmgr_func = func;
+       // The tbm_bufmgr from backend module is actually tbm_module memory in libtbm.
+       // libtbm initializes module init with this tbm_module which is casted with tbm_bufmgr.
+       tbm_module *module = (tbm_module *)bufmgr;
+       module->bufmgr_func = func;
 
        return TBM_ERROR_NONE;
 }
@@ -129,7 +137,10 @@ tbm_backend_bufmgr_register_bo_func(tbm_bufmgr bufmgr, tbm_backend_bo_func *func
        TBM_RETURN_VAL_IF_FAIL(bufmgr, TBM_ERROR_INVALID_PARAMETER);
        TBM_RETURN_VAL_IF_FAIL(func, TBM_ERROR_INVALID_PARAMETER);
 
-       bufmgr->bo_func = func;
+       // The tbm_bufmgr from backend module is actually tbm_module memory in libtbm.
+       // libtbm initializes module init with this tbm_module which is casted with tbm_bufmgr.
+       tbm_module *module = (tbm_module *)bufmgr;
+       module->bo_func = func;
 
        return TBM_ERROR_NONE;
 }