forked from enlightenment/efl
efl: update append_rect implementation.
This now generate more optimized path by reducing the use of arc and switching to only line whenever possible. Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
parent
d5719aad9d
commit
f6a1694181
|
@ -1150,22 +1150,32 @@ _efl_gfx_shape_append_rect(Eo *obj, Efl_Gfx_Shape_Data *pd,
|
|||
double x, double y, double w, double h,
|
||||
double rx, double ry)
|
||||
{
|
||||
// clamp the x and y radius value.
|
||||
if (rx > w/2) rx = w/2;
|
||||
if (ry > h/2) ry = h/2;
|
||||
// check for invalid rectangle
|
||||
if (w <=0 || h<= 0)
|
||||
return;
|
||||
|
||||
_efl_gfx_shape_append_move_to(obj, pd, x, y + ry);
|
||||
// Top left corner
|
||||
_efl_gfx_shape_append_arc_to(obj, pd, x + rx, y, rx, ry, 0, EINA_FALSE, EINA_TRUE);
|
||||
_efl_gfx_shape_append_line_to(obj, pd, x + w - rx, y);
|
||||
// Top right corner
|
||||
_efl_gfx_shape_append_arc_to(obj, pd, x + w, y + ry, rx, ry, 0, EINA_FALSE, EINA_TRUE);
|
||||
_efl_gfx_shape_append_line_to(obj, pd, x + w, y + h - ry);
|
||||
// Bottom right corner
|
||||
_efl_gfx_shape_append_arc_to(obj, pd, x + w - rx, y + h, rx, ry, 0, EINA_FALSE, EINA_TRUE);
|
||||
_efl_gfx_shape_append_line_to(obj, pd, x + rx, y + h);
|
||||
// Bottom left corner
|
||||
_efl_gfx_shape_append_arc_to(obj, pd, x, y + h - ry, rx, ry, 0, EINA_FALSE, EINA_TRUE);
|
||||
if (rx <=0 || ry<=0)
|
||||
{
|
||||
// add a normal rect.
|
||||
_efl_gfx_shape_append_move_to(obj, pd, x, y);
|
||||
_efl_gfx_shape_append_line_to(obj, pd, x, y + h);
|
||||
_efl_gfx_shape_append_line_to(obj, pd, x + w, y + h);
|
||||
_efl_gfx_shape_append_line_to(obj, pd, x + w, y);
|
||||
_efl_gfx_shape_append_close(obj, pd);
|
||||
return;
|
||||
}
|
||||
|
||||
// clamp the rx and ry radius value.
|
||||
rx = 2*rx;
|
||||
ry = 2*ry;
|
||||
if (rx > w) rx = w;
|
||||
if (ry > h) ry = h;
|
||||
|
||||
_efl_gfx_shape_append_move_to(obj, pd, x, y + h/2);
|
||||
_efl_gfx_shape_append_arc(obj, pd, x, y + h - ry, rx, ry, 180, 90);
|
||||
_efl_gfx_shape_append_arc(obj, pd, x + w - rx, y + h - ry, rx, ry, 270, 90);
|
||||
_efl_gfx_shape_append_arc(obj, pd, x + w - rx, y, rx, ry, 0, 90);
|
||||
_efl_gfx_shape_append_arc(obj, pd, x, y, rx, ry, 90, 90);
|
||||
_efl_gfx_shape_append_close(obj, pd);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue