[clutter] Migrated ClutterPathNode to use ClutterPoint
- From: Erick Pérez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter] Migrated ClutterPathNode to use ClutterPoint
- Date: Sat, 4 May 2013 14:48:46 +0000 (UTC)
commit b1fa6434e1bc0f19e91479f8209a9ffa3f1846a8
Author: Erick Pérez Castellanos <erick red gmail com>
Date: Sat Apr 13 13:01:10 2013 -0400
Migrated ClutterPathNode to use ClutterPoint
Removed the use of ClutterKnot almost everywhere
Updated casting to get the data from the variable arguments list
clutter/clutter-bezier.c | 4 +-
clutter/clutter-bezier.h | 4 +-
clutter/clutter-path-constraint.c | 2 +-
clutter/clutter-path.c | 89 ++++++++++++++++++++++---------------
clutter/clutter-path.h | 43 +++++++++---------
clutter/clutter-types.h | 2 +-
tests/conform/path.c | 4 +-
7 files changed, 83 insertions(+), 65 deletions(-)
---
diff --git a/clutter/clutter-bezier.c b/clutter/clutter-bezier.c
index 304d051..aeefe4d 100644
--- a/clutter/clutter-bezier.c
+++ b/clutter/clutter-bezier.c
@@ -143,7 +143,7 @@ _clutter_bezier_clone_and_move (const ClutterBezier *b,
void
_clutter_bezier_advance (const ClutterBezier *b,
gfloat L,
- ClutterKnot *knot)
+ ClutterPoint *knot)
{
gfloat t;
t = L;
@@ -231,7 +231,7 @@ _clutter_bezier_init (ClutterBezier *b,
*/
void
_clutter_bezier_adjust (ClutterBezier *b,
- ClutterKnot *knot,
+ ClutterPoint *knot,
guint indx)
{
gfloat x[4], y[4];
diff --git a/clutter/clutter-bezier.h b/clutter/clutter-bezier.h
index 885372f..6be13c1 100644
--- a/clutter/clutter-bezier.h
+++ b/clutter/clutter-bezier.h
@@ -42,7 +42,7 @@ ClutterBezier *_clutter_bezier_clone_and_move (const ClutterBezier *b,
void _clutter_bezier_advance (const ClutterBezier *b,
gfloat L,
- ClutterKnot *knot);
+ ClutterPoint *knot);
void _clutter_bezier_init (ClutterBezier *b,
gfloat x_0,
@@ -55,7 +55,7 @@ void _clutter_bezier_init (ClutterBezier *b,
gfloat y_3);
void _clutter_bezier_adjust (ClutterBezier *b,
- ClutterKnot *knot,
+ ClutterPoint *knot,
guint indx);
gfloat _clutter_bezier_get_length (const ClutterBezier *b);
diff --git a/clutter/clutter-path-constraint.c b/clutter/clutter-path-constraint.c
index 3e953bc..13ce670 100644
--- a/clutter/clutter-path-constraint.c
+++ b/clutter/clutter-path-constraint.c
@@ -97,7 +97,7 @@ clutter_path_constraint_update_allocation (ClutterConstraint *constraint,
{
ClutterPathConstraint *self = CLUTTER_PATH_CONSTRAINT (constraint);
gfloat width, height;
- ClutterKnot position;
+ ClutterPoint position;
guint knot_id;
if (self->path == NULL)
diff --git a/clutter/clutter-path.c b/clutter/clutter-path.c
index 86aea54..d4740d5 100644
--- a/clutter/clutter-path.c
+++ b/clutter/clutter-path.c
@@ -6,6 +6,7 @@
* Authored By Matthew Allum <mallum openedhand com>
*
* Copyright (C) 2008 Intel Corporation
+ * Copyright (C) 2013 Erick Pérez Castellanos <erick red gmail com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -342,7 +343,15 @@ clutter_path_add_node_full (ClutterPath *path,
priv->nodes_dirty = TRUE;
}
-/* Helper function to make the rest of teh add_* functions shorter */
+/*
+ * clutter_path_add_node_helper:
+ * @path: A #ClutterPath
+ * @type: The node type
+ * @num_coords: The number of coords passed
+ * @...: The value of each coordinate, a float value, single precision
+ *
+ * Helper function to make the rest of the add_* functions shorter
+ */
static void
clutter_path_add_node_helper (ClutterPath *path,
ClutterPathNodeType type,
@@ -361,8 +370,8 @@ clutter_path_add_node_helper (ClutterPath *path,
for (i = 0; i < num_coords; i++)
{
- node->k.points[i].x = va_arg (ap, gint);
- node->k.points[i].y = va_arg (ap, gint);
+ node->k.points[i].x = va_arg (ap, double);
+ node->k.points[i].y = va_arg (ap, double);
}
va_end (ap);
@@ -384,8 +393,8 @@ clutter_path_add_node_helper (ClutterPath *path,
*/
void
clutter_path_add_move_to (ClutterPath *path,
- gint x,
- gint y)
+ gfloat x,
+ gfloat y)
{
g_return_if_fail (CLUTTER_IS_PATH (path));
@@ -405,8 +414,8 @@ clutter_path_add_move_to (ClutterPath *path,
*/
void
clutter_path_add_rel_move_to (ClutterPath *path,
- gint x,
- gint y)
+ gfloat x,
+ gfloat y)
{
g_return_if_fail (CLUTTER_IS_PATH (path));
@@ -426,8 +435,8 @@ clutter_path_add_rel_move_to (ClutterPath *path,
*/
void
clutter_path_add_line_to (ClutterPath *path,
- gint x,
- gint y)
+ gfloat x,
+ gfloat y)
{
g_return_if_fail (CLUTTER_IS_PATH (path));
@@ -447,8 +456,8 @@ clutter_path_add_line_to (ClutterPath *path,
*/
void
clutter_path_add_rel_line_to (ClutterPath *path,
- gint x,
- gint y)
+ gfloat x,
+ gfloat y)
{
g_return_if_fail (CLUTTER_IS_PATH (path));
@@ -473,12 +482,12 @@ clutter_path_add_rel_line_to (ClutterPath *path,
*/
void
clutter_path_add_curve_to (ClutterPath *path,
- gint x_1,
- gint y_1,
- gint x_2,
- gint y_2,
- gint x_3,
- gint y_3)
+ gfloat x_1,
+ gfloat y_1,
+ gfloat x_2,
+ gfloat y_2,
+ gfloat x_3,
+ gfloat y_3)
{
g_return_if_fail (CLUTTER_IS_PATH (path));
@@ -505,12 +514,12 @@ clutter_path_add_curve_to (ClutterPath *path,
*/
void
clutter_path_add_rel_curve_to (ClutterPath *path,
- gint x_1,
- gint y_1,
- gint x_2,
- gint y_2,
- gint x_3,
- gint y_3)
+ gfloat x_1,
+ gfloat y_1,
+ gfloat x_2,
+ gfloat y_2,
+ gfloat x_3,
+ gfloat y_3)
{
g_return_if_fail (CLUTTER_IS_PATH (path));
@@ -541,9 +550,10 @@ clutter_path_add_close (ClutterPath *path)
static gboolean
clutter_path_parse_number (const gchar **pin,
gboolean allow_comma,
- gint *ret)
+ gfloat *ret)
{
gint val = 0;
+ gint fract = 0;
gboolean negative = FALSE;
gint digit_count = 0;
const gchar *p = *pin;
@@ -588,6 +598,7 @@ clutter_path_parse_number (const gchar **pin,
digit_count = 0;
while (clutter_path_isdigit (*p))
{
+ fract = fract * 10.0 + *p - '0';
digit_count++;
p++;
}
@@ -600,6 +611,12 @@ clutter_path_parse_number (const gchar **pin,
*pin = p;
*ret = negative ? -val : val;
+ /* Adding fractional part */
+ if (fract != 0)
+ {
+ *ret += (gfloat) fract / pow (10, digit_count);
+ }
+
return TRUE;
}
@@ -1236,7 +1253,7 @@ clutter_path_get_description (ClutterPath *path)
g_string_append_c (str, letter);
for (i = 0; i < params; i++)
- g_string_append_printf (str, " %i %i",
+ g_string_append_printf (str, " %f %f",
node->k.points[i].x,
node->k.points[i].y);
}
@@ -1245,8 +1262,8 @@ clutter_path_get_description (ClutterPath *path)
}
static guint
-clutter_path_node_distance (const ClutterKnot *start,
- const ClutterKnot *end)
+clutter_path_node_distance (const ClutterPoint *start,
+ const ClutterPoint *end)
{
gint64 x_d, y_d;
float t;
@@ -1254,7 +1271,7 @@ clutter_path_node_distance (const ClutterKnot *start,
g_return_val_if_fail (start != NULL, 0);
g_return_val_if_fail (end != NULL, 0);
- if (clutter_knot_equal (start, end))
+ if (clutter_point_equals (start, end))
return 0;
x_d = end->x - start->x;
@@ -1274,9 +1291,9 @@ clutter_path_ensure_node_data (ClutterPath *path)
if (priv->nodes_dirty)
{
GSList *l;
- ClutterKnot last_position = { 0, 0 };
- ClutterKnot loop_start = { 0, 0 };
- ClutterKnot points[3];
+ ClutterPoint last_position = { 0, 0 };
+ ClutterPoint loop_start = { 0, 0 };
+ ClutterPoint points[3];
priv->total_length = 0;
@@ -1340,7 +1357,7 @@ clutter_path_ensure_node_data (ClutterPath *path)
}
}
else
- memcpy (points, node->k.points, sizeof (ClutterKnot) * 3);
+ memcpy (points, node->k.points, sizeof (ClutterPoint) * 3);
_clutter_bezier_init (node->bezier,
last_position.x, last_position.y,
@@ -1387,9 +1404,9 @@ clutter_path_ensure_node_data (ClutterPath *path)
*
*/
guint
-clutter_path_get_position (ClutterPath *path,
- gdouble progress,
- ClutterKnot *position)
+clutter_path_get_position (ClutterPath *path,
+ gdouble progress,
+ ClutterPoint *position)
{
ClutterPathPrivate *priv;
GSList *l;
@@ -1407,7 +1424,7 @@ clutter_path_get_position (ClutterPath *path,
something better */
if (priv->nodes == NULL)
{
- memset (position, 0, sizeof (ClutterKnot));
+ memset (position, 0, sizeof (ClutterPoint));
return 0;
}
diff --git a/clutter/clutter-path.h b/clutter/clutter-path.h
index 218141f..8bd3ff0 100644
--- a/clutter/clutter-path.h
+++ b/clutter/clutter-path.h
@@ -6,6 +6,7 @@
* Authored By Matthew Allum <mallum openedhand com>
*
* Copyright (C) 2008 Intel Corporation
+ * Copyright (C) 2013 Erick Pérez Castellanos <erick red gmail com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -91,31 +92,31 @@ GType clutter_path_get_type (void) G_GNUC_CONST;
ClutterPath *clutter_path_new (void);
ClutterPath *clutter_path_new_with_description (const gchar *desc);
void clutter_path_add_move_to (ClutterPath *path,
- gint x,
- gint y);
+ gfloat x,
+ gfloat y);
void clutter_path_add_rel_move_to (ClutterPath *path,
- gint x,
- gint y);
+ gfloat x,
+ gfloat y);
void clutter_path_add_line_to (ClutterPath *path,
- gint x,
- gint y);
+ gfloat x,
+ gfloat y);
void clutter_path_add_rel_line_to (ClutterPath *path,
- gint x,
- gint y);
+ gfloat x,
+ gfloat y);
void clutter_path_add_curve_to (ClutterPath *path,
- gint x_1,
- gint y_1,
- gint x_2,
- gint y_2,
- gint x_3,
- gint y_3);
+ gfloat x_1,
+ gfloat y_1,
+ gfloat x_2,
+ gfloat y_2,
+ gfloat x_3,
+ gfloat y_3);
void clutter_path_add_rel_curve_to (ClutterPath *path,
- gint x_1,
- gint y_1,
- gint x_2,
- gint y_2,
- gint x_3,
- gint y_3);
+ gfloat x_1,
+ gfloat y_1,
+ gfloat x_2,
+ gfloat y_2,
+ gfloat x_3,
+ gfloat y_3);
void clutter_path_add_close (ClutterPath *path);
gboolean clutter_path_add_string (ClutterPath *path,
const gchar *str);
@@ -147,7 +148,7 @@ void clutter_path_to_cairo_path (ClutterPath *path,
cairo_t *cr);
guint clutter_path_get_position (ClutterPath *path,
gdouble progress,
- ClutterKnot *position);
+ ClutterPoint *position);
guint clutter_path_get_length (ClutterPath *path);
G_END_DECLS
diff --git a/clutter/clutter-types.h b/clutter/clutter-types.h
index 670507b..65b5e8c 100644
--- a/clutter/clutter-types.h
+++ b/clutter/clutter-types.h
@@ -556,7 +556,7 @@ struct _ClutterPathNode
{
ClutterPathNodeType type;
- ClutterKnot points[3];
+ ClutterPoint points[3];
};
GType clutter_path_node_get_type (void) G_GNUC_CONST;
diff --git a/tests/conform/path.c b/tests/conform/path.c
index b292ac9..7ab6a2e 100644
--- a/tests/conform/path.c
+++ b/tests/conform/path.c
@@ -402,7 +402,7 @@ path_test_convert_to_cairo_path (CallbackData *data)
cairo_t *cr;
cairo_path_t *cpath;
guint i, j;
- ClutterKnot path_start = { 0, 0 }, last_point = { 0, 0 };
+ ClutterPoint path_start = { 0, 0 }, last_point = { 0, 0 };
/* Create a temporary image surface and context to hold the cairo
path */
@@ -531,7 +531,7 @@ path_test_get_position (CallbackData *data)
for (i = 0; i < G_N_ELEMENTS (values); i += 3)
{
- ClutterKnot pos;
+ ClutterPoint pos;
clutter_path_get_position (data->path,
values[i],
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]