From db518c8736f09215fbb31dfb1f6b2464c0c31332 Mon Sep 17 00:00:00 2001 From: Chris Lord Date: Tue, 10 Jun 2008 10:05:12 +0000 Subject: [PATCH] * clutter/cogl/common/cogl-primitives.c: (_cogl_path_arc): Draw as expected when end angle is lower than start angle (i.e. do not swap the angles). This aligns with cairo behaviour. --- ChangeLog | 6 +++++ clutter/cogl/common/cogl-primitives.c | 34 ++++++++++++++++++++------- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index f6836719c..bb070995f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-06-10 Chris Lord + + * clutter/cogl/common/cogl-primitives.c: (_cogl_path_arc): + Draw as expected when end angle is lower than start angle (i.e. do not + swap the angles). This aligns with cairo behaviour. + 2008-06-10 Tommi Komulainen Bug#959 - Multiple minor improvements diff --git a/clutter/cogl/common/cogl-primitives.c b/clutter/cogl/common/cogl-primitives.c index 2018c4444..43d78b85f 100644 --- a/clutter/cogl/common/cogl-primitives.c +++ b/clutter/cogl/common/cogl-primitives.c @@ -207,7 +207,6 @@ _cogl_path_arc (ClutterFixed center_x, guint move_first) { ClutterAngle a = 0x0; - ClutterAngle temp = 0x0; ClutterFixed cosa = 0x0; ClutterFixed sina = 0x0; ClutterFixed px = 0x0; @@ -221,16 +220,10 @@ _cogl_path_arc (ClutterFixed center_x, if (angle_step < 0x0) angle_step = -angle_step; - if (angle_2 < angle_1) - { - temp = angle_1; - angle_1 = angle_2; - angle_2 = temp; - } - /* Walk the arc by given step */ - for (a = angle_1; a < angle_2; a += angle_step) + a = angle_1; + while (a != angle_2) { cosa = clutter_cosi (a); sina = clutter_sini (a); @@ -242,7 +235,30 @@ _cogl_path_arc (ClutterFixed center_x, cogl_path_move_to (px, py); else cogl_path_line_to (px, py); + + if (G_LIKELY (angle_2 > angle_1)) + { + a += angle_step; + if (a > angle_2) + a = angle_2; + } + else + { + a -= angle_step; + if (a < angle_2) + a = angle_2; + } } + + /* Make sure the final point is drawn */ + + cosa = clutter_cosi (angle_2); + sina = clutter_sini (angle_2); + + px = center_x + CFX_MUL (cosa, radius_x); + py = center_y + CFX_MUL (sina, radius_y); + + cogl_path_line_to (px, py); } void