Hi all,
I'm attaching a patch that addresses the awkward usage case. It's something
that didn't bother me initially but the more I look at it, i think
it's a little off. :-)
The initial version of the evas_gl that I've submitted had the
following use case.
evasgl = evas_gl_new(e);
sfc = evas_gl_surface_create(...);
ctx = evas_gl_context_create(...);
// Make current triggers surface texture and FBO to be created
evas_gl_make_current(evasgl, sfc, ctx);
// Then you can do a surface_get to retrieve the proper texture and set it
evas_gl_native_surface_get(evasgl, sfc, &ns);
evas_object_image_native_surface_set(img_obj, &ns);
The unnatural thing about this use case is that you have to call the
make_current
one time in order for evas_gl to generate a surface texture. This is because
you need a context to create a texture. Unfortunately, this makes the usage
case really awkward.
So, instead, I've decided to get rid of the need for calling the make_current
by generating a surface texture when evas_gl_surface_create() is called
by using the evas' gl context. This works because the newly created context
shares resources with evas. in fact, this is what i'm currently doing
with surface
deletion anyway so I thought this solution was reasonable.
Here's how it looks after you get rid of the make_current:
evasgl = evas_gl_new(e);
sfc = evas_gl_surface_create(...);
ctx = evas_gl_context_create(...);
evas_gl_native_surface_get(evasgl, sfc, &ns);
evas_object_image_native_surface_set(img_obj, &ns);
The patch is pretty small and straightforward.
Let me know what you guys think.
cheers,
Sung
Index: src/modules/engines/gl_x11/evas_engine.c
===================================================================
--- src/modules/engines/gl_x11/evas_engine.c (revision 58768)
+++ src/modules/engines/gl_x11/evas_engine.c (working copy)
@@ -2229,6 +2229,7 @@
Render_Engine *re;
Render_Engine_GL_Surface *sfc;
Evas_GL_Config *cfg;
+ int ret;
sfc = calloc(1, sizeof(Render_Engine_GL_Surface));
@@ -2254,6 +2255,49 @@
return NULL;
}
+ // Create Render Target Texture/Buffers if not initialized
+ if (!sfc->initialized)
+ {
+ // I'm using evas's original context to create the render target texture
+ // This is to prevent awkwardness in using native_surface_get() function
+ // If the rt texture creation is deferred till the context is created and
+ // make_current called, the user can't call native_surface_get() right
+ // after the surface is created. hence this is done here using evas' context.
+#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
+ ret = eglMakeCurrent(re->win->egl_disp, re->win->egl_surface[0], re->win->egl_surface[0], re->win->egl_context[0]);
+#else
+ ret = glXMakeCurrent(re->info->info.display, re->win->win, re->win->context);
+#endif
+ if (!ret)
+ {
+ ERR("xxxMakeCurrent() failed!");
+ free(sfc);
+ return NULL;
+ }
+
+ // Create Render texture
+ if (!_create_rt_buffers(re, sfc))
+ {
+ ERR("_create_rt_buffers() failed.");
+ free(sfc);
+ return NULL;
+ }
+
+#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
+ ret = eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE,
+ EGL_NO_SURFACE, EGL_NO_CONTEXT);
+#else
+ ret = glXMakeCurrent(re->info->info.display, None, NULL);
+#endif
+ if (!ret)
+ {
+ ERR("xxxMakeCurrent() failed!");
+ free(sfc);
+ return 0;
+ }
+ sfc->initialized = 1;
+ }
+
return sfc;
}
@@ -2487,17 +2531,6 @@
return 0;
}
- // Create Render Target Texture/Buffers if not initialized
- if (!sfc->initialized)
- {
- if (!_create_rt_buffers(re, sfc))
- {
- ERR("_create_rt_buffers() failed.");
- return 0;
- }
- sfc->initialized = 1;
- }
-
// Create FBO if not initalized already
if (!ctx->initialized)
{
------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve
application availability and disaster protection. Learn more about boosting
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel