summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-10-14 16:58:05 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-10-14 19:46:47 +0900
commit86d1b190c2c013db3b8bad6644aa28c303fe2f2d (patch)
treeab6b815ced156a09a453e53adcde0635d21158d9
parenta1be855fe4a0c36628e1393090d78bfb3236df07 (diff)
Evas GL: Avoid make_current(0,0) during destroy
Show an error message and call make_current(NULL, NULL) only if the object (context, surface) being destroyed is current. Otherwise, avoid changing the current context & surface.
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_core.c83
1 files changed, 42 insertions, 41 deletions
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 1091ddb480..46eca424a7 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_core.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_core.c
@@ -984,7 +984,7 @@ _surface_cap_print(int error)
984 984
985 PRINT_LOG("----------------------------------------------------------------------------------------------------------------"); 985 PRINT_LOG("----------------------------------------------------------------------------------------------------------------");
986 PRINT_LOG(" Evas GL Supported Surface Format "); 986 PRINT_LOG(" Evas GL Supported Surface Format ");
987 PRINT_LOG("----------------------------------------------------------------------------------------------------------------\n"); 987 PRINT_LOG("----------------------------------------------------------------------------------------------------------------");
988 PRINT_LOG(" Max Surface Width: %d Height: %d", evgl_engine->caps.max_w, evgl_engine->caps.max_h); 988 PRINT_LOG(" Max Surface Width: %d Height: %d", evgl_engine->caps.max_w, evgl_engine->caps.max_h);
989 PRINT_LOG(" Multisample Support: %d", evgl_engine->caps.msaa_supported); 989 PRINT_LOG(" Multisample Support: %d", evgl_engine->caps.msaa_supported);
990 //if (evgl_engine->caps.msaa_supported) 990 //if (evgl_engine->caps.msaa_supported)
@@ -1973,8 +1973,6 @@ evgl_surface_destroy(void *eng_data, EVGL_Surface *sfc)
1973 EVGL_Resource *rsc; 1973 EVGL_Resource *rsc;
1974 Eina_Bool dbg; 1974 Eina_Bool dbg;
1975 1975
1976 // FIXME: This does some make_current(0,0) which may have side effects
1977
1978 // Check input parameter 1976 // Check input parameter
1979 if ((!evgl_engine) || (!sfc)) 1977 if ((!evgl_engine) || (!sfc))
1980 { 1978 {
@@ -1992,6 +1990,21 @@ evgl_surface_destroy(void *eng_data, EVGL_Surface *sfc)
1992 if ((dbg = evgl_engine->api_debug_mode)) 1990 if ((dbg = evgl_engine->api_debug_mode))
1993 DBG("Destroying surface sfc %p (eng %p)", sfc, eng_data); 1991 DBG("Destroying surface sfc %p (eng %p)", sfc, eng_data);
1994 1992
1993 if ((rsc->current_ctx) && (rsc->current_ctx->current_sfc == sfc) )
1994 {
1995 if (evgl_engine->api_debug_mode)
1996 {
1997 ERR("The context is still current before it's being destroyed. "
1998 "Calling make_current(NULL, NULL)");
1999 }
2000 else
2001 {
2002 WRN("The context is still current before it's being destroyed. "
2003 "Calling make_current(NULL, NULL)");
2004 }
2005 evgl_make_current(eng_data, NULL, NULL);
2006 }
2007
1995 // Make current to current context to destroy surface buffers 2008 // Make current to current context to destroy surface buffers
1996 if (!_internal_resource_make_current(eng_data, rsc->current_ctx)) 2009 if (!_internal_resource_make_current(eng_data, rsc->current_ctx))
1997 { 2010 {
@@ -2050,38 +2063,15 @@ evgl_surface_destroy(void *eng_data, EVGL_Surface *sfc)
2050 } 2063 }
2051 } 2064 }
2052 2065
2053 if ((rsc->current_ctx) && (rsc->current_ctx->current_sfc == sfc) )
2054 {
2055 if (evgl_engine->api_debug_mode)
2056 {
2057 ERR("The surface is still current before it's being destroyed.");
2058 ERR("Doing make_current(NULL, NULL)");
2059 }
2060 else
2061 {
2062 WRN("The surface is still current before it's being destroyed.");
2063 WRN("Doing make_current(NULL, NULL)");
2064 }
2065 evgl_make_current(eng_data, NULL, NULL);
2066 }
2067
2068 if (sfc->current_ctx && sfc->current_ctx->current_sfc == sfc) 2066 if (sfc->current_ctx && sfc->current_ctx->current_sfc == sfc)
2069 sfc->current_ctx->current_sfc = NULL; 2067 sfc->current_ctx->current_sfc = NULL;
2070 2068
2071 if (dbg) DBG("Calling make_current(NULL, NULL)");
2072 if (!evgl_engine->funcs->make_current(eng_data, NULL, NULL, 0))
2073 {
2074 ERR("Error doing make_current(NULL, NULL).");
2075 return 0;
2076 }
2077
2078 // Remove it from the list 2069 // Remove it from the list
2079 LKL(evgl_engine->resource_lock); 2070 LKL(evgl_engine->resource_lock);
2080 evgl_engine->surfaces = eina_list_remove(evgl_engine->surfaces, sfc); 2071 evgl_engine->surfaces = eina_list_remove(evgl_engine->surfaces, sfc);
2081 LKU(evgl_engine->resource_lock); 2072 LKU(evgl_engine->resource_lock);
2082 2073
2083 free(sfc); 2074 free(sfc);
2084 sfc = NULL;
2085 2075
2086 _surface_context_list_print(); 2076 _surface_context_list_print();
2087 2077
@@ -2170,6 +2160,7 @@ evgl_context_create(void *eng_data, EVGL_Context *share_ctx,
2170int 2160int
2171evgl_context_destroy(void *eng_data, EVGL_Context *ctx) 2161evgl_context_destroy(void *eng_data, EVGL_Context *ctx)
2172{ 2162{
2163 EVGL_Resource *rsc;
2173 Eina_Bool dbg; 2164 Eina_Bool dbg;
2174 2165
2175 // Check the input 2166 // Check the input
@@ -2178,18 +2169,37 @@ evgl_context_destroy(void *eng_data, EVGL_Context *ctx)
2178 ERR("Invalid input data. Engine: %p Context:%p", evgl_engine, ctx); 2169 ERR("Invalid input data. Engine: %p Context:%p", evgl_engine, ctx);
2179 return 0; 2170 return 0;
2180 } 2171 }
2181 dbg = evgl_engine->api_debug_mode;
2182 2172
2183 // FIXME: this calls make_current(0,0) which probably shouldn't be the case 2173 // Retrieve the resource object
2184 // if the context is not current (?) 2174 if (!(rsc = _evgl_tls_resource_get()))
2175 {
2176 ERR("Error retrieving resource from TLS");
2177 return 0;
2178 }
2185 2179
2186 if (dbg) DBG("Destroying context (eng = %p, ctx = %p)", eng_data, ctx); 2180 if ((dbg = evgl_engine->api_debug_mode))
2181 DBG("Destroying context (eng = %p, ctx = %p)", eng_data, ctx);
2182
2183 if ((rsc->current_ctx) && (rsc->current_ctx == ctx))
2184 {
2185 if (evgl_engine->api_debug_mode)
2186 {
2187 ERR("The context is still current before it's being destroyed. "
2188 "Calling make_current(NULL, NULL)");
2189 }
2190 else
2191 {
2192 WRN("The context is still current before it's being destroyed. "
2193 "Calling make_current(NULL, NULL)");
2194 }
2195 evgl_make_current(eng_data, NULL, NULL);
2196 }
2187 2197
2188 if (ctx->current_sfc && (ctx->current_sfc->current_ctx == ctx)) 2198 if (ctx->current_sfc && (ctx->current_sfc->current_ctx == ctx))
2189 ctx->current_sfc->current_ctx = NULL; 2199 ctx->current_sfc->current_ctx = NULL;
2190 2200
2191 // Set the context current with resource context/surface 2201 // Set the context current with resource context/surface
2192 if (!_internal_resource_make_current(eng_data, NULL)) 2202 if (!_internal_resource_make_current(eng_data, rsc->current_ctx))
2193 { 2203 {
2194 ERR("Error doing an internal resource make current"); 2204 ERR("Error doing an internal resource make current");
2195 return 0; 2205 return 0;
@@ -2199,14 +2209,6 @@ evgl_context_destroy(void *eng_data, EVGL_Context *ctx)
2199 if (ctx->surface_fbo) 2209 if (ctx->surface_fbo)
2200 glDeleteFramebuffers(1, &ctx->surface_fbo); 2210 glDeleteFramebuffers(1, &ctx->surface_fbo);
2201 2211
2202 // Unset the currrent context
2203 if (dbg) DBG("Calling make_current(NULL, NULL)");
2204 if (!evgl_engine->funcs->make_current(eng_data, NULL, NULL, 0))
2205 {
2206 ERR("Error doing make_current(NULL, NULL).");
2207 return 0;
2208 }
2209
2210 // Destroy indirect rendering context 2212 // Destroy indirect rendering context
2211 if (ctx->indirect_context && 2213 if (ctx->indirect_context &&
2212 !evgl_engine->funcs->context_destroy(eng_data, ctx->indirect_context)) 2214 !evgl_engine->funcs->context_destroy(eng_data, ctx->indirect_context))
@@ -2234,7 +2236,6 @@ evgl_context_destroy(void *eng_data, EVGL_Context *ctx)
2234 return 1; 2236 return 1;
2235} 2237}
2236 2238
2237
2238int 2239int
2239evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx) 2240evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
2240{ 2241{
@@ -2287,7 +2288,7 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
2287 if (dbg) DBG("Calling make_current(NULL, NULL)"); 2288 if (dbg) DBG("Calling make_current(NULL, NULL)");
2288 if (!evgl_engine->funcs->make_current(eng_data, NULL, NULL, 0)) 2289 if (!evgl_engine->funcs->make_current(eng_data, NULL, NULL, 0))
2289 { 2290 {
2290 ERR("Error doing make_current(NULL, NULL)."); 2291 ERR("Error calling make_current(NULL, NULL).");
2291 return 0; 2292 return 0;
2292 } 2293 }
2293 2294