From 89733b22f6287f0c9126acc93a2b1dae590ae4dd Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Wed, 13 Sep 2017 17:41:20 +0900 Subject: [PATCH] efl_gfx_fill: Use Eina.Rectangle for fill (EO) --- src/lib/edje/edje_calc.c | 4 ++-- src/lib/edje/edje_private.h | 4 +--- src/lib/efl/interfaces/efl_gfx_fill.eo | 10 ++++------ src/lib/elementary/elm_transit.c | 18 ++++++++++-------- src/lib/evas/canvas/evas_image_legacy.c | 8 +++++++- src/lib/evas/canvas/evas_object_image.c | 15 +++++---------- src/lib/evas/canvas/evas_object_vg.c | 18 +++++------------- 7 files changed, 34 insertions(+), 43 deletions(-) diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c index 8c811478b7..9bdedcaa0b 100644 --- a/src/lib/edje/edje_calc.c +++ b/src/lib/edje/edje_calc.c @@ -3616,7 +3616,7 @@ _edje_proxy_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edj } } - efl_gfx_fill_set(ep->object, p3->type.common->fill.x, p3->type.common->fill.y, p3->type.common->fill.w, p3->type.common->fill.h); + efl_gfx_fill_set(ep->object, p3->type.common->fill); efl_image_smooth_scale_set(ep->object, p3->smooth); evas_object_image_source_visible_set(ep->object, chosen_desc->proxy.source_visible); evas_object_image_source_clip_set(ep->object, chosen_desc->proxy.source_clip); @@ -3656,7 +3656,7 @@ _edje_image_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edj set->entry->border.scale_by : p3->type.common->spec.image.border_scale_by; } - efl_gfx_fill_set(ep->object, p3->type.common->fill.x, p3->type.common->fill.y, p3->type.common->fill.w, p3->type.common->fill.h); + efl_gfx_fill_set(ep->object, p3->type.common->fill); efl_image_smooth_scale_set(ep->object, p3->smooth); if (chosen_desc->image.border.scale) { diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h index b98e02af13..f0e7f00252 100644 --- a/src/lib/edje/edje_private.h +++ b/src/lib/edje/edje_private.h @@ -1844,9 +1844,7 @@ typedef struct _Edje_Calc_Params_Type_Node Edje_Calc_Params_Type_Node; struct _Edje_Calc_Params_Type_Common { - struct { - int x, y, w, h; // 16 - } fill; // 16 + Eina_Rectangle fill; // 16 union { struct { unsigned short l, r, t, b; // 8 diff --git a/src/lib/efl/interfaces/efl_gfx_fill.eo b/src/lib/efl/interfaces/efl_gfx_fill.eo index f0280c0074..385f79fce5 100644 --- a/src/lib/efl/interfaces/efl_gfx_fill.eo +++ b/src/lib/efl/interfaces/efl_gfx_fill.eo @@ -1,3 +1,5 @@ +import eina_types; + interface Efl.Gfx.Fill { [[Efl graphics fill interface]] methods { @@ -36,12 +38,8 @@ interface Efl.Gfx.Fill { set {} get {} values { - x: int; [[The x coordinate (from the top left corner of the bound - image) to start drawing from.]] - y: int; [[The y coordinate (from the top left corner of the bound - image) to start drawing from.]] - w: int; [[The width the bound image will be displayed at.]] - h: int; [[The height the bound image will be displayed at.]] + fill: Eina.Rectangle; [[The top-left corner to start drawing from + as well as the size at which the bound image will be displayed.]] } } } diff --git a/src/lib/elementary/elm_transit.c b/src/lib/elementary/elm_transit.c index 0ff99faed3..69c9604c7a 100644 --- a/src/lib/elementary/elm_transit.c +++ b/src/lib/elementary/elm_transit.c @@ -480,7 +480,6 @@ _recover_image_uv(Evas_Object *obj, Evas_Map *map, Eina_Bool revert, Eina_Bool b //Need to handle uvs only for image objects int iw, ih; int x, y, w, h; - int fill_x, fill_y, fill_w, fill_h; const char *type = evas_object_type_get(obj); if ((!type) || (strcmp(type, "image"))) return EINA_FALSE; @@ -507,16 +506,19 @@ _recover_image_uv(Evas_Object *obj, Evas_Map *map, Eina_Bool revert, Eina_Bool b //Zooming image fill area. else { - efl_gfx_fill_get(obj, &fill_x, &fill_y, &fill_w, &fill_h); + Eina_Rectangle fill; + + fill = efl_gfx_fill_get(obj); efl_gfx_size_get(obj, &w, &h); - double rate_x = (double) w / (double) fill_w; - double rate_y = (double) h / (double) fill_h; - double rate_x2 = (double) iw / (double) fill_w; - double rate_y2 = (double) ih / (double) fill_h; + EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_rectangle_is_valid(&fill), EINA_FALSE); + double rate_x = (double) w / (double) fill.w; + double rate_y = (double) h / (double) fill.h; + double rate_x2 = (double) iw / (double) fill.w; + double rate_y2 = (double) ih / (double) fill.h; - x = -(int)((double) fill_x * rate_x2); - y = -(int)((double) fill_y * rate_y2); + x = -(int)((double) fill.x * rate_x2); + y = -(int)((double) fill.y * rate_y2); w = (int)(((double) iw) * rate_x) + x; h = (int)(((double) ih) * rate_y) + y; } diff --git a/src/lib/evas/canvas/evas_image_legacy.c b/src/lib/evas/canvas/evas_image_legacy.c index 9ac97408d7..9b7557128d 100644 --- a/src/lib/evas/canvas/evas_image_legacy.c +++ b/src/lib/evas/canvas/evas_image_legacy.c @@ -90,8 +90,14 @@ evas_object_image_fill_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h) { + Eina_Rectangle r; + EVAS_IMAGE_API(obj); - efl_gfx_fill_get(obj, x, y, w, h); + r = efl_gfx_fill_get(obj); + if (x) *x = r.x; + if (y) *y = r.y; + if (w) *w = r.w; + if (h) *h = r.h; } EAPI void diff --git a/src/lib/evas/canvas/evas_object_image.c b/src/lib/evas/canvas/evas_object_image.c index e3f428d91b..452311ec0f 100644 --- a/src/lib/evas/canvas/evas_object_image.c +++ b/src/lib/evas/canvas/evas_object_image.c @@ -668,23 +668,18 @@ _evas_image_fill_set(Eo *eo_obj, Evas_Image_Data *o, int x, int y, int w, int h) } EOLIAN static void -_efl_canvas_image_internal_efl_gfx_fill_fill_set(Eo *eo_obj, Evas_Image_Data *o, - int x, int y, int w, int h) +_efl_canvas_image_internal_efl_gfx_fill_fill_set(Eo *eo_obj, Evas_Image_Data *o, Eina_Rectangle fill) { // Should (0,0,0,0) reset the filled flag to true? o->filled = EINA_FALSE; o->filled_set = EINA_TRUE; - _evas_image_fill_set(eo_obj, o, x, y, w, h); + _evas_image_fill_set(eo_obj, o, fill.x, fill.y, fill.w, fill.h); } -EOLIAN static void -_efl_canvas_image_internal_efl_gfx_fill_fill_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o, - int *x, int *y, int *w, int *h) +EOLIAN static Eina_Rectangle +_efl_canvas_image_internal_efl_gfx_fill_fill_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o) { - if (x) *x = o->cur->fill.x; - if (y) *y = o->cur->fill.y; - if (w) *w = o->cur->fill.w; - if (h) *h = o->cur->fill.h; + return o->cur->fill; } EOLIAN static void diff --git a/src/lib/evas/canvas/evas_object_vg.c b/src/lib/evas/canvas/evas_object_vg.c index c3edc9dac9..19a4b45d83 100644 --- a/src/lib/evas/canvas/evas_object_vg.c +++ b/src/lib/evas/canvas/evas_object_vg.c @@ -418,23 +418,15 @@ _evas_vg_efl_gfx_view_view_size_set(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, } void -_evas_vg_efl_gfx_fill_fill_set(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, - int x, int y, int w, int h) +_evas_vg_efl_gfx_fill_fill_set(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, Eina_Rectangle fill) { - pd->fill.x = x; - pd->fill.y = y; - pd->fill.w = w; - pd->fill.h = h; + pd->fill = fill; } -void -_evas_vg_efl_gfx_fill_fill_get(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, - int *x, int *y, int *w, int *h) +Eina_Rectangle +_evas_vg_efl_gfx_fill_fill_get(Eo *obj EINA_UNUSED, Evas_VG_Data *pd) { - if (x) *x = pd->fill.x; - if (y) *y = pd->fill.y; - if (w) *w = pd->fill.w; - if (h) *h = pd->fill.h; + return pd->fill; } #include "evas_vg.eo.c"