From 5a35e6babcff11280aac48c697a339d449388662 Mon Sep 17 00:00:00 2001 From: Wonki Kim Date: Wed, 8 Jun 2016 17:46:55 +0900 Subject: [PATCH] efl_gfx_shape: Improve coordinate cacluation of vector graphic Improvements have been already applied in Tizen 2.4 to resolve the problem that the renderer don't draw a circle properly, when a radius of the circle is odd. Then this commit will resolve the same problem in Tizen 3.0. Change-Id: Ibf856375c97ea811d4946fad0a1fad6d1f818451 Signed-off-by: Wonki Kim --- src/lib/efl/interfaces/efl_gfx_shape.c | 64 ++++++++++++---------------------- 1 file changed, 23 insertions(+), 41 deletions(-) diff --git a/src/lib/efl/interfaces/efl_gfx_shape.c b/src/lib/efl/interfaces/efl_gfx_shape.c index 184f39e..09b4bb4 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.c +++ b/src/lib/efl/interfaces/efl_gfx_shape.c @@ -823,8 +823,8 @@ typedef struct _Bezier typedef struct _Point { - int x; - int y; + double x; + double y; }Point; static @@ -938,8 +938,8 @@ _efl_gfx_t_for_arc_angle(double angle) } static void -_find_ellipse_coords(int x, int y, int w, int h, double angle, double length, - Point* start_point, Point *end_point) +_find_ellipse_coords(double x, double y, double w, double h, double angle, double length, + Point* start_point, Point *end_point) { if (!w || !h ) { @@ -950,8 +950,8 @@ _find_ellipse_coords(int x, int y, int w, int h, double angle, double length, return; } - int w2 = w / 2; - int h2 = h / 2; + double w2 = w / 2; + double h2 = h / 2; double angles[2] = { angle, angle + length }; Point *points[2] = { start_point, end_point }; @@ -985,8 +985,8 @@ _find_ellipse_coords(int x, int y, int w, int h, double angle, double length, // top quadrants if (quadrant == 0 || quadrant == 1) py = -py; - int cx = x+w/2; - int cy = y+h/2; + double cx = x+w/2; + double cy = y+h/2; points[i]->x = cx + w2 * px; points[i]->y = cy + h2 * py; } @@ -994,16 +994,16 @@ _find_ellipse_coords(int x, int y, int w, int h, double angle, double length, //// The return value is the starting point of the arc static -Point _curves_for_arc(int x, int y, int w, int h, +Point _curves_for_arc(double x, double y, double w, double h, double start_angle, double sweep_length, Point *curves, int *point_count) { *point_count = 0; - int w2 = w / 2; - int w2k = w2 * PATH_KAPPA; + double w2 = w / 2; + double w2k = w2 * PATH_KAPPA; - int h2 = h / 2; - int h2k = h2 * PATH_KAPPA; + double h2 = h / 2; + double h2k = h2 * PATH_KAPPA; Point points[16] = { @@ -1147,11 +1147,6 @@ _efl_gfx_shape_append_arc(Eo *obj, Efl_Gfx_Shape_Data *pd, { int point_count; Point pts[15]; - // FIXME: make the radius even, as the default - // renderer unable to generate a perfect arc in case of odd radius. - // remove the below line once the rle generation is fixed for the same. - if (((int)w & 1)) w = w-1; - if (((int)h & 1)) h = h-1; Point curve_start = _curves_for_arc(x, y, w, h, start_angle, sweep_length, pts, &point_count); int i; @@ -1186,11 +1181,6 @@ _efl_gfx_shape_append_circle(Eo *obj, Efl_Gfx_Shape_Data *pd, double xc, double yc, double radius) { _efl_gfx_shape_append_arc(obj, pd, xc - radius, yc - radius, 2*radius, 2*radius, 0, 360); -#if 0 - _efl_gfx_shape_append_move_to(obj, pd, xc - radius, yc); - _efl_gfx_shape_append_arc_to(obj, pd, xc + radius, yc, radius, radius, 0, EINA_TRUE, EINA_TRUE); - _efl_gfx_shape_append_arc_to(obj, pd, xc - radius, yc, radius, radius, 0, EINA_TRUE, EINA_TRUE); -#endif } static void @@ -1198,6 +1188,16 @@ _efl_gfx_shape_append_rect(Eo *obj, Efl_Gfx_Shape_Data *pd, double x, double y, double w, double h, double rx, double ry) { + if (!rx || !ry) + { + _efl_gfx_shape_append_move_to(obj, pd, x, y); + _efl_gfx_shape_append_line_to(obj, pd, x + w, y); + _efl_gfx_shape_append_line_to(obj, pd, x + w, y + h); + _efl_gfx_shape_append_line_to(obj, pd, x, y + h); + _efl_gfx_shape_append_close(obj, pd); + + return; + } // clamp the rx and ry radius value. rx = 2*rx; ry = 2*ry; @@ -1209,24 +1209,6 @@ _efl_gfx_shape_append_rect(Eo *obj, Efl_Gfx_Shape_Data *pd, _efl_gfx_shape_append_arc(obj, pd, x + w - rx, y, rx, ry, 90, -90); _efl_gfx_shape_append_arc(obj, pd, x + w - rx, y + h - ry, rx, ry, 0, -90); _efl_gfx_shape_append_arc(obj, pd, x, y + h - ry, rx, ry, 270, -90); -#if 0 - // 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); -#endif _efl_gfx_shape_append_close(obj, pd); } -- 2.7.4