From 64aa5a2670dd60851939a240beaa0fa9207f416f Mon Sep 17 00:00:00 2001 From: "Sung W. Park" Date: Mon, 4 Mar 2013 20:23:49 +0900 Subject: [PATCH] evas: evas_gl - Got rid of resource pool in favor of creation on demand. Resource contexts/surfaces are used for creating resources within Evas_GL. In oder to handle Evas_GL runnig from different thread than the main one, a resource context/surface pool was used. This turned out to be unnecssary as they are not used very frequently. So, I got rid of the pool and made the resources create as needed. --- ChangeLog | 11 +- .../evas/engines/gl_common/evas_gl_core.c | 143 +++--------------- .../evas/engines/gl_common/evas_gl_core.h | 4 +- .../engines/gl_common/evas_gl_core_private.h | 10 +- 4 files changed, 36 insertions(+), 132 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3f2e2b5a0a..42a6cd7b9e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2013-03-04 Sung W. Park (sung_) + + * Evas Evas_GL: removed resource surface/context pool in favor of + creating on-demand. resource surface/contexts are used for creating + GL resources for Evas_GL. + + 2013-02-28 Tom Hacohen (TAsn) * Evas textblock: Added proper size adjustments for @@ -5,8 +12,8 @@ 2013-02-28 Mike Blumenkrantz - * fix custom states for edje SPACER parts - * fix edje program filters + * fix custom states for edje SPACER parts + * fix edje program filters 2013-02-28 Cedric Bail diff --git a/src/modules/evas/engines/gl_common/evas_gl_core.c b/src/modules/evas/engines/gl_common/evas_gl_core.c index 125a9be827..9b3a4bcf42 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_core.c +++ b/src/modules/evas/engines/gl_common/evas_gl_core.c @@ -22,105 +22,6 @@ static void _surface_context_list_print(EVGL_Engine *ee); // Internal Resources: // - Surface and Context used for internal buffer creation //---------------------------------------------------------------// -static int -_native_surface_pool_create(EVGL_Engine *ee) -{ - int i = 0; - int pool_num = 0; - char *s = NULL; - void *sfc = NULL, *win = NULL; - - // Check if engine is valid - if (!ee) - { - ERR("EVGL Engine not initialized!"); - return 0; - } - - // Check for evn var. Otherwise default max is 8 - s = getenv("EVAS_GL_CONTEXT_POOL_COUNT"); - if (s) pool_num = atoi(s); - if (pool_num <= 0) pool_num = 8; - ee->pool_num = pool_num; - - // Allocate surface pool - ee->surface_pool = calloc(1, sizeof(Native_Surface)*pool_num); - - if (!ee->surface_pool) - { - ERR("Error allocating native surface pool."); - goto error; - } - - for (i = 0; i < pool_num; ++i) - { - sfc = win = NULL; - - win = ee->funcs->native_window_create(ee->engine_data); - if (!win) - { - ERR("Error creating native window"); - goto error; - } - - sfc = ee->funcs->surface_create(ee->engine_data, win); - if (!sfc) - { - ERR("Error creating native surface"); - goto error; - } - - ee->surface_pool[i].window = win; - ee->surface_pool[i].surface = sfc; - } - - return 1; - -error: - for (i = 0; i < ee->pool_num; ++i) - { - win = ee->surface_pool[i].window; - sfc = ee->surface_pool[i].surface; - - if (win) - ee->funcs->native_window_destroy(ee->engine_data, win); - if (sfc) - ee->funcs->surface_destroy(ee->engine_data, sfc); - } - if (!ee->surface_pool) free(ee->surface_pool); - - return 0; -} - -static int -_native_surface_pool_destroy(EVGL_Engine *ee) -{ - int i = 0; - void *sfc = NULL, *win = NULL; - - // Check if engine is valid - if (!ee) - { - ERR("EVGL Engine not initialized!"); - return 0; - } - - for (i = 0; i < ee->pool_num; ++i) - { - win = ee->surface_pool[i].window; - sfc = ee->surface_pool[i].surface; - - if (win) - ee->funcs->native_window_destroy(ee->engine_data, win); - if (sfc) - ee->funcs->surface_destroy(ee->engine_data, sfc); - } - - if (!ee->surface_pool) free(ee->surface_pool); - - return 1; -} - static void * _internal_resources_create(EVGL_Engine *ee) { @@ -152,16 +53,21 @@ _internal_resources_create(EVGL_Engine *ee) if (rsc->id == ee->main_tid) rsc->surface = ee->funcs->evas_surface_get(ee->engine_data); else - if (rsc->id <= ee->pool_num) - { - rsc->surface = ee->surface_pool[rsc->id-1].surface; - ERR("Surface Pool[%d]: %p", (rsc->id-1), rsc->surface); - } - else - { - ERR("Too many threads using EvasGL."); - goto error; - } + { + rsc->window = ee->funcs->native_window_create(ee->engine_data); + if (!rsc->window) + { + ERR("Error creating native window"); + goto error; + } + + rsc->surface = ee->funcs->surface_create(ee->engine_data, rsc->window); + if (!rsc->surface) + { + ERR("Error creating native surface"); + goto error; + } + } if (!rsc->surface) { @@ -192,6 +98,9 @@ error: if (rsc->surface) if (rsc->id != ee->main_tid) // 0 is the main thread ee->funcs->surface_destroy(ee->engine_data, rsc->surface); + if (rsc->window) + if (rsc->id != ee->main_tid) // 0 is the main thread + ee->funcs->native_window_destroy(ee->engine_data, rsc->window); if (rsc) free(rsc); @@ -218,6 +127,12 @@ _internal_resources_destroy(EVGL_Engine *ee) // Only delete contexts here. if (rsc->context) ee->funcs->context_destroy(ee->engine_data, rsc->context); + if (rsc->window) + if (rsc->id != ee->main_tid) // 0 is the main thread + ee->funcs->native_window_destroy(ee->engine_data, rsc->window); + if (rsc->surface) + if (rsc->id != ee->main_tid) // 0 is the main thread + ee->funcs->surface_destroy(ee->engine_data, rsc->surface); free(rsc); } eina_list_free(ee->resource_list); @@ -1368,13 +1283,6 @@ evgl_engine_create(EVGL_Interface *efunc, void *engine_data) evgl_engine->funcs = efunc; evgl_engine->engine_data = engine_data; - // Create a surface pool - if (!_native_surface_pool_create(evgl_engine)) - { - ERR("Error createing native surface pool"); - goto error; - } - // Initialize Resource TLS if (eina_tls_new(&evgl_engine->resource_key) == EINA_FALSE) { @@ -1455,9 +1363,6 @@ int evgl_engine_destroy(EVGL_Engine *ee) // Destroy internal resources _internal_resources_destroy(ee); - // Destroy surface pool - _native_surface_pool_destroy(ee); - // Destroy TLS if (ee->resource_key) eina_tls_free(ee->resource_key); diff --git a/src/modules/evas/engines/gl_common/evas_gl_core.h b/src/modules/evas/engines/gl_common/evas_gl_core.h index 369b3c3237..9979e91cd0 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_core.h +++ b/src/modules/evas/engines/gl_common/evas_gl_core.h @@ -4,18 +4,18 @@ #include "Evas_GL.h" typedef void *EVGLNative_Display; +typedef void *EVGLNative_Window; typedef void *EVGLNative_Surface; typedef void *EVGLNative_Context; typedef struct _EVGL_Engine EVGL_Engine; typedef struct _EVGL_Interface EVGL_Interface; typedef struct _EVGL_Surface EVGL_Surface; -typedef struct _EVGL_Native_Surface EVGL_Native_Surface; +typedef struct _EVGL_Native_Window EVGL_Native_Window; typedef struct _EVGL_Context EVGL_Context; typedef struct _EVGL_Resource EVGL_Resource; typedef struct _EVGL_Cap EVGL_Cap; typedef struct _EVGL_Surface_Cap EVGL_Surface_Cap; typedef struct _EVGL_Surface_Format EVGL_Surface_Format; -typedef struct _Native_Surface Native_Surface; extern EVGL_Engine *evgl_engine_create(EVGL_Interface *efunc, void *engine_data); diff --git a/src/modules/evas/engines/gl_common/evas_gl_core_private.h b/src/modules/evas/engines/gl_common/evas_gl_core_private.h index 62c1da47e5..1bf746e427 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_core_private.h +++ b/src/modules/evas/engines/gl_common/evas_gl_core_private.h @@ -204,6 +204,7 @@ struct _EVGL_Resource EVGLNative_Display display; EVGLNative_Context context; + EVGLNative_Window window; EVGLNative_Surface surface; EVGL_Context *current_ctx; @@ -212,12 +213,6 @@ struct _EVGL_Resource Evas_Object *direct_img_obj; }; -struct _Native_Surface -{ - void *surface; - void *window; -}; - struct _EVGL_Engine { int initted; @@ -235,9 +230,6 @@ struct _EVGL_Engine Eina_List *resource_list; int resource_count; int main_tid; - int pool_num; - Native_Surface *surface_pool; - int direct_override; int direct_mem_opt;