mirror of
https://github.com/brl/mutter.git
synced 2024-11-10 07:56:14 -05:00
Add clutter_path_to_cairo_path and clutter_path_add_cairo_path
See bug #1325. Added doc for new cairo path functions to clutter-sections.txt
This commit is contained in:
parent
0e1a3c2124
commit
a462d19e14
@ -736,6 +736,121 @@ clutter_path_add_node (ClutterPath *path,
|
||||
clutter_path_add_node_full (path, node_full);
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_path_add_cairo_path:
|
||||
* @path: a #ClutterPath
|
||||
* @cpath: a Cairo path
|
||||
*
|
||||
* Add the nodes of the Cairo path to the end of @path.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
void
|
||||
clutter_path_add_cairo_path (ClutterPath *path,
|
||||
const cairo_path_t *cpath)
|
||||
{
|
||||
int num_data;
|
||||
const cairo_path_data_t *p;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_PATH (path));
|
||||
g_return_if_fail (cpath != NULL);
|
||||
|
||||
/* Iterate over each command in the cairo path */
|
||||
for (num_data = cpath->num_data, p = cpath->data;
|
||||
num_data > 0;
|
||||
num_data -= p->header.length, p += p->header.length)
|
||||
{
|
||||
switch (p->header.type)
|
||||
{
|
||||
case CAIRO_PATH_MOVE_TO:
|
||||
g_assert (p->header.length >= 2);
|
||||
|
||||
clutter_path_add_move_to (path, p[1].point.x, p[1].point.y);
|
||||
break;
|
||||
|
||||
case CAIRO_PATH_LINE_TO:
|
||||
g_assert (p->header.length >= 2);
|
||||
|
||||
clutter_path_add_line_to (path, p[1].point.x, p[1].point.y);
|
||||
break;
|
||||
|
||||
case CAIRO_PATH_CURVE_TO:
|
||||
g_assert (p->header.length >= 4);
|
||||
|
||||
clutter_path_add_curve_to (path,
|
||||
p[1].point.x, p[1].point.y,
|
||||
p[2].point.x, p[2].point.y,
|
||||
p[3].point.x, p[3].point.y);
|
||||
break;
|
||||
|
||||
case CAIRO_PATH_CLOSE_PATH:
|
||||
clutter_path_add_close (path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_path_add_node_to_cairo_path (const ClutterPathNode *node,
|
||||
gpointer data)
|
||||
{
|
||||
cairo_t *cr = data;
|
||||
|
||||
switch (node->type)
|
||||
{
|
||||
case CLUTTER_PATH_MOVE_TO:
|
||||
cairo_move_to (cr, node->points[0].x, node->points[0].y);
|
||||
break;
|
||||
|
||||
case CLUTTER_PATH_LINE_TO:
|
||||
cairo_line_to (cr, node->points[0].x, node->points[0].y);
|
||||
break;
|
||||
|
||||
case CLUTTER_PATH_CURVE_TO:
|
||||
cairo_curve_to (cr,
|
||||
node->points[0].x, node->points[0].y,
|
||||
node->points[1].x, node->points[1].y,
|
||||
node->points[2].x, node->points[2].y);
|
||||
break;
|
||||
|
||||
case CLUTTER_PATH_REL_MOVE_TO:
|
||||
cairo_rel_move_to (cr, node->points[0].x, node->points[0].y);
|
||||
break;
|
||||
|
||||
case CLUTTER_PATH_REL_LINE_TO:
|
||||
cairo_rel_line_to (cr, node->points[0].x, node->points[0].y);
|
||||
break;
|
||||
|
||||
case CLUTTER_PATH_REL_CURVE_TO:
|
||||
cairo_rel_curve_to (cr,
|
||||
node->points[0].x, node->points[0].y,
|
||||
node->points[1].x, node->points[1].y,
|
||||
node->points[2].x, node->points[2].y);
|
||||
break;
|
||||
|
||||
case CLUTTER_PATH_CLOSE:
|
||||
cairo_close_path (cr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_path_to_cairo_path:
|
||||
* @path: a #ClutterPath
|
||||
* @cr: a Cairo context
|
||||
*
|
||||
* Add the nodes of the ClutterPath to the path in the Cairo context.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
void
|
||||
clutter_path_to_cairo_path (ClutterPath *path,
|
||||
cairo_t *cr)
|
||||
{
|
||||
g_return_if_fail (CLUTTER_IS_PATH (path));
|
||||
g_return_if_fail (cr != NULL);
|
||||
|
||||
clutter_path_foreach (path, clutter_path_add_node_to_cairo_path, cr);
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_path_get_n_nodes:
|
||||
* @path: a #ClutterPath
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <clutter/clutter-types.h>
|
||||
#include <cairo/cairo.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@ -195,6 +196,9 @@ gboolean clutter_path_add_string (ClutterPath *path,
|
||||
void clutter_path_add_node (ClutterPath *path,
|
||||
const ClutterPathNode *node);
|
||||
|
||||
void clutter_path_add_cairo_path (ClutterPath *path,
|
||||
const cairo_path_t *cpath);
|
||||
|
||||
guint clutter_path_get_n_nodes (ClutterPath *path);
|
||||
|
||||
void clutter_path_get_node (ClutterPath *path,
|
||||
@ -225,6 +229,9 @@ gboolean clutter_path_set_description (ClutterPath *path,
|
||||
|
||||
void clutter_path_clear (ClutterPath *path);
|
||||
|
||||
void clutter_path_to_cairo_path (ClutterPath *path,
|
||||
cairo_t *cr);
|
||||
|
||||
guint clutter_path_get_position (ClutterPath *path,
|
||||
guint alpha,
|
||||
ClutterKnot *position);
|
||||
|
@ -702,6 +702,7 @@ clutter_path_add_rel_curve_to
|
||||
clutter_path_add_close
|
||||
clutter_path_add_string
|
||||
clutter_path_add_node
|
||||
clutter_path_add_cairo_path
|
||||
clutter_path_get_n_nodes
|
||||
clutter_path_get_node
|
||||
clutter_path_get_nodes
|
||||
@ -711,6 +712,7 @@ clutter_path_remove_node
|
||||
clutter_path_replace_node
|
||||
clutter_path_get_description
|
||||
clutter_path_set_description
|
||||
clutter_path_to_cairo_path
|
||||
clutter_path_clear
|
||||
clutter_path_get_position
|
||||
clutter_path_get_length
|
||||
|
Loading…
Reference in New Issue
Block a user