From 995e0a6613c2c1a8ecf5464aea603f8b601a0863 Mon Sep 17 00:00:00 2001 From: Sung Park Date: Wed, 21 Nov 2012 04:59:52 +0000 Subject: [PATCH] Fixed Evas GL direct rendering bug from refactoring. The conditions weren't set properly where if a program uses evas_gl to do GL rendering in direct rendering mode and then use a pixmap to do native GL rendering in the same program, native pixmap rendering would also fall into the direct rendering path and not render anything for image object. It's been fixed. SVN revision: 79493 --- .../evas/engines/gl_common/evas_gl_api.c | 12 ++-- .../evas/engines/gl_common/evas_gl_core.c | 70 ++++++++++--------- .../evas/engines/gl_common/evas_gl_core.h | 2 +- .../engines/gl_common/evas_gl_core_private.h | 3 +- src/modules/evas/engines/gl_x11/evas_engine.c | 4 +- 5 files changed, 50 insertions(+), 41 deletions(-) diff --git a/src/modules/evas/engines/gl_common/evas_gl_api.c b/src/modules/evas/engines/gl_common/evas_gl_api.c index d5b952af72..02e8297fb1 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_api.c +++ b/src/modules/evas/engines/gl_common/evas_gl_api.c @@ -68,7 +68,7 @@ _evgl_glBindFramebuffer(GLenum target, GLuint framebuffer) // Take care of BindFramebuffer 0 issue if (framebuffer==0) { - if (evgl_direct_enabled(evgl_engine)) + if (_evgl_direct_enabled(evgl_engine)) glBindFramebuffer(target, 0); else glBindFramebuffer(target, ctx->surface_fbo); @@ -270,7 +270,7 @@ _evgl_glClear(GLbitfield mask) return; } - if (evgl_direct_enabled(evgl_engine)) + if (_evgl_direct_enabled(evgl_engine)) { if (!(rsc->current_ctx->current_fbo)) { @@ -351,7 +351,7 @@ _evgl_glGetIntegerv(GLenum pname, GLint* params) EVGL_Context *ctx; Evas_Object_Protected_Data *img; - if (evgl_direct_enabled(evgl_engine)) + if (_evgl_direct_enabled(evgl_engine)) { if (!params) { @@ -423,7 +423,7 @@ _evgl_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum forma return; } - if (evgl_direct_enabled(evgl_engine)) + if (_evgl_direct_enabled(evgl_engine)) { if (!(rsc->current_ctx->current_fbo)) @@ -468,7 +468,7 @@ _evgl_glScissor(GLint x, GLint y, GLsizei width, GLsizei height) return; } - if (evgl_direct_enabled(evgl_engine)) + if (_evgl_direct_enabled(evgl_engine)) { if (!(rsc->current_ctx->current_fbo)) { @@ -548,7 +548,7 @@ _evgl_glViewport(GLint x, GLint y, GLsizei width, GLsizei height) return; } - if (evgl_direct_enabled(evgl_engine)) + if (_evgl_direct_enabled(evgl_engine)) { if (!(rsc->current_ctx->current_fbo)) { 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 212e54ad39..53289e6d06 100755 --- a/src/modules/evas/engines/gl_common/evas_gl_core.c +++ b/src/modules/evas/engines/gl_common/evas_gl_core.c @@ -950,12 +950,8 @@ _internal_config_set(EVGL_Engine *ee, EVGL_Surface *sfc, Evas_GL_Config *cfg) } static int -_evgl_direct_renderable(EVGL_Engine *ee, EVGL_Context *ctx, EVGL_Surface *sfc) +_evgl_direct_renderable(EVGL_Engine *ee, EVGL_Resource *rsc, EVGL_Context *ctx, EVGL_Surface *sfc) { - EVGL_Resource *rsc; - - if (!(rsc=_evgl_tls_resource_get(ee))) return 0; - if (ee->force_direct_off) return 0; if (rsc->id != ee->main_tid) return 0; if (!ctx) return 0; @@ -966,7 +962,7 @@ _evgl_direct_renderable(EVGL_Engine *ee, EVGL_Context *ctx, EVGL_Surface *sfc) } //---------------------------------------------------------------// -// Retrieve the internal resource object from TLS +// Functions used by Evas GL module //---------------------------------------------------------------// EVGL_Resource * _evgl_tls_resource_get(EVGL_Engine *ee) @@ -1009,6 +1005,37 @@ _evgl_current_context_get() return rsc->current_ctx; } +int +_evgl_not_in_pixel_get(EVGL_Engine *ee) +{ + EVGL_Resource *rsc; + + if (!(rsc=_evgl_tls_resource_get(ee))) return 1; + + EVGL_Context *ctx = rsc->current_ctx; + + if ((!ee->force_direct_off) && (rsc->id == ee->main_tid) && + (ctx) && (ctx->current_sfc) && (ctx->current_sfc->direct_fb_opt) && + (!rsc->direct_img_obj)) + return 1; + else + return 0; +} + +int +_evgl_direct_enabled(EVGL_Engine *ee) +{ + EVGL_Resource *rsc; + EVGL_Context *ctx; + EVGL_Surface *sfc; + + if (!(rsc=_evgl_tls_resource_get(ee))) return 0; + if (!(ctx=rsc->current_ctx)) return 0; + if (!(sfc=rsc->current_ctx->current_sfc)) return 0; + + return _evgl_direct_renderable(ee, rsc, ctx, sfc); +} + //---------------------------------------------------------------// // Exported functions for evas_engine to use @@ -1153,9 +1180,6 @@ int evgl_engine_destroy(EVGL_Engine *ee) return 1; } -//-----------------------------------------------------// -// Exported functions for evas_engine to use -// - We just need to implement these functions and have evas_engine load them :) void * evgl_surface_create(EVGL_Engine *ee, Evas_GL_Config *cfg, int w, int h) { @@ -1426,7 +1450,7 @@ evgl_make_current(EVGL_Engine *ee, EVGL_Surface *sfc, EVGL_Context *ctx) glGenFramebuffers(1, &ctx->surface_fbo); // Direct Rendering - if (_evgl_direct_renderable(ee, ctx, sfc)) + if (_evgl_direct_renderable(ee, rsc, ctx, sfc)) { // This is to transition from FBO rendering to direct rendering glGetIntegerv(GL_FRAMEBUFFER_BINDING, &curr_fbo); @@ -1435,7 +1459,7 @@ evgl_make_current(EVGL_Engine *ee, EVGL_Surface *sfc, EVGL_Context *ctx) glBindFramebuffer(GL_FRAMEBUFFER, 0); ctx->current_fbo = 0; } - rsc->direct_enabled = 1; + rsc->direct_rendered = 1; } else { @@ -1452,8 +1476,7 @@ evgl_make_current(EVGL_Engine *ee, EVGL_Surface *sfc, EVGL_Context *ctx) if (ctx->current_fbo) glBindFramebuffer(GL_FRAMEBUFFER, ctx->current_fbo); } - - rsc->direct_enabled = 0; + rsc->direct_rendered = 0; } ctx->current_sfc = sfc; @@ -1507,30 +1530,13 @@ evgl_native_surface_get(EVGL_Engine *ee, EVGL_Surface *sfc, Evas_Native_Surface } int -_evgl_not_in_pixel_get(EVGL_Engine *ee) -{ - EVGL_Resource *rsc; - - if (!(rsc=_evgl_tls_resource_get(ee))) return 1; - - EVGL_Context *ctx = rsc->current_ctx; - - if ((!ee->force_direct_off) && (rsc->id == ee->main_tid) && - (ctx) && (ctx->current_sfc) && (ctx->current_sfc->direct_fb_opt) && - (!rsc->direct_img_obj)) - return 1; - else - return 0; -} - -int -evgl_direct_enabled(EVGL_Engine *ee) +evgl_direct_rendered(EVGL_Engine *ee) { EVGL_Resource *rsc; if (!(rsc=_evgl_tls_resource_get(ee))) return 0; - return rsc->direct_enabled; + return rsc->direct_rendered; } void 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 c18f6fc9dc..369b3c3237 100755 --- a/src/modules/evas/engines/gl_common/evas_gl_core.h +++ b/src/modules/evas/engines/gl_common/evas_gl_core.h @@ -31,7 +31,7 @@ extern void *evgl_proc_address_get(const char *name); extern int evgl_native_surface_get(EVGL_Engine *ee, EVGL_Surface *sfc, Evas_Native_Surface *ns); extern Evas_GL_API *evgl_api_get(EVGL_Engine *ee); -extern int evgl_direct_enabled(EVGL_Engine *ee); +extern int evgl_direct_rendered(EVGL_Engine *ee); extern void evgl_direct_img_obj_set(EVGL_Engine *ee, Evas_Object *img); extern Evas_Object *evgl_direct_img_obj_get(EVGL_Engine *ee); 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 be114b497d..491bd75349 100755 --- a/src/modules/evas/engines/gl_common/evas_gl_core_private.h +++ b/src/modules/evas/engines/gl_common/evas_gl_core_private.h @@ -200,7 +200,7 @@ struct _EVGL_Resource EVGL_Context *current_ctx; - int direct_enabled; + int direct_rendered; Evas_Object *direct_img_obj; }; @@ -249,5 +249,6 @@ extern void _evgl_api_get(Evas_GL_API *api, int debug); extern EVGL_Resource *_evgl_tls_resource_get(EVGL_Engine *ee); extern EVGL_Context *_evgl_current_context_get(); extern int _evgl_not_in_pixel_get(); +extern int _evgl_direct_enabled(EVGL_Engine *ee); #endif //_EVAS_GL_CORE_PRIVATE_H diff --git a/src/modules/evas/engines/gl_x11/evas_engine.c b/src/modules/evas/engines/gl_x11/evas_engine.c index 3aca2d78af..aa8dcc8542 100644 --- a/src/modules/evas/engines/gl_x11/evas_engine.c +++ b/src/modules/evas/engines/gl_x11/evas_engine.c @@ -2491,10 +2491,12 @@ eng_image_draw(void *data, void *context, void *surface, void *image, int src_x, Render_Engine *re; re = (Render_Engine *)data; Evas_GL_Image *im = image; + Native *n; if (!im) return; + n = im->native.data; - if ((im->native.data) && evgl_direct_enabled(re->evgl_engine)) + if ((n) && (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL) && (evgl_direct_rendered(re->evgl_engine))) { DBG("Rendering Directly to the window"); evas_object_image_pixels_dirty_set(evgl_direct_img_obj_get(re->evgl_engine), EINA_TRUE);