efl_gfx_fill: Use Eina.Rectangle for fill (EO)

This commit is contained in:
Jean-Philippe Andre 2017-09-13 17:41:20 +09:00
parent 83ea35541c
commit 89733b22f6
7 changed files with 34 additions and 43 deletions

View File

@ -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)
{

View File

@ -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

View File

@ -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.]]
}
}
}

View File

@ -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;
}

View File

@ -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

View File

@ -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

View File

@ -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"