Fix evas_gl's internal resource surface bug. For optimzation evas_gl

was using evas' window surface to do its resource creation and it 
wans't properly updated when a window is destroyed and recreated.

Also, deleted some whitespaces. 


SVN revision: 74771
This commit is contained in:
Sung Park 2012-08-02 01:15:38 +00:00
parent e40c9a05c8
commit d0b5d1e13e
3 changed files with 90 additions and 58 deletions

View File

@ -943,3 +943,9 @@
* Provide share (Data) file for prefix finding and use * Provide share (Data) file for prefix finding and use
eina_prefix for modules too so we work with debian multiarch eina_prefix for modules too so we work with debian multiarch
2012-08-02 Sung W. Park (sung_)
* Fix evas_gl's internal resource surface bug. For optimzation evas_gl
was using evas' window surface to do its resource creation and it
wans't properly updated when a window is destroyed and recreated.

View File

@ -26,6 +26,7 @@ Fixes:
* Don't crash when calling evas_object_smart_type_check without type. * Don't crash when calling evas_object_smart_type_check without type.
* Handle proxy with the right context. * Handle proxy with the right context.
* Force proxied object to stay active to keep track of change in them. * Force proxied object to stay active to keep track of change in them.
* Fix evas_gl's internal resource surface bug when evas' window is deleted/recreated.
Removal: Removal:
* Remove EVAS_FRAME_QUEUING, EVAS_SLI, METRIC_CACHE and WORD_CACHE. * Remove EVAS_FRAME_QUEUING, EVAS_SLI, METRIC_CACHE and WORD_CACHE.

View File

@ -621,14 +621,14 @@ _gl_ext_init(Render_Engine *re)
glexts = (const char*)glGetString(GL_EXTENSIONS); glexts = (const char*)glGetString(GL_EXTENSIONS);
ext_len = strlen(glexts); ext_len = strlen(glexts);
if (!ext_len) if (!ext_len)
{ {
DBG("GL Get Extension string NULL: No extensions supported"); DBG("GL Get Extension string NULL: No extensions supported");
return; return;
} }
_gl_ext_string = calloc(1, sizeof(char) * ext_len * 2); _gl_ext_string = calloc(1, sizeof(char) * ext_len * 2);
if (!_gl_ext_string) if (!_gl_ext_string)
{ {
ERR("Error allocating _gl_ext_string."); ERR("Error allocating _gl_ext_string.");
return; return;
@ -662,14 +662,14 @@ _gl_ext_init(Render_Engine *re)
#endif #endif
ext_len = strlen(evasglexts); ext_len = strlen(evasglexts);
if (!ext_len) if (!ext_len)
{ {
DBG("GL Get Extension string NULL: No extensions supported"); DBG("GL Get Extension string NULL: No extensions supported");
return; return;
} }
_evasgl_ext_string = calloc(1, sizeof(char) * ext_len * 2); _evasgl_ext_string = calloc(1, sizeof(char) * ext_len * 2);
if (!_evasgl_ext_string) if (!_evasgl_ext_string)
{ {
ERR("Error allocating _evasgl_ext_string."); ERR("Error allocating _evasgl_ext_string.");
return; return;
@ -889,6 +889,15 @@ _destroy_internal_glue_resources(void *data)
Render_Engine_GL_Resource *rsc; Render_Engine_GL_Resource *rsc;
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX) #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
// Create internal resource context if it hasn't been created already
if ((rsc = eina_tls_get(resource_key)) == NULL)
{
ERR("Error retrieving the TLS resources.");
return 0;
}
if (eina_main_loop_is()) rsc->surface = re->win->egl_surface[0];
// EGL // EGL
// Delete the Resources // Delete the Resources
LKL(resource_lock); LKL(resource_lock);
@ -900,7 +909,7 @@ _destroy_internal_glue_resources(void *data)
eglDestroyContext(re->win->egl_disp, rsc->context); eglDestroyContext(re->win->egl_disp, rsc->context);
free(rsc); free(rsc);
} }
#else #else
// GLX // GLX
// Delete the Resources // Delete the Resources
LKL(resource_lock); LKL(resource_lock);
@ -937,6 +946,45 @@ _destroy_internal_glue_resources(void *data)
} }
static int
_internal_resources_make_current(void *data)
{
Render_Engine *re = (Render_Engine *)data;
Render_Engine_GL_Resource *rsc;
int ret = 0;
// Create internal resource context if it hasn't been created already
if ((rsc = eina_tls_get(resource_key)) == NULL)
{
if ((rsc = _create_internal_glue_resources(re)) == NULL)
{
ERR("Error creating internal resources.");
return 0;
}
}
// Use resource surface/context to create surface resrouces
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
// Update the evas' window surface
if (eina_main_loop_is()) rsc->surface = re->win->egl_surface[0];
ret = eglMakeCurrent(re->win->egl_disp, rsc->surface, rsc->surface, rsc->context);
if (!ret)
{
ERR("eglMakeCurrent() failed. Error Code: %#x", eglGetError());
return 0;
}
#else
ret = glXMakeCurrent(re->info->info.display, re->win->win, rsc->context);
if (!ret)
{
ERR("glXMakeCurrent()!");
return 0;
}
#endif
return 1;
}
static int static int
eng_setup(Evas *e, void *in) eng_setup(Evas *e, void *in)
@ -3023,7 +3071,7 @@ _print_gl_surface_info(Render_Engine_GL_Surface *sfc, int error)
else \ else \
DBG(__VA_ARGS__); DBG(__VA_ARGS__);
PRINT_LOG("----------Surface Info------------"); PRINT_LOG("----------Surface Info------------");
PRINT_LOG(" [Surface] %x", (unsigned int)sfc); PRINT_LOG(" [Surface] %x", (unsigned int)sfc);
PRINT_LOG(" Width: %d", sfc->w); PRINT_LOG(" Width: %d", sfc->w);
PRINT_LOG(" Height: %d", sfc->h); PRINT_LOG(" Height: %d", sfc->h);
@ -3045,7 +3093,7 @@ _print_gl_surface_info(Render_Engine_GL_Surface *sfc, int error)
PRINT_LOG(" RenderBuffer Stencil Format : %x", sfc->rb_stencil_fmt); PRINT_LOG(" RenderBuffer Stencil Format : %x", sfc->rb_stencil_fmt);
PRINT_LOG(" RenderBuffer Depth Stencil : %x", sfc->rb_depth_stencil); PRINT_LOG(" RenderBuffer Depth Stencil : %x", sfc->rb_depth_stencil);
PRINT_LOG(" RenderBuffer Depth Stencil Format: %x", sfc->rb_depth_stencil_fmt); PRINT_LOG(" RenderBuffer Depth Stencil Format: %x", sfc->rb_depth_stencil_fmt);
PRINT_LOG("--------------------------------------"); PRINT_LOG("--------------------------------------");
#undef PRINT_LOG #undef PRINT_LOG
} }
@ -3368,9 +3416,9 @@ _attach_fbo_surface(Render_Engine *data __UNUSED__,
// Attach texture to FBO // Attach texture to FBO
if (sfc->rt_msaa_samples) if (sfc->rt_msaa_samples)
glsym_glFramebufferTexture2DMultisample(GL_FRAMEBUFFER, glsym_glFramebufferTexture2DMultisample(GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, sfc->rt_tex, GL_TEXTURE_2D, sfc->rt_tex,
0, sfc->rt_msaa_samples); 0, sfc->rt_msaa_samples);
else else
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
@ -3391,17 +3439,17 @@ _attach_fbo_surface(Render_Engine *data __UNUSED__,
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL_OES, sfc->w, sfc->h, glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL_OES, sfc->w, sfc->h,
0, GL_DEPTH_STENCIL_OES, GL_UNSIGNED_INT_24_8_OES, NULL); 0, GL_DEPTH_STENCIL_OES, GL_UNSIGNED_INT_24_8_OES, NULL);
if (sfc->rt_msaa_samples) if (sfc->rt_msaa_samples)
{ {
glsym_glFramebufferTexture2DMultisample(GL_FRAMEBUFFER, glsym_glFramebufferTexture2DMultisample(GL_FRAMEBUFFER,
GL_DEPTH_ATTACHMENT, GL_DEPTH_ATTACHMENT,
GL_TEXTURE_2D, GL_TEXTURE_2D,
sfc->rb_depth_stencil, sfc->rb_depth_stencil,
0, sfc->rt_msaa_samples); 0, sfc->rt_msaa_samples);
glsym_glFramebufferTexture2DMultisample(GL_FRAMEBUFFER, glsym_glFramebufferTexture2DMultisample(GL_FRAMEBUFFER,
GL_STENCIL_ATTACHMENT, GL_STENCIL_ATTACHMENT,
GL_TEXTURE_2D, GL_TEXTURE_2D,
sfc->rb_depth_stencil, sfc->rb_depth_stencil,
0, sfc->rt_msaa_samples); 0, sfc->rt_msaa_samples);
} }
else else
@ -3535,7 +3583,7 @@ _create_rt_buffers(Render_Engine *data __UNUSED__,
ERR("_attach_fbo_surface() failed."); ERR("_attach_fbo_surface() failed.");
return 0; return 0;
} }
else else
return 1; return 1;
} }
@ -3582,25 +3630,10 @@ eng_gl_surface_create(void *data, void *config, int w, int h)
#endif #endif
} }
// Create internal resource context if it hasn't been created already // Use resource surface/context to do a make current
if ((rsc = eina_tls_get(resource_key)) == NULL) if (!_internal_resources_make_current(re))
{ {
if ((rsc = _create_internal_glue_resources(re)) == NULL) ERR("Error doing a make current with the internal resources.");
{
ERR("Error creating internal resources.");
goto finish;
}
}
// Use resource surface/context to create surface resrouces
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
res = eglMakeCurrent(re->win->egl_disp, rsc->surface, rsc->surface, rsc->context);
#else
res = glXMakeCurrent(re->info->info.display, re->win->win, rsc->context);
#endif
if (!res)
{
ERR("xxxMakeCurrent() finish!");
goto finish; goto finish;
} }
@ -3662,16 +3695,10 @@ eng_gl_surface_destroy(void *data, void *surface)
if (!sfc) return 0; if (!sfc) return 0;
if ((rsc = eina_tls_get(resource_key)) == EINA_FALSE) return 0; // Use resource surface/context to create surface resrouces
if (!_internal_resources_make_current(re))
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
ret = eglMakeCurrent(re->win->egl_disp, rsc->surface, rsc->surface, rsc->context);
#else
ret = glXMakeCurrent(re->info->info.display, re->win->win, rsc->context);
#endif
if (!ret)
{ {
ERR("xxxMakeCurrent() failed!"); ERR("Error doing a make current with the internal resources.");
return 0; return 0;
} }
@ -3813,19 +3840,10 @@ eng_gl_context_destroy(void *data, void *context)
if (!ctx) return 0; if (!ctx) return 0;
if ((rsc = eina_tls_get(resource_key)) == EINA_FALSE) return 0; // Use resource surface/context to create surface resrouces
if (!_internal_resources_make_current(re))
// Do a make current with the given context
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
ret = eglMakeCurrent(re->win->egl_disp, rsc->surface,
rsc->surface, ctx->context);
#else
ret = glXMakeCurrent(re->info->info.display, re->win->win,
ctx->context);
#endif
if (!ret)
{ {
ERR("xxxMakeCurrent() failed!"); ERR("Error doing a make current with the internal resources.");
return 0; return 0;
} }
@ -3904,7 +3922,14 @@ eng_gl_make_current(void *data __UNUSED__, void *surface, void *context)
// rendering outside of pixel getter but it doesn't guarantee // rendering outside of pixel getter but it doesn't guarantee
// correct rendering. // correct rendering.
if ((sfc->direct_fb_opt) && (gl_direct_img_obj || gl_direct_override)) if ((sfc->direct_fb_opt) && (gl_direct_img_obj || gl_direct_override))
gl_direct_enabled = 1; {
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
sfc->direct_sfc = re->win->egl_surface[0];
#else
sfc->direct_sfc = re->win->win;
#endif
gl_direct_enabled = 1;
}
else else
gl_direct_enabled = 0; gl_direct_enabled = 0;