1
0
Fork 0

clutter: Drop unnused cairo specific APIs

The APIs are not used by Mutter and GNOME Shell, so they should be safe to remove

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3040>
This commit is contained in:
Bilal Elmoussaoui 2023-06-01 16:32:30 +01:00 committed by Marge Bot
parent 2b58efbcbb
commit 9a6ee5d7c7
3 changed files with 0 additions and 213 deletions

View file

@ -735,117 +735,6 @@ 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.
*/
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.
*/
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

View file

@ -122,9 +122,6 @@ CLUTTER_EXPORT
void clutter_path_add_node (ClutterPath *path,
const ClutterPathNode *node);
CLUTTER_EXPORT
void clutter_path_add_cairo_path (ClutterPath *path,
const cairo_path_t *cpath);
CLUTTER_EXPORT
guint clutter_path_get_n_nodes (ClutterPath *path);
CLUTTER_EXPORT
void clutter_path_get_node (ClutterPath *path,
@ -155,9 +152,6 @@ gboolean clutter_path_set_description (ClutterPath *path,
CLUTTER_EXPORT
void clutter_path_clear (ClutterPath *path);
CLUTTER_EXPORT
void clutter_path_to_cairo_path (ClutterPath *path,
cairo_t *cr);
CLUTTER_EXPORT
guint clutter_path_get_position (ClutterPath *path,
gdouble progress,
ClutterKnot *position);

View file

@ -395,101 +395,6 @@ path_test_get_description (CallbackData *data)
return ret;
}
static gboolean
path_test_convert_to_cairo_path (CallbackData *data)
{
cairo_surface_t *surface;
cairo_t *cr;
cairo_path_t *cpath;
guint i, j;
ClutterKnot path_start = { 0, 0 }, last_point = { 0, 0 };
/* Create a temporary image surface and context to hold the cairo
path */
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 10, 10);
cr = cairo_create (surface);
/* Convert to a cairo path */
clutter_path_to_cairo_path (data->path, cr);
/* Get a copy of the cairo path data */
cpath = cairo_copy_path (cr);
/* Convert back to a clutter path */
clutter_path_clear (data->path);
clutter_path_add_cairo_path (data->path, cpath);
/* The relative nodes will have been converted to absolute so we
need to reflect this in the node array for comparison */
for (i = 0; i < data->n_nodes; i++)
{
switch (data->nodes[i].type)
{
case CLUTTER_PATH_MOVE_TO:
path_start = last_point = data->nodes[i].points[0];
break;
case CLUTTER_PATH_LINE_TO:
last_point = data->nodes[i].points[0];
break;
case CLUTTER_PATH_CURVE_TO:
last_point = data->nodes[i].points[2];
break;
case CLUTTER_PATH_REL_MOVE_TO:
last_point.x += data->nodes[i].points[0].x;
last_point.y += data->nodes[i].points[0].y;
data->nodes[i].points[0] = last_point;
data->nodes[i].type = CLUTTER_PATH_MOVE_TO;
path_start = last_point;
break;
case CLUTTER_PATH_REL_LINE_TO:
last_point.x += data->nodes[i].points[0].x;
last_point.y += data->nodes[i].points[0].y;
data->nodes[i].points[0] = last_point;
data->nodes[i].type = CLUTTER_PATH_LINE_TO;
break;
case CLUTTER_PATH_REL_CURVE_TO:
for (j = 0; j < 3; j++)
{
data->nodes[i].points[j].x += last_point.x;
data->nodes[i].points[j].y += last_point.y;
}
last_point = data->nodes[i].points[2];
data->nodes[i].type = CLUTTER_PATH_CURVE_TO;
break;
case CLUTTER_PATH_CLOSE:
last_point = path_start;
/* Cairo always adds a move to after every close so we need
to insert one here. Since Cairo commit 166453c1abf2 it
doesn't seem to do this anymore so will assume that if
Cairo's minor version is >= 11 then it includes that
commit */
if (cairo_version () < CAIRO_VERSION_ENCODE (1, 11, 0))
{
memmove (data->nodes + i + 2, data->nodes + i + 1,
(data->n_nodes - i - 1) * sizeof (ClutterPathNode));
data->nodes[i + 1].type = CLUTTER_PATH_MOVE_TO;
data->nodes[i + 1].points[0] = last_point;
data->n_nodes++;
}
break;
}
}
/* Free the cairo resources */
cairo_path_destroy (cpath);
cairo_destroy (cr);
cairo_surface_destroy (surface);
return TRUE;
}
static gboolean
float_fuzzy_equals (float fa, float fb)
{
@ -652,7 +557,6 @@ path_tests[] =
{ "Replace a node", path_test_replace },
{ "Set description", path_test_set_description },
{ "Get description", path_test_get_description },
{ "Convert to cairo path and back", path_test_convert_to_cairo_path },
{ "Clear", path_test_clear },
{ "Get position", path_test_get_position },
{ "Check node boxed type", path_test_boxed_type },