From: Cedric BAIL Date: Tue, 25 Apr 2017 23:15:37 +0000 (-0700) Subject: evas: do not rely on Evas canvas for Evas Ector engine backend. X-Git-Tag: upstream/1.20.0~1307 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7f5ec0c8ea00020be823808edbee12ad74c19fe6;p=platform%2Fupstream%2Fefl.git evas: do not rely on Evas canvas for Evas Ector engine backend. --- diff --git a/src/lib/evas/include/evas_ector_buffer.eo b/src/lib/evas/include/evas_ector_buffer.eo index f65012e..77f66a3 100644 --- a/src/lib/evas/include/evas_ector_buffer.eo +++ b/src/lib/evas/include/evas_ector_buffer.eo @@ -13,7 +13,7 @@ interface Evas.Ector.Buffer engine_image_set { [[Attach this ector buffer to an existing engine image.]] params { - @in evas: Evas.Canvas; [[The current Evas.]] + @in engine: void_ptr; [[The current Evas.]] @in image: void_ptr; [[The RGBA_Image or Evas_GL_Image.]] } } diff --git a/src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.c b/src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.c index 26c2c47..46eb8d3 100644 --- a/src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.c +++ b/src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.c @@ -39,18 +39,21 @@ struct _Ector_GL_Buffer_Map struct _Evas_Ector_GL_Buffer_Data { - Evas_Public_Data *evas; + Render_Engine_GL_Generic *re; Evas_GL_Image *glim; Eina_Bool alpha_only, was_render; Ector_GL_Buffer_Map *maps; }; +void *eng_image_data_put(void *data, void *image, DATA32 *image_data); +void *eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data, int *err, Eina_Bool *tofree); +void eng_image_free(void *data, void *image); + #undef ENFN #undef ENDT #undef ENC -#define ENFN pd->evas->engine.func -#define ENC _evas_engine_context(pd->evas) +#define ENC pd->re // testing out some macros to maybe add to eina #define EINA_INLIST_REMOVE(l,i) do { l = (__typeof__(l)) eina_inlist_remove(EINA_INLIST_GET(l), EINA_INLIST_GET(i)); } while (0) @@ -104,16 +107,16 @@ _evas_gl_image_is_fbo(Evas_GL_Image *glim) EOLIAN static void _evas_ector_gl_buffer_gl_buffer_prepare(Eo *obj, Evas_Ector_GL_Buffer_Data *pd, - Evas_Canvas *eo_evas, + void *engine, int w, int h, Efl_Gfx_Colorspace cspace, Ector_Buffer_Flag flags EINA_UNUSED) { - Render_Engine_GL_Generic *re; + Render_Engine_GL_Generic *re = engine; Evas_Engine_GL_Context *gc; Evas_GL_Image *im; // this is meant to be called only once - EINA_SAFETY_ON_FALSE_GOTO(!pd->evas, on_fail); + EINA_SAFETY_ON_FALSE_GOTO(!pd->re, on_fail); EINA_SAFETY_ON_FALSE_GOTO(!efl_finalized_get(obj), on_fail); if (cspace == EFL_GFX_COLORSPACE_ARGB8888) @@ -123,9 +126,7 @@ _evas_ector_gl_buffer_gl_buffer_prepare(Eo *obj, Evas_Ector_GL_Buffer_Data *pd, else fail("Unsupported colorspace: %u", cspace); - // FIXME: we should not rely on evas canvas in the module (just evas engine) - pd->evas = efl_data_xref(eo_evas, EVAS_CANVAS_CLASS, obj); - re = ENC; + pd->re = re; gc = re->window_gl_context_get(re->software.ob); im = evas_gl_common_image_surface_new(gc, w, h, EINA_TRUE, EINA_FALSE); @@ -243,12 +244,12 @@ _evas_ector_gl_buffer_ector_buffer_map(Eo *obj EINA_UNUSED, Evas_Ector_GL_Buffer if (write && _evas_gl_image_is_fbo(pd->glim)) { // Can not open FBO data to write! - im = ENFN->image_data_get(ENC, pd->glim, EINA_FALSE, &data, &err, &tofree); + im = eng_image_data_get(ENC, pd->glim, EINA_FALSE, &data, &err, &tofree); if (!im) return NULL; } else { - im = ENFN->image_data_get(ENC, pd->glim, write, &data, &err, &tofree); + im = eng_image_data_get(ENC, pd->glim, write, &data, &err, &tofree); if (!im) return NULL; } @@ -338,12 +339,12 @@ _evas_ector_gl_buffer_ector_buffer_unmap(Eo *obj EINA_UNUSED, Evas_Ector_GL_Buff if (map->im) { MAP_DUMP(map->im, "out_ro_free"); - ENFN->image_free(ENC, map->im); + eng_image_free(ENC, map->im); } else { MAP_DUMP(pd->glim, "out_ro_nofree"); - ENFN->image_data_put(ENC, pd->glim, map->image_data); + eng_image_data_put(ENC, pd->glim, map->image_data); } } if (map->allocated) @@ -371,7 +372,6 @@ EOLIAN static void _evas_ector_gl_buffer_efl_object_destructor(Eo *obj, Evas_Ector_GL_Buffer_Data *pd) { evas_gl_common_image_free(pd->glim); - efl_data_xunref(pd->evas->evas, pd->evas, obj); efl_destructor(efl_super(obj, MY_CLASS)); } diff --git a/src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.eo b/src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.eo index 6c6bdc0..57335dd 100644 --- a/src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.eo +++ b/src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.eo @@ -8,7 +8,7 @@ class Evas.Ector.GL.Buffer (Efl.Object, Evas.Ector.Buffer, Ector.GL.Buffer) gl_buffer_prepare { [[Set the main properties to create a gl buffer.]] params { - evas: Evas.Canvas; [[The current canvas]] + engine: void_ptr; [[The current canvas engine]] w: int; [[Width]] h: int; [[Height]] cspace: Efl.Gfx.Colorspace; [[Alpha or RGBA]] diff --git a/src/modules/evas/engines/gl_generic/evas_ector_gl_image_buffer.c b/src/modules/evas/engines/gl_generic/evas_ector_gl_image_buffer.c index 157c0e1..1ba39d1 100644 --- a/src/modules/evas/engines/gl_generic/evas_ector_gl_image_buffer.c +++ b/src/modules/evas/engines/gl_generic/evas_ector_gl_image_buffer.c @@ -38,7 +38,7 @@ struct _Ector_GL_Buffer_Map struct _Evas_Ector_GL_Image_Buffer_Data { - Evas_Public_Data *evas; + Render_Engine_GL_Generic *re; Evas_GL_Image *glim; Ector_GL_Buffer_Map *maps; }; @@ -47,9 +47,11 @@ struct _Evas_Ector_GL_Image_Buffer_Data #undef ENDT #undef ENC -// FIXME: It should not use evas canvas, just the engine -#define ENFN pd->evas->engine.func -#define ENC _evas_engine_context(pd->evas) +#define ENC pd->re + +void *eng_image_data_put(void *data, void *image, DATA32 *image_data); +void *eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data, int *err, Eina_Bool *tofree); +void eng_image_free(void *data, void *image); // testing out some macros to maybe add to eina #define EINA_INLIST_REMOVE(l,i) do { l = (__typeof__(l)) eina_inlist_remove(EINA_INLIST_GET(l), EINA_INLIST_GET(i)); } while (0) @@ -70,19 +72,18 @@ _pixels_argb_to_gry8_convert(uint8_t *dst, const uint32_t *src, int len) } EOLIAN static void -_evas_ector_gl_image_buffer_evas_ector_buffer_engine_image_set(Eo *obj, Evas_Ector_GL_Image_Buffer_Data *pd, - Evas *eo_evas, void *image) +_evas_ector_gl_image_buffer_evas_ector_buffer_engine_image_set(Eo *obj EINA_UNUSED, + Evas_Ector_GL_Image_Buffer_Data *pd, + void *engine, void *image) { + Render_Engine_GL_Generic *re = engine; Evas_GL_Image *im = image; - Evas_Public_Data *evas; EINA_SAFETY_ON_FALSE_RETURN(!pd->glim); EINA_SAFETY_ON_NULL_RETURN(im); - evas = efl_data_xref(eo_evas, EVAS_CANVAS_CLASS, obj); if (!im->tex) { - Render_Engine_GL_Generic *re = ENC; Evas_Engine_GL_Context *gc; gc = re->window_gl_context_get(re->software.ob); @@ -92,12 +93,11 @@ _evas_ector_gl_image_buffer_evas_ector_buffer_engine_image_set(Eo *obj, Evas_Ect fail("Image has no texture!"); } - pd->evas = evas; + pd->re = re; evas_gl_common_image_ref(im); pd->glim = im; -on_fail: - efl_data_xunref(eo_evas, evas, obj); + on_fail: return; } @@ -188,7 +188,7 @@ _evas_ector_gl_image_buffer_ector_buffer_map(Eo *obj EINA_UNUSED, Evas_Ector_GL_ if (!h) h = H - y; if ((x + w > W) || (y + h > H)) return NULL; - im = ENFN->image_data_get(ENC, pd->glim, EINA_FALSE, &data, &err, &tofree); + im = eng_image_data_get(ENC, pd->glim, EINA_FALSE, &data, &err, &tofree); if (!im) return NULL; map = calloc(1, sizeof(*map)); @@ -252,9 +252,9 @@ _evas_ector_gl_image_buffer_ector_buffer_unmap(Eo *obj EINA_UNUSED, { EINA_INLIST_REMOVE(pd->maps, map); if (map->free_image) - ENFN->image_free(ENC, map->im); + eng_image_free(ENC, map->im); else - ENFN->image_data_put(ENC, map->im, map->image_data); + eng_image_data_put(ENC, map->im, map->image_data); if (map->allocated) free(map->base_data); free(map); @@ -280,7 +280,6 @@ EOLIAN static void _evas_ector_gl_image_buffer_efl_object_destructor(Eo *obj, Evas_Ector_GL_Image_Buffer_Data *pd) { evas_gl_common_image_free(pd->glim); - efl_data_xunref(pd->evas->evas, pd->evas, obj); efl_destructor(efl_super(obj, MY_CLASS)); } diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c index 951f656..223a23f 100644 --- a/src/modules/evas/engines/gl_generic/evas_engine.c +++ b/src/modules/evas/engines/gl_generic/evas_engine.c @@ -547,7 +547,7 @@ eng_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data, int return evas_gl_common_image_new_from_copied_data(gl_context, w, h, image_data, alpha, cspace); } -static void +void eng_image_free(void *data, void *image) { Render_Engine_GL_Generic *re = data; @@ -717,7 +717,7 @@ _rotate_image_data(Render_Engine_GL_Generic *re, Evas_GL_Image *im1) return im2; } -static void * +void * eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data, int *err, Eina_Bool *tofree) { Render_Engine_GL_Generic *re = data; @@ -943,7 +943,7 @@ rotate_image: return im_new; } -static void * +void * eng_image_data_put(void *data, void *image, DATA32 *image_data) { Render_Engine_GL_Generic *re = data; @@ -2476,11 +2476,11 @@ eng_ector_buffer_wrap(void *data EINA_UNUSED, Evas *evas, void *engine_image) } static Ector_Buffer * -eng_ector_buffer_new(void *data EINA_UNUSED, Evas *evas, int w, int h, +eng_ector_buffer_new(void *data, Evas *evas, int w, int h, Efl_Gfx_Colorspace cspace, Ector_Buffer_Flag flags) { return efl_add(EVAS_ECTOR_GL_BUFFER_CLASS, evas, - evas_ector_gl_buffer_prepare(efl_added, evas, w, h, cspace, flags)); + evas_ector_gl_buffer_prepare(efl_added, data, w, h, cspace, flags)); } static Efl_Gfx_Render_Op diff --git a/src/modules/evas/engines/software_generic/evas_ector_software_buffer.c b/src/modules/evas/engines/software_generic/evas_ector_software_buffer.c index 262c405..cebda32 100644 --- a/src/modules/evas/engines/software_generic/evas_ector_software_buffer.c +++ b/src/modules/evas/engines/software_generic/evas_ector_software_buffer.c @@ -13,7 +13,6 @@ typedef struct { Ector_Software_Buffer_Base_Data *base; - Evas_Public_Data *evas; RGBA_Image *image; } Evas_Ector_Software_Buffer_Data; @@ -21,8 +20,10 @@ typedef struct { // eg. in the filters. EOLIAN static void -_evas_ector_software_buffer_evas_ector_buffer_engine_image_set(Eo *obj, Evas_Ector_Software_Buffer_Data *pd, - Evas *evas, void *image) +_evas_ector_software_buffer_evas_ector_buffer_engine_image_set(Eo *obj, + Evas_Ector_Software_Buffer_Data *pd, + void *engine EINA_UNUSED, + void *image) { RGBA_Image *im = image; @@ -30,7 +31,6 @@ _evas_ector_software_buffer_evas_ector_buffer_engine_image_set(Eo *obj, Evas_Ect EINA_SAFETY_ON_FALSE_RETURN(!efl_finalized_get(obj)); EINA_SAFETY_ON_NULL_RETURN(im->image.data); - pd->evas = efl_data_xref(evas, EVAS_CANVAS_CLASS, obj); evas_cache_image_ref(&im->cache_entry); pd->image = im; @@ -87,8 +87,6 @@ _evas_ector_software_buffer_efl_object_destructor(Eo *obj, Evas_Ector_Software_B { efl_data_xunref(obj, pd->base, obj); evas_cache_image_drop(&pd->image->cache_entry); - if (pd->evas) - efl_data_xunref(pd->evas->evas, pd->evas, obj); efl_destructor(efl_super(obj, MY_CLASS)); } diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c index 84bd52f..dbc2c4a 100644 --- a/src/modules/evas/engines/software_generic/evas_engine.c +++ b/src/modules/evas/engines/software_generic/evas_engine.c @@ -4333,7 +4333,7 @@ eng_ector_destroy(void *data EINA_UNUSED, Ector_Surface *ector) } static Ector_Buffer * -eng_ector_buffer_wrap(void *data EINA_UNUSED, Evas *e, void *engine_image) +eng_ector_buffer_wrap(void *data, Evas *e EINA_UNUSED, void *engine_image) { Image_Entry *ie = engine_image; Ector_Buffer *buf = NULL; @@ -4343,7 +4343,7 @@ eng_ector_buffer_wrap(void *data EINA_UNUSED, Evas *e, void *engine_image) if (!efl_domain_current_push(EFL_ID_DOMAIN_SHARED)) return NULL; buf = efl_add(EVAS_ECTOR_SOFTWARE_BUFFER_CLASS, NULL, - evas_ector_buffer_engine_image_set(efl_added, e, ie)); + evas_ector_buffer_engine_image_set(efl_added, data, ie)); efl_domain_current_pop(); return buf;