diff options
author | subhransu mohanty <sub.mohanty@samsung.com> | 2017-11-09 16:55:44 +0900 |
---|---|---|
committer | Jean-Philippe Andre <jp.andre@samsung.com> | 2017-11-10 11:20:38 +0900 |
commit | f0b8c37d805fceba15ba317dd96b906d6e12f147 (patch) | |
tree | 5660c10fe9e66ca600f676779000d1c13ff52fc6 | |
parent | befb7701a71e45e9c76fb3873f3056b74d62527c (diff) | |
download | efl-f0b8c37d805fceba15ba317dd96b906d6e12f147.tar.gz |
evas/vg: refactor ector engine api and backend .
-rw-r--r-- | src/lib/evas/canvas/evas_main.c | 2 | ||||
-rw-r--r-- | src/lib/evas/include/evas_private.h | 9 | ||||
-rw-r--r-- | src/modules/evas/engines/gl_generic/evas_engine.c | 205 | ||||
-rw-r--r-- | src/modules/evas/engines/software_generic/evas_engine.c | 40 |
4 files changed, 64 insertions, 192 deletions
diff --git a/src/lib/evas/canvas/evas_main.c b/src/lib/evas/canvas/evas_main.c index dff563f195..60d2b7b4a1 100644 --- a/src/lib/evas/canvas/evas_main.c +++ b/src/lib/evas/canvas/evas_main.c @@ -887,8 +887,6 @@ _image_data_unset(Evas_Object_Protected_Data *obj, Eina_List **list) } CHECK(EFL_CANVAS_IMAGE_INTERNAL_CLASS, Evas_Image_Data, ENFN->image_free(ENC, data->engine_data)) - else CHECK(EFL_CANVAS_VG_CLASS, Efl_Canvas_Vg_Data, - obj->layer->evas->engine.func->ector_free(data->engine_data)) else CHECK(EFL_CANVAS_POLYGON_CLASS, Efl_Canvas_Polygon_Data, data->engine_data = obj->layer->evas->engine.func->polygon_points_clear(ENC, diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h index 2fac91e094..43d378511b 100644 --- a/src/lib/evas/include/evas_private.h +++ b/src/lib/evas/include/evas_private.h @@ -1503,15 +1503,12 @@ struct _Evas_Func void *(*texture_image_get) (void *engine, void *texture); Ector_Surface *(*ector_create) (void *engine); - void (*ector_output_set) (void *engine, Ector_Surface *surface, void *output); void (*ector_destroy) (void *engine, Ector_Surface *surface); Ector_Buffer *(*ector_buffer_wrap) (void *engine, Evas *e, void *engine_image); Ector_Buffer *(*ector_buffer_new) (void *engine, Evas *e, int width, int height, Efl_Gfx_Colorspace cspace, Ector_Buffer_Flag flags); - void (*ector_begin) (void *engine, void *context, Ector_Surface *ector, void *surface, void *engine_data, int x, int y, Eina_Bool do_async); - void (*ector_renderer_draw) (void *engine, void *data, void *context, void *surface, void *engine_data, Ector_Renderer *r, Eina_Array *clips, Eina_Bool do_async); - void (*ector_end) (void *engine, void *context, Ector_Surface *ector, void *surface, void *engine_data, Eina_Bool do_async); - void* (*ector_new) (void *engine, void *context, Ector_Surface *ector, void *surface); - void (*ector_free) (void *engine_data); + void (*ector_begin) (void *engine, void *output, void *context, void *surface, Ector_Surface *ector, int x, int y, Eina_Bool do_async); + void (*ector_renderer_draw) (void *engine, void *output, void *context, void *surface, Ector_Renderer *r, Eina_Array *clips, Eina_Bool do_async); + void (*ector_end) (void *engine, void *output, void *context, void *surface, Ector_Surface *ector, Eina_Bool do_async); void *(*ector_surface_create) (void *engine, int w, int h, int *error); void (*ector_surface_destroy) (void *engine, void *surface); diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c index 6e6d6a9082..0829e7a0b4 100644 --- a/src/modules/evas/engines/gl_generic/evas_engine.c +++ b/src/modules/evas/engines/gl_generic/evas_engine.c @@ -172,7 +172,8 @@ eng_engine_free(void *engine) Render_Engine_GL_Generic *e = engine; Render_Output_GL_Generic *output; - generic_cache_destroy(e->software.surface_cache); + //@FIXME this causes some deadlock while freeing the engine image. + //generic_cache_destroy(e->software.surface_cache); EINA_LIST_FREE(e->software.outputs, output) ERR("Output %p not properly cleaned before engine destruction.", output); @@ -2560,67 +2561,30 @@ _evas_render_op_to_ector_rop(Evas_Render_Op op) } static void -eng_ector_renderer_draw(void *engine EINA_UNUSED, void *data, void *context, void *surface, void *engine_data EINA_UNUSED, Ector_Renderer *renderer, Eina_Array *clips, Eina_Bool do_async EINA_UNUSED) +eng_ector_renderer_draw(void *engine EINA_UNUSED, void *output, + void *context EINA_UNUSED, void *surface EINA_UNUSED, + Ector_Renderer *renderer, Eina_Array *clips EINA_UNUSED, Eina_Bool do_async EINA_UNUSED) { - Evas_GL_Image *dst = surface; - Evas_Engine_GL_Context *gc; - Render_Output_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); - gc->dc = context; - if (gc->dc->clip.use) - { - clip.x = gc->dc->clip.x; - clip.y = gc->dc->clip.y; - clip.w = gc->dc->clip.w; - clip.h = gc->dc->clip.h; - } - else - { - clip.x = 0; - clip.y = 0; - clip.w = dst->w; - clip.h = dst->h; - } - - c = eina_array_new(8); - if (clips) + if (use_cairo|| !use_gl) { - EINA_ARRAY_ITER_NEXT(clips, i, r, it) - { - Eina_Rectangle *rc; + int w, h; + Eina_Rectangle *r; + Eina_Array *c = eina_array_new(4); + Evas_GL_Image *glimg = output; - rc = eina_rectangle_new(r->x, r->y, r->w, r->h); - if (!rc) continue; + eng_image_size_get(engine, glimg, &w, &h); + eina_array_push(c, eina_rectangle_new(0, 0, w, h)); - if (eina_rectangle_intersection(rc, &clip)) - eina_array_push(c, rc); - else - eina_rectangle_free(rc); - } + ector_renderer_draw(renderer, _evas_render_op_to_ector_rop(EVAS_RENDER_COPY), c, 0xffffffff); - if (eina_array_count(c) == 0 && - eina_array_count(clips) > 0) - { - eina_array_free(c); - return; - } + while ((r = eina_array_pop(c))) + eina_rectangle_free(r); + eina_array_free(c); + } + else + { + //FIXME no implementation yet } - - if (eina_array_count(c) == 0) - eina_array_push(c, eina_rectangle_new(clip.x, clip.y, clip.w, clip.h)); - - ector_renderer_draw(renderer, _evas_render_op_to_ector_rop(gc->dc->render_op), c, // mul_col will be applied by GL during ector_end - 0xffffffff); - - while ((r = eina_array_pop(c))) - eina_rectangle_free(r); - eina_array_free(c); } // Ector functions start @@ -2641,7 +2605,7 @@ eng_ector_surface_create(void *engine, int width, int height, int *error) { surface = eng_image_new_from_copied_data(engine, width, height, NULL, EINA_TRUE, EVAS_COLORSPACE_ARGB8888); if (!surface) - *error = EINA_TRUE; + *error = EINA_TRUE; else //Use this hint for ZERO COPY texture upload. eng_image_content_hint_set(engine, surface, EVAS_IMAGE_CONTENT_HINT_DYNAMIC); } @@ -2681,127 +2645,54 @@ eng_ector_surface_cache_drop(void *engine, void *key) generic_cache_data_drop(e->software.surface_cache, key); } - -typedef struct _Evas_GL_Ector Evas_GL_Ector; -struct _Evas_GL_Ector -{ - Evas_GL_Image *gl; - DATA32 *software; - - Eina_Bool tofree; -}; - -static void* -eng_ector_new(void *engine EINA_UNUSED, void *context EINA_UNUSED, Ector_Surface *ector EINA_UNUSED, void *surface EINA_UNUSED) -{ - Evas_GL_Ector *r; - - r = calloc(1, sizeof (Evas_GL_Ector)); - return r; -} - -static void -eng_ector_free(void *engine_data) -{ - Evas_GL_Ector *r = engine_data; - - evas_gl_common_image_free(r->gl); - if (r->tofree) free(r->software); - free(r); -} - static void -eng_ector_begin(void *engine, void *context EINA_UNUSED, Ector_Surface *ector, - void *surface, void *engine_data, - int x, int y, Eina_Bool do_async EINA_UNUSED) +eng_ector_begin(void *engine, void *output, + void *context EINA_UNUSED, void *surface EINA_UNUSED, + Ector_Surface *ector, int x, int y, Eina_Bool do_async EINA_UNUSED) { - Evas_Engine_GL_Context *gl_context; - Evas_GL_Ector *buffer = engine_data; - int w, h; - - gl_context = gl_generic_context_get(engine, 1); - evas_gl_common_context_target_surface_set(gl_context, surface); - gl_context->dc = context; - if (use_cairo|| !use_gl) { - w = gl_context->w; h = gl_context->h; - - if (!buffer->gl || buffer->gl->w != w || buffer->gl->h != h) - { - int err = EVAS_LOAD_ERROR_NONE; + int w, h, stride; + Evas_GL_Image *glim = output; + DATA32 *pixels; + int load_err; - evas_gl_common_image_free(buffer->gl); - if (buffer->tofree) free(buffer->software); - buffer->software = NULL; + glim = eng_image_data_get(engine, glim, EINA_TRUE, &pixels, &load_err,NULL); + eng_image_stride_get(engine, glim, &stride); + eng_image_size_get(engine, glim, &w, &h); + memset(pixels, 0, stride * h); - buffer->gl = evas_gl_common_image_new(gl_context, w, h, 1, EVAS_COLORSPACE_ARGB8888); - if (!buffer->gl) - { - ERR("Creation of an image for vector graphics [%i, %i] failed\n", w, h); - return ; - } - /* evas_gl_common_image_content_hint_set(buffer->gl, EVAS_IMAGE_CONTENT_HINT_DYNAMIC); */ - buffer->gl = eng_image_data_get(engine, buffer->gl, 1, &buffer->software, &err, &buffer->tofree); - if (!buffer->gl && err != EVAS_LOAD_ERROR_NONE) - { - ERR("Mapping of an image for vector graphics [%i, %i] failed with %i\n", w, h, err); - return ; - } - } - memset(buffer->software, 0, sizeof (unsigned int) * w * h); - ector_buffer_pixels_set(ector, buffer->software, w, h, EFL_GFX_COLORSPACE_ARGB8888, EINA_TRUE); + // it just uses the software backend to draw for now + ector_buffer_pixels_set(ector, pixels, w, h, EFL_GFX_COLORSPACE_ARGB8888, EINA_TRUE); ector_surface_reference_point_set(ector, x, y); } else { - evas_gl_common_context_flush(gl_context); - - ector_surface_reference_point_set(ector, x, y); + //FIXME: No implementation yet } } static void -eng_ector_end(void *engine, void *context EINA_UNUSED, Ector_Surface *ector, - void *surface EINA_UNUSED, void *engine_data, - Eina_Bool do_async EINA_UNUSED) +eng_ector_end(void *engine, void *output, + void *context EINA_UNUSED, void *surface EINA_UNUSED, + Ector_Surface *ector, Eina_Bool do_async EINA_UNUSED) { - Evas_Engine_GL_Context *gl_context; - Evas_GL_Ector *buffer = engine_data; - int w, h; - Eina_Bool mul_use; - if (use_cairo || !use_gl) { - gl_context = gl_generic_context_get(engine, 1); - w = gl_context->w; h = gl_context->h; - mul_use = gl_context->dc->mul.use; - - ector_buffer_pixels_set(ector, NULL, 0, 0, 0, 0); - buffer->gl = eng_image_data_put(engine, buffer->gl, buffer->software); - - if (!mul_use) - { - // @hack as image_draw uses below fields to do colour multiplication. - gl_context->dc->mul.col = ector_color_multiply(0xffffffff, gl_context->dc->col.col); - gl_context->dc->mul.use = EINA_TRUE; - } + Evas_GL_Image *glim = output; + DATA32 *pixels; + int load_err; - // 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, buffer->gl, 0, 0, w, h, 0, 0, w, h, 0); + glim = eng_image_data_get(engine, glim, EINA_FALSE, &pixels, &load_err,NULL); - // restore gl state - gl_context->dc->mul.use = mul_use; + eng_image_data_put(engine, glim, pixels); + eng_image_data_put(engine, glim, pixels); + ector_buffer_pixels_set(ector, NULL, 0, 0, EFL_GFX_COLORSPACE_ARGB8888, EINA_TRUE); + evas_common_cpu_end_opt(); } else if (use_gl) { - // FIXME: Need to find a cleaner way to do so (maybe have a reset in evas_gl_context) - // Force a full pipe reinitialization for now + //FIXME: No implementation yet } } @@ -3362,8 +3253,6 @@ module_open(Evas_Module *em) ORD(ector_begin); ORD(ector_renderer_draw); ORD(ector_end); - ORD(ector_new); - ORD(ector_free); ORD(ector_surface_create); ORD(ector_surface_destroy); ORD(ector_surface_cache_set); diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c index 1d7c97c7d4..69cc07b39b 100644 --- a/src/modules/evas/engines/software_generic/evas_engine.c +++ b/src/modules/evas/engines/software_generic/evas_engine.c @@ -4365,15 +4365,6 @@ eng_ector_surface_cache_drop(void *engine, void *key) generic_cache_data_drop(e->surface_cache, key); } - -static void -eng_ector_output_set(void *engine EINA_UNUSED, - Ector_Surface *surface EINA_UNUSED, - void *output EINA_UNUSED) -{ - // To be useful for GL backend only. -} - static void eng_ector_destroy(void *data EINA_UNUSED, Ector_Surface *ector) { @@ -4467,8 +4458,11 @@ _draw_thread_ector_draw(void *data) } static void -eng_ector_renderer_draw(void *engine EINA_UNUSED, void *data EINA_UNUSED, void *context, void *surface, void *engine_data EINA_UNUSED, Ector_Renderer *renderer, Eina_Array *clips, Eina_Bool do_async) +eng_ector_renderer_draw(void *engine EINA_UNUSED, void *surface, + void *context, void *remove EINA_UNUSED, + Ector_Renderer *renderer, Eina_Array *clips, Eina_Bool do_async) { + RGBA_Image *dst = surface; RGBA_Draw_Context *dc = context; Evas_Thread_Command_Ector ector; @@ -4573,6 +4567,8 @@ _draw_thread_ector_surface_set(void *data) h = surface->cache_entry.h; x = ector_surface->x; y = ector_surface->y; + // clear the surface before giving to ector + memset(pixels, 0, (w * h * 4)); } ector_buffer_pixels_set(ector_surface->ector, pixels, w, h, EFL_GFX_COLORSPACE_ARGB8888, EINA_TRUE); @@ -4581,19 +4577,10 @@ _draw_thread_ector_surface_set(void *data) eina_mempool_free(_mp_command_ector_surface, ector_surface); } -static void* -eng_ector_new(void *data EINA_UNUSED, void *context EINA_UNUSED, Ector_Surface *ector EINA_UNUSED, void *surface EINA_UNUSED) -{ - return NULL; -} - -static void -eng_ector_free(void *engine_data EINA_UNUSED) -{ -} - static void -eng_ector_begin(void *data EINA_UNUSED, void *context EINA_UNUSED, Ector_Surface *ector, void *surface, void *engine_data EINA_UNUSED, int x, int y, Eina_Bool do_async) +eng_ector_begin(void *engine EINA_UNUSED, void *surface, + void *context EINA_UNUSED, void *remove EINA_UNUSED, + Ector_Surface *ector, int x, int y, Eina_Bool do_async) { if (do_async) { @@ -4619,6 +4606,8 @@ eng_ector_begin(void *data EINA_UNUSED, void *context EINA_UNUSED, Ector_Surface pixels = evas_cache_image_pixels(&sf->cache_entry); w = sf->cache_entry.w; h = sf->cache_entry.h; + // clear the surface before giving to ector + memset(pixels, 0, (w * h * 4)); ector_buffer_pixels_set(ector, pixels, w, h, EFL_GFX_COLORSPACE_ARGB8888, EINA_TRUE); ector_surface_reference_point_set(ector, x, y); @@ -4626,7 +4615,9 @@ eng_ector_begin(void *data EINA_UNUSED, void *context EINA_UNUSED, Ector_Surface } static void -eng_ector_end(void *data EINA_UNUSED, void *context EINA_UNUSED, Ector_Surface *ector, void *surface EINA_UNUSED, void *engine_data EINA_UNUSED, Eina_Bool do_async) +eng_ector_end(void *engine EINA_UNUSED, void *surface EINA_UNUSED, + void *context EINA_UNUSED, void *remove EINA_UNUSED, + Ector_Surface *ector, Eina_Bool do_async) { if (do_async) { @@ -4885,15 +4876,12 @@ static Evas_Func func = NULL, // eng_texture_image_set NULL, // eng_texture_image_get eng_ector_create, - eng_ector_output_set, eng_ector_destroy, eng_ector_buffer_wrap, eng_ector_buffer_new, eng_ector_begin, eng_ector_renderer_draw, eng_ector_end, - eng_ector_new, - eng_ector_free, eng_ector_surface_create, eng_ector_surface_destroy, eng_ector_surface_cache_set, |