Hi all,
As I was testing evas_gl, I've ran into a bug when I'm using the
evas_object_map_*
functions.
I don't necessarily want to say it's a bug because it did say
// FIXME: handle yinvert
ERR("not handling inverted y case for map");
So i'm submitting a patch that handles the yinvert case.
Index: src/modules/engines/gl_common/evas_gl_context.c
===================================================================
--- src/modules/engines/gl_common/evas_gl_context.c (revision 59024)
+++ src/modules/engines/gl_common/evas_gl_context.c (working copy)
@@ -2688,8 +2688,12 @@
if ((tex->im) && (tex->im->native.data) && (!tex->im->native.yinvert))
{
- // FIXME: handle yinvert
- ERR("not handling inverted y case for map");
+ for (i = 0; i < 4; i++)
+ {
+ ty[i] = 1.0 - ty[i];
+ if (yuv)
+ t2y[i] = 1.0 - t2y[i];
+ }
}
cmul = ARGB_JOIN(a, r, g, b);
I'm also submitting an example program that you can run to see before and
after.
let me know if this seems reasonable.
cheers,
Sung
Index: src/modules/engines/gl_common/evas_gl_context.c
===================================================================
--- src/modules/engines/gl_common/evas_gl_context.c (revision 59024)
+++ src/modules/engines/gl_common/evas_gl_context.c (working copy)
@@ -2688,8 +2688,12 @@
if ((tex->im) && (tex->im->native.data) && (!tex->im->native.yinvert))
{
- // FIXME: handle yinvert
- ERR("not handling inverted y case for map");
+ for (i = 0; i < 4; i++)
+ {
+ ty[i] = 1.0 - ty[i];
+ if (yuv)
+ t2y[i] = 1.0 - t2y[i];
+ }
}
cmul = ARGB_JOIN(a, r, g, b);
/**
* Simple Evas_GL example
*/
#include <Ecore_Evas.h>
#include <Ecore.h>
#include <Evas_GL.h>
#include <stdio.h>
// this gl include we won't need later when Evas_GL.h is complete
#include <GL/gl.h>
//static Evas_GL_API *evgl;
// demo - animator just to keep ticking over saying to draw the image
static Eina_Bool on_animate(void *data);
// callbacks we want to handle deletion on the object and updates/draws
static void on_pixels(void *data, Evas_Object *obj);
static void on_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
int main(void)
{
// config for the surface for evas_gl
Evas_GL_Config config =
{
EVAS_GL_RGBA_8,
EVAS_GL_DEPTH_NONE,
EVAS_GL_STENCIL_NONE
};
// a size by default
int w = 256, h = 256;
// some variables we will use
Ecore_Evas *ee;
Evas *canvas;
Evas_Object *r1;
Evas_Native_Surface ns;
Evas_GL *evasgl;
Evas_GL_Surface *sfc;
Evas_GL_Context *ctx;
float half_w, half_h;
float degree;
int x, y;
Evas_Map *map;
// regular low-leve EFL (ecore+ecore-evas) init. elm is simpler
ecore_init();
ecore_evas_init();
ee = ecore_evas_gl_x11_new(NULL, 0, 0, 0, 512, 512);
ecore_evas_title_set(ee, "Ecore_Evas Template");
canvas = ecore_evas_get(ee);
//-//-//-// THIS IS WHERE GL INIT STUFF HAPPENS (ALA EGL)
//-//
// get the evas gl handle for doing gl things
evasgl = evas_gl_new(canvas);
//evgl = evas_gl_api_get(evasgl);
// create a surface and context
sfc = evas_gl_surface_create(evasgl, &config, w, h);
ctx = evas_gl_context_create(evasgl, NULL);
//-//
//-//-//-// END GL INIT BLOB
// set up the image object. a filled one by default
r1 = evas_object_image_filled_add(canvas);
// attach important data we need to the object using key names. this just
// avoids some global variables and means we can do nice cleanup. you can
// avoid this if you are lazy
evas_object_data_set(r1, "..evasgl", evasgl);
evas_object_data_set(r1, "..sfc", sfc);
evas_object_data_set(r1, "..ctx", ctx);
// when the object is deleted - call the on_del callback. like the above,
// this is just being clean
evas_object_event_callback_add(r1, EVAS_CALLBACK_DEL, on_del, NULL);
// set up an actual pixel size fot the buffer data. it may be different
// to the output size. any windowing system has something like this, just
// evas has 2 sizes, a pixel size and the output object size
evas_object_image_size_set(r1, w, h);
// set up the native surface info to use the context and surface created
// above
//-//-//-// THIS IS WHERE GL INIT STUFF HAPPENS (ALA EGL)
//evas_gl_make_current(evasgl, sfc, ctx);
evas_gl_native_surface_get(evasgl, sfc, &ns);
evas_object_image_native_surface_set(r1, &ns);
evas_object_image_pixels_get_callback_set(r1, on_pixels, r1);
//-//
//-//-//-// END GL INIT BLOB
// move the image object somewhere, resize it and show it. any windowing
// system would need this kind of thing - place a child "window"
evas_object_move(r1, 128, 128);
evas_object_resize(r1, w, h);
map = evas_map_new(4);
if (!map) return -1;
evas_map_util_points_populate_from_object_full(map, r1, 0);
degree = 30;
evas_object_geometry_get(r1, &x, &y, &w, &h);
half_w = (float)w * 0.5;
half_h = (float)h * 0.5;
evas_object_map_enable_set(r1, EINA_TRUE);
evas_map_util_3d_rotate(map, 0, 0, degree, x + half_w, y + half_h, 0);
evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, 2000);
evas_object_map_enable_set(r1, EINA_TRUE);
evas_object_map_set(r1, map);
evas_object_show(r1);
// animating - just a demo. as long as you trigger an update on the image
// object via evas_object_image_pixels_dirty_set(). any display system,
// mainloop siztem etc. will have something of this kind unless it's making
// you spin infinitely yourself and invent your own animation mechanism
//
// NOTE: if you delete r1, this animator will keep runing trying to access
// r1 so you'd better delete this animator with ecore_animator_del() or
// structure how you do animation differently. you can also attach it like
// evasgl, sfc, etc. etc. if this animator is specific to this object
// only and delete it in the del handler for the obj.
ecore_animator_add(on_animate, r1);
// finally show the window for the world to see. windowing system generic
ecore_evas_show(ee);
// begin the mainloop and tick over the animator, handle events etc.
// also windowing system generic
ecore_main_loop_begin();
// standard EFL shutdown stuff - generic for most systems, EFL or not
ecore_evas_shutdown();
ecore_shutdown();
return 0;
}
static Eina_Bool
on_animate(void *data)
{
// just a demo - animate here whenever an animation tick happens and then
// mark the image as "dirty" meaning it needs an update next time evas
// renders. it will call the pixel get callback then.
evas_object_image_pixels_dirty_set(data, EINA_TRUE);
return EINA_TRUE; // keep looping
}
static void
on_del(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
// on delete of our object clean up some things that don't get auto
// celeted for us as they are not intrinsically bound to the image
// object as such (you could use the same context and surface across
// multiple image objects and re-use the evasgl handle too multiple times.
// here we bind them to 1 object only though by doing this.
Evas_GL *evasgl = evas_object_data_get(obj, "..evasgl");
Evas_GL_Surface *sfc = evas_object_data_get(obj, "..sfc");
Evas_GL_Context *ctx = evas_object_data_get(obj, "..ctx");
evas_gl_surface_destroy(evasgl, sfc);
evas_gl_context_destroy(evasgl, ctx);
evas_gl_free(evasgl);
}
static void
on_pixels(void *data, Evas_Object *obj)
{
// get some variable we need from the object data keys
Evas_GL *evasgl = evas_object_data_get(obj, "..evasgl");
Evas_GL_Surface *sfc = evas_object_data_get(obj, "..sfc");
Evas_GL_Context *ctx = evas_object_data_get(obj, "..ctx");
int w, h;
// get the image size in case it changed with evas_object_image_size_set()
evas_object_image_size_get(obj, &w, &h);
// set up the context and surface as the current one
evas_gl_make_current(evasgl, sfc, ctx);
printf("Image needs its pixels. It was marked as dirty. Provide them.\n");
// GL Viewport stuff. you can avoid doing this if viewport is all the
// same as last frame if you want
//
// NOTE: the below GL calls will become something like:
//
// evgl = evas_gl_api_get(evasgl);
// ...
// evgl->glViewport(0, 0, w, h);
// evgl->glMatrixMode(GL_PROJECTION);
// ...
// evgl->glClear(GL_COLOR_BUFFER_BIT);
// evgl->glEnable(GL_BLEND);
// ... etc.
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, w, 0, h, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// Clear the buffer
glClearColor(1.0, 0.3, 0.3, 1);
glClear(GL_COLOR_BUFFER_BIT);
// Draw a Triangle
glEnable(GL_BLEND);
glBegin(GL_TRIANGLES);
glColor3f(1, 0, 0);
glVertex3f(20, 20, 0);
glColor3f(0, 1, 0);
glVertex3f(236, 20, 0);
glColor3f(0, 0, 1);
glVertex3f(128, 236, 0);
glEnd();
// Optional - Flush the GL pipeline
glFlush();
}
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network
management toolset available today. Delivers lowest initial
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel