cedric pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=f6a1694181dccf03fa6d05bdf48bc4758179d84f
commit f6a1694181dccf03fa6d05bdf48bc4758179d84f Author: Subhransu Mohanty <sub.moha...@samsung.com> Date: Fri Nov 6 10:47:37 2015 +0900 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 <ced...@osg.samsung.com> --- src/lib/efl/interfaces/efl_gfx_shape.c | 42 +++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/src/lib/efl/interfaces/efl_gfx_shape.c b/src/lib/efl/interfaces/efl_gfx_shape.c index 49b6e5f..212e25b 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.c +++ b/src/lib/efl/interfaces/efl_gfx_shape.c @@ -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; - - _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); + // check for invalid rectangle + if (w <=0 || h<= 0) + return; + + 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); } --