From f8cd006b2f07ca76cdec360be2adf9dd00bce243 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:31:49 +0200 Subject: [PATCH] evas: and now fix Evas GL backend to display Evas_Object_VG correctly. --- .../evas/engines/gl_generic/evas_engine.c | 89 ++++++++++++++----- 1 file changed, 66 insertions(+), 23 deletions(-) diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c index f3d329d4ec..5865d4ba25 100644 --- a/src/modules/evas/engines/gl_generic/evas_engine.c +++ b/src/modules/evas/engines/gl_generic/evas_engine.c @@ -22,6 +22,7 @@ #endif #include "cairo/Ector_Cairo.h" +#include "software/Ector_Software.h" #include "ector_cairo_software_surface.eo.h" @@ -2092,13 +2093,26 @@ eng_texture_image_set(void *data EINA_UNUSED, void *texture, void *image) } static Ector_Surface *_software_ector = NULL; +static Eina_Bool use_cairo; static Ector_Surface * eng_ector_get(void *data EINA_UNUSED) { if (!_software_ector) { - _software_ector = eo_add(ECTOR_CAIRO_SOFTWARE_SURFACE_CLASS, NULL); + const char *ector_backend; + + ector_backend = getenv("ECTOR_BACKEND"); + if (ector_backend && !strcasecmp(ector_backend, "freetype")) + { + _software_ector = eo_add(ECTOR_SOFTWARE_SURFACE_CLASS, NULL); + use_cairo = EINA_FALSE; + } + else + { + _software_ector = eo_add(ECTOR_CAIRO_SOFTWARE_SURFACE_CLASS, NULL); + use_cairo = EINA_TRUE; + } } return _software_ector; } @@ -2118,16 +2132,18 @@ _evas_render_op_to_ector_rop(Evas_Render_Op op) } static void -eng_ector_renderer_draw(void *data EINA_UNUSED, void *context, void *surface, Ector_Renderer *renderer, Eina_Array *clips, int x, int y, Eina_Bool do_async EINA_UNUSED) +eng_ector_renderer_draw(void *data, void *context EINA_UNUSED, void *surface, Ector_Renderer *renderer, Eina_Array *clips, int x, int y, Eina_Bool do_async EINA_UNUSED) { Evas_GL_Image *dst = surface; - Evas_Engine_GL_Context *gc = context; + Evas_Engine_GL_Context *gc; + Render_Engine_GL_Generic *re = data; Eina_Rectangle *r; Eina_Array *c; Eina_Rectangle clip; Eina_Array_Iterator it; unsigned int i; + gc = re->window_gl_context_get(re->software.ob); if (gc->dc->clip.use) { clip.x = gc->dc->clip.x; @@ -2185,35 +2201,62 @@ static void *software_buffer = NULL; static void eng_ector_begin(void *data EINA_UNUSED, void *context EINA_UNUSED, void *surface, Eina_Bool do_async EINA_UNUSED) { - Evas_GL_Image *dst = surface; + Evas_Engine_GL_Context *gl_context; + Render_Engine_GL_Generic *re = data; + int w, h; - software_buffer = realloc(software_buffer, sizeof (unsigned int) * dst->w * dst->h); - eo_do(_software_ector, - ector_cairo_software_surface_set(software_buffer, dst->w, dst->h)); + re->window_use(re->software.ob); + gl_context = re->window_gl_context_get(re->software.ob); + evas_gl_common_context_target_surface_set(gl_context, surface); + gl_context->dc = context; + + w = gl_context->w; h = gl_context->h; + + software_buffer = realloc(software_buffer, sizeof (unsigned int) * w * h); + if (use_cairo) + { + eo_do(_software_ector, + ector_cairo_software_surface_set(software_buffer, w, h)); + } + else + { + eo_do(_software_ector, + ector_software_surface_set(software_buffer, w, h)); + } } static void -eng_ector_end(void *data, void *context, void *surface, Eina_Bool do_async) +eng_ector_end(void *data, void *context EINA_UNUSED, void *surface EINA_UNUSED, Eina_Bool do_async EINA_UNUSED) { - Evas_GL_Image *dst = surface; + Evas_Engine_GL_Context *gl_context; + Render_Engine_GL_Generic *re = data; Evas_GL_Image *im; + int w, h; - eo_do(_software_ector, - ector_cairo_software_surface_set(NULL, 0, 0)); + gl_context = re->window_gl_context_get(re->software.ob); + w = gl_context->w; h = gl_context->h; - im = evas_gl_common_image_new_from_data(context, dst->w, dst->h, software_buffer, 1, EVAS_COLORSPACE_ARGB8888); - eng_image_draw(data, context, surface, im, - // We actually just bluntly push the pixel all over the - // destination surface. We don't have the actual information - // of the widget size. This is not a problem. - // Later on, we don't want that information and today when - // using GL backend, you just need to turn on Evas_Map on - // the Evas_Object_VG. - 0, 0, dst->w, dst->h, - 0, 0, dst->w, dst->h, 0, do_async); + if (use_cairo) + { + eo_do(_software_ector, + ector_cairo_software_surface_set(NULL, 0, 0)); + } + else + { + eo_do(_software_ector, + ector_software_surface_set(NULL, 0, 0)); + } - evas_common_rgba_image_free(software_buffer); - software_buffer = NULL; + im = evas_gl_common_image_new_from_copied_data(gl_context, w, h, software_buffer, 1, EVAS_COLORSPACE_ARGB8888); + // We actually just bluntly push the pixel all over the + // destination surface. We don't have the actual information + // of the widget size. This is not a problem. + // Later on, we don't want that information and today when + // using GL backend, you just need to turn on Evas_Map on + // the Evas_Object_VG. + evas_gl_common_image_draw(gl_context, im, 0, 0, w, h, 0, 0, w, h, 0); + + evas_gl_common_image_free(im); } static Evas_Func func, pfunc;