From 48a73d095434675adc3a8d0bf2e997769f30365f Mon Sep 17 00:00:00 2001 From: Nicola Fontana Date: Mon, 11 Mar 2013 15:27:19 +0100 Subject: [PATCH] cpml: removed CpmlPath CpmlPath was an alias for cairo_path_t: modified the code to directly use cairo_path_t and removed cpml_path related APIs. --- src/adg/adg-adim-private.h | 40 +++++++++---------- src/adg/adg-adim.c | 50 ++++++++++++------------ src/adg/adg-edges-private.h | 12 +++--- src/adg/adg-edges.c | 54 +++++++++++++------------- src/adg/adg-ldim-private.h | 36 ++++++++--------- src/adg/adg-ldim.c | 90 +++++++++++++++++++++---------------------- src/adg/adg-path-private.h | 4 +- src/adg/adg-path.c | 84 ++++++++++++++++++++-------------------- src/adg/adg-path.h | 4 +- src/adg/adg-rdim-private.h | 28 +++++++------- src/adg/adg-rdim.c | 40 +++++++++---------- src/adg/adg-trail.c | 94 ++++++++++++++++++++++----------------------- src/adg/adg-trail.h | 6 +-- src/cpml/cpml-segment.c | 43 +++------------------ src/cpml/cpml-segment.h | 6 +-- 15 files changed, 278 insertions(+), 313 deletions(-) diff --git a/src/adg/adg-adim-private.h b/src/adg/adg-adim-private.h index 204b0925..bacac1f0 100644 --- a/src/adg/adg-adim-private.h +++ b/src/adg/adg-adim-private.h @@ -25,7 +25,7 @@ G_BEGIN_DECLS /* - * The cpml.data array is structured in the following way: + * The cairo.data array is structured in the following way: * * [0] = MOVE_TO * [1] = arc start @@ -45,36 +45,36 @@ G_BEGIN_DECLS typedef struct _AdgADimPrivate AdgADimPrivate; struct _AdgADimPrivate { - AdgPoint *org1; - AdgPoint *org2; - gboolean has_extension1; - gboolean has_extension2; + AdgPoint *org1; + AdgPoint *org2; + gboolean has_extension1; + gboolean has_extension2; - AdgTrail *trail; - AdgMarker *marker1; - AdgMarker *marker2; + AdgTrail *trail; + AdgMarker *marker1; + AdgMarker *marker2; - gboolean geometry_arranged; - gdouble angle1, angle2; + gboolean geometry_arranged; + gdouble angle1, angle2; struct { - CpmlPair base1, base12, base2; - } point; + CpmlPair base1, base12, base2; + } point; struct { - CpmlPair from1, from2; - CpmlPair base1, base12, base2; - CpmlPair to1, to2; - } shift; + CpmlPair from1, from2; + CpmlPair base1, base12, base2; + CpmlPair to1, to2; + } shift; struct { - cairo_matrix_t global_map; - } quote; + cairo_matrix_t global_map; + } quote; struct { - CpmlPath path; + cairo_path_t path; cairo_path_data_t data[13]; - } cpml; + } cairo; }; G_END_DECLS diff --git a/src/adg/adg-adim.c b/src/adg/adg-adim.c index b9fde084..282b20cd 100644 --- a/src/adg/adg-adim.c +++ b/src/adg/adg-adim.c @@ -96,7 +96,7 @@ static gboolean _adg_get_info (AdgADim *adim, CpmlVector vector[], CpmlPair *center, gdouble *distance); -static CpmlPath * _adg_trail_callback (AdgTrail *trail, +static cairo_path_t * _adg_trail_callback (AdgTrail *trail, gpointer user_data); @@ -182,15 +182,15 @@ adg_adim_init(AdgADim *adim) data->has_extension1 = TRUE; data->has_extension2 = TRUE; - data->cpml.path.status = CAIRO_STATUS_INVALID_PATH_DATA; - data->cpml.path.data = data->cpml.data; - data->cpml.path.num_data = G_N_ELEMENTS(data->cpml.data); - data->cpml.path.data[0] = move_to; - data->cpml.path.data[2] = arc_to; - data->cpml.path.data[5] = move_to; - data->cpml.path.data[7] = line_to; - data->cpml.path.data[9] = move_to; - data->cpml.path.data[11] = line_to; + data->cairo.path.status = CAIRO_STATUS_INVALID_PATH_DATA; + data->cairo.path.data = data->cairo.data; + data->cairo.path.num_data = G_N_ELEMENTS(data->cairo.data); + data->cairo.path.data[0] = move_to; + data->cairo.path.data[2] = arc_to; + data->cairo.path.data[5] = move_to; + data->cairo.path.data[7] = line_to; + data->cairo.path.data[9] = move_to; + data->cairo.path.data[11] = line_to; data->trail = NULL; data->marker1 = NULL; @@ -828,7 +828,7 @@ _adg_arrange(AdgEntity *entity) _adg_update_entities(adim); - if (data->cpml.path.status == CAIRO_STATUS_SUCCESS) { + if (data->cairo.path.status == CAIRO_STATUS_SUCCESS) { AdgEntity *quote_entity = (AdgEntity *) quote; adg_entity_set_global_map(quote_entity, &data->quote.global_map); return; @@ -854,40 +854,40 @@ _adg_arrange(AdgEntity *entity) /* Combine points and global shifts to build the path */ pair.x = ref1.x + data->shift.from1.x; pair.y = ref1.y + data->shift.from1.y; - cpml_pair_to_cairo(&pair, &data->cpml.data[6]); + cpml_pair_to_cairo(&pair, &data->cairo.data[6]); pair.x = base1.x + data->shift.base1.x; pair.y = base1.y + data->shift.base1.y; - cpml_pair_to_cairo(&pair, &data->cpml.data[1]); + cpml_pair_to_cairo(&pair, &data->cairo.data[1]); pair.x += data->shift.to1.x; pair.y += data->shift.to1.y; - cpml_pair_to_cairo(&pair, &data->cpml.data[8]); + cpml_pair_to_cairo(&pair, &data->cairo.data[8]); pair.x = base12.x + data->shift.base12.x; pair.y = base12.y + data->shift.base12.y; - cpml_pair_to_cairo(&pair, &data->cpml.data[3]); + cpml_pair_to_cairo(&pair, &data->cairo.data[3]); pair.x = ref2.x + data->shift.from2.x; pair.y = ref2.y + data->shift.from2.y; - cpml_pair_to_cairo(&pair, &data->cpml.data[10]); + cpml_pair_to_cairo(&pair, &data->cairo.data[10]); pair.x = base2.x + data->shift.base2.x; pair.y = base2.y + data->shift.base2.y; - cpml_pair_to_cairo(&pair, &data->cpml.data[4]); + cpml_pair_to_cairo(&pair, &data->cairo.data[4]); pair.x += data->shift.to2.x; pair.y += data->shift.to2.y; - cpml_pair_to_cairo(&pair, &data->cpml.data[12]); + cpml_pair_to_cairo(&pair, &data->cairo.data[12]); /* Play with header lengths to show or hide the extension lines */ if (data->has_extension1) { - data->cpml.data[7].header.length = data->has_extension2 ? 2 : 6; + data->cairo.data[7].header.length = data->has_extension2 ? 2 : 6; } else { - data->cpml.data[2].header.length = data->has_extension2 ? 7 : 11; + data->cairo.data[2].header.length = data->has_extension2 ? 7 : 11; } - data->cpml.path.status = CAIRO_STATUS_SUCCESS; + data->cairo.path.status = CAIRO_STATUS_SUCCESS; /* Arrange the quote */ if (quote != NULL) { @@ -897,7 +897,7 @@ _adg_arrange(AdgEntity *entity) quote_entity = (AdgEntity *) quote; angle = adg_dim_quote_angle(dim, (data->angle1 + data->angle2) / 2 + G_PI_2); - cpml_pair_from_cairo(&pair, &data->cpml.data[3]); + cpml_pair_from_cairo(&pair, &data->cairo.data[3]); adg_alignment_set_factor_explicit(quote, 0.5, 0); @@ -1111,7 +1111,7 @@ _adg_unset_trail(AdgADim *adim) if (data->trail != NULL) adg_model_clear((AdgModel *) data->trail); - data->cpml.path.status = CAIRO_STATUS_INVALID_PATH_DATA; + data->cairo.path.status = CAIRO_STATUS_INVALID_PATH_DATA; } static void @@ -1216,7 +1216,7 @@ _adg_get_info(AdgADim *adim, CpmlVector vector[], return TRUE; } -static CpmlPath * +static cairo_path_t * _adg_trail_callback(AdgTrail *trail, gpointer user_data) { AdgADim *adim; @@ -1225,5 +1225,5 @@ _adg_trail_callback(AdgTrail *trail, gpointer user_data) adim = (AdgADim *) user_data; data = adim->data; - return &data->cpml.path; + return &data->cairo.path; } diff --git a/src/adg/adg-edges-private.h b/src/adg/adg-edges-private.h index 6ca8b552..e6694222 100644 --- a/src/adg/adg-edges-private.h +++ b/src/adg/adg-edges-private.h @@ -27,14 +27,14 @@ G_BEGIN_DECLS typedef struct _AdgEdgesPrivate AdgEdgesPrivate; struct _AdgEdgesPrivate { - AdgTrail *source; - gdouble axis_angle; - gdouble critical_angle; + AdgTrail *source; + gdouble axis_angle; + gdouble critical_angle; struct { - CpmlPath path; - GArray *array; - } cpml; + cairo_path_t path; + GArray *array; + } cairo; }; G_END_DECLS diff --git a/src/adg/adg-edges.c b/src/adg/adg-edges.c index 800c4fa7..164a1a09 100644 --- a/src/adg/adg-edges.c +++ b/src/adg/adg-edges.c @@ -82,9 +82,9 @@ static void _adg_set_property (GObject *object, const GValue *value, GParamSpec *pspec); static void _adg_clear (AdgModel *model); -static CpmlPath * _adg_get_cpml_path (AdgTrail *trail); +static cairo_path_t * _adg_get_cairo_path (AdgTrail *trail); static void _adg_unset_source (AdgEdges *edges); -static void _adg_clear_cpml_path (AdgEdges *edges); +static void _adg_clear_cairo_path (AdgEdges *edges); static GSList * _adg_get_vertices (CpmlSegment *segment, gdouble threshold); static GSList * _adg_optimize_vertices (GSList *vertices); @@ -114,7 +114,7 @@ adg_edges_class_init(AdgEdgesClass *klass) model_class->clear = _adg_clear; - trail_class->get_cpml_path = _adg_get_cpml_path; + trail_class->get_cairo_path = _adg_get_cairo_path; param = g_param_spec_object("source", P_("Source"), @@ -148,8 +148,8 @@ adg_edges_init(AdgEdges *edges) data->critical_angle = G_PI / 45; data->axis_angle = 0; - data->cpml.path.status = CAIRO_STATUS_INVALID_PATH_DATA; - data->cpml.array = NULL; + data->cairo.path.status = CAIRO_STATUS_INVALID_PATH_DATA; + data->cairo.array = NULL; edges->data = data; } @@ -168,7 +168,7 @@ _adg_dispose(GObject *object) static void _adg_finalize(GObject *object) { - _adg_clear_cpml_path((AdgEdges *) object); + _adg_clear_cairo_path((AdgEdges *) object); if (_ADG_OLD_OBJECT_CLASS->finalize != NULL) _ADG_OLD_OBJECT_CLASS->finalize(object); @@ -232,14 +232,14 @@ _adg_set_property(GObject *object, guint prop_id, tmp_double = g_value_get_double(value); if (data->axis_angle != tmp_double) { data->axis_angle = tmp_double; - _adg_clear_cpml_path(edges); + _adg_clear_cairo_path(edges); } break; case PROP_CRITICAL_ANGLE: tmp_double = g_value_get_double(value); if (data->critical_angle != tmp_double) { data->critical_angle = tmp_double; - _adg_clear_cpml_path(edges); + _adg_clear_cairo_path(edges); } break; default: @@ -416,14 +416,14 @@ adg_edges_get_critical_angle(AdgEdges *edges) static void _adg_clear(AdgModel *model) { - _adg_clear_cpml_path((AdgEdges *) model); + _adg_clear_cairo_path((AdgEdges *) model); if (_ADG_OLD_MODEL_CLASS->clear != NULL) _ADG_OLD_MODEL_CLASS->clear(model); } -static CpmlPath * -_adg_get_cpml_path(AdgTrail *trail) +static cairo_path_t * +_adg_get_cairo_path(AdgTrail *trail) { AdgEdges *edges; AdgEdgesPrivate *data; @@ -436,10 +436,10 @@ _adg_get_cpml_path(AdgTrail *trail) data = edges->data; /* Check for cached path */ - if (data->cpml.path.status == CAIRO_STATUS_SUCCESS) - return &data->cpml.path; + if (data->cairo.path.status == CAIRO_STATUS_SUCCESS) + return &data->cairo.path; - _adg_clear_cpml_path((AdgEdges *) trail); + _adg_clear_cairo_path((AdgEdges *) trail); if (data->source != NULL) { adg_trail_put_segment(data->source, 1, &segment); @@ -459,7 +459,7 @@ _adg_get_cpml_path(AdgTrail *trail) g_slist_foreach(vertices, (GFunc) cpml_pair_transform, &map); vertices = _adg_optimize_vertices(vertices); - data->cpml.array = _adg_path_build(vertices); + data->cairo.array = _adg_path_build(vertices); g_slist_foreach(vertices, (GFunc) g_free, NULL); g_slist_free(vertices); @@ -467,14 +467,14 @@ _adg_get_cpml_path(AdgTrail *trail) /* Reapply the inverse of the previous transformation to * move the vertices to their original positions */ cairo_matrix_invert(&map); - _adg_path_transform(data->cpml.array, &map); + _adg_path_transform(data->cairo.array, &map); - data->cpml.path.status = CAIRO_STATUS_SUCCESS; - data->cpml.path.data = (cairo_path_data_t *) (data->cpml.array)->data; - data->cpml.path.num_data = (data->cpml.array)->len; + data->cairo.path.status = CAIRO_STATUS_SUCCESS; + data->cairo.path.data = (cairo_path_data_t *) (data->cairo.array)->data; + data->cairo.path.num_data = (data->cairo.array)->len; } - return &data->cpml.path; + return &data->cairo.path; } static void @@ -484,18 +484,18 @@ _adg_unset_source(AdgEdges *edges) } static void -_adg_clear_cpml_path(AdgEdges *edges) +_adg_clear_cairo_path(AdgEdges *edges) { AdgEdgesPrivate *data = edges->data; - if (data->cpml.array != NULL) { - g_array_free(data->cpml.array, TRUE); - data->cpml.array = NULL; + if (data->cairo.array != NULL) { + g_array_free(data->cairo.array, TRUE); + data->cairo.array = NULL; } - data->cpml.path.status = CAIRO_STATUS_INVALID_PATH_DATA; - data->cpml.path.data = NULL; - data->cpml.path.num_data = 0; + data->cairo.path.status = CAIRO_STATUS_INVALID_PATH_DATA; + data->cairo.path.data = NULL; + data->cairo.path.num_data = 0; } /** diff --git a/src/adg/adg-ldim-private.h b/src/adg/adg-ldim-private.h index f4bd0cd2..9cc9c342 100644 --- a/src/adg/adg-ldim-private.h +++ b/src/adg/adg-ldim-private.h @@ -25,7 +25,7 @@ G_BEGIN_DECLS /* - * The cpml.data array is structured in the following way: + * The cairo.data array is structured in the following way: * * [0] = MOVE_TO * [1] = baseline start @@ -52,33 +52,33 @@ G_BEGIN_DECLS typedef struct _AdgLDimPrivate AdgLDimPrivate; struct _AdgLDimPrivate { - double direction; - gboolean has_extension1; - gboolean has_extension2; + double direction; + gboolean has_extension1; + gboolean has_extension2; - AdgTrail *trail; - AdgMarker *marker1; - AdgMarker *marker2; + AdgTrail *trail; + AdgMarker *marker1; + AdgMarker *marker2; struct { - gboolean is_arranged; - CpmlPair base1, base2; - gdouble distance; - } geometry; + gboolean is_arranged; + CpmlPair base1, base2; + gdouble distance; + } geometry; struct { - gboolean is_arranged; - CpmlPair from, base, to; - } shift; + gboolean is_arranged; + CpmlPair from, base, to; + } shift; struct { - cairo_matrix_t global_map; - } quote; + cairo_matrix_t global_map; + } quote; struct { - CpmlPath path; + cairo_path_t path; cairo_path_data_t data[20]; - } cpml; + } cairo; }; G_END_DECLS diff --git a/src/adg/adg-ldim.c b/src/adg/adg-ldim.c index 8369752e..d619ff51 100644 --- a/src/adg/adg-ldim.c +++ b/src/adg/adg-ldim.c @@ -102,7 +102,7 @@ static void _adg_update_extents (AdgLDim *ldim); static void _adg_unset_trail (AdgLDim *ldim); static void _adg_dispose_trail (AdgLDim *ldim); static void _adg_dispose_markers (AdgLDim *ldim); -static CpmlPath * _adg_trail_callback (AdgTrail *trail, +static cairo_path_t * _adg_trail_callback (AdgTrail *trail, gpointer user_data); @@ -168,19 +168,19 @@ adg_ldim_init(AdgLDim *ldim) data->has_extension1 = TRUE; data->has_extension2 = TRUE; - data->cpml.path.status = CAIRO_STATUS_INVALID_PATH_DATA; - data->cpml.path.data = data->cpml.data; - data->cpml.path.num_data = G_N_ELEMENTS(data->cpml.data); - data->cpml.path.data[0] = move_to; - data->cpml.path.data[2] = line_to; - data->cpml.path.data[4] = move_to; - data->cpml.path.data[6] = line_to; - data->cpml.path.data[8] = move_to; - data->cpml.path.data[10] = line_to; - data->cpml.path.data[12] = move_to; - data->cpml.path.data[14] = line_to; - data->cpml.path.data[16] = move_to; - data->cpml.path.data[18] = line_to; + data->cairo.path.status = CAIRO_STATUS_INVALID_PATH_DATA; + data->cairo.path.data = data->cairo.data; + data->cairo.path.num_data = G_N_ELEMENTS(data->cairo.data); + data->cairo.path.data[0] = move_to; + data->cairo.path.data[2] = line_to; + data->cairo.path.data[4] = move_to; + data->cairo.path.data[6] = line_to; + data->cairo.path.data[8] = move_to; + data->cairo.path.data[10] = line_to; + data->cairo.path.data[12] = move_to; + data->cairo.path.data[14] = line_to; + data->cairo.path.data[16] = move_to; + data->cairo.path.data[18] = line_to; data->trail = NULL; data->marker1 = NULL; @@ -579,7 +579,7 @@ _adg_arrange(AdgEntity *entity) _adg_update_entities(ldim); /* Check for cached result */ - if (data->cpml.path.status == CAIRO_STATUS_SUCCESS) { + if (data->cairo.path.status == CAIRO_STATUS_SUCCESS) { adg_entity_set_global_map((AdgEntity *) quote, &data->quote.global_map); return; } @@ -607,23 +607,23 @@ _adg_arrange(AdgEntity *entity) pair.x = ref1.x + data->shift.from.x; pair.y = ref1.y + data->shift.from.y; - cpml_pair_to_cairo(&pair, &data->cpml.data[13]); + cpml_pair_to_cairo(&pair, &data->cairo.data[13]); - cpml_pair_to_cairo(&base1, &data->cpml.data[1]); + cpml_pair_to_cairo(&base1, &data->cairo.data[1]); pair.x = base1.x + data->shift.to.x; pair.y = base1.y + data->shift.to.y; - cpml_pair_to_cairo(&pair, &data->cpml.data[15]); + cpml_pair_to_cairo(&pair, &data->cairo.data[15]); pair.x = ref2.x + data->shift.from.x; pair.y = ref2.y + data->shift.from.y; - cpml_pair_to_cairo(&pair, &data->cpml.data[17]); + cpml_pair_to_cairo(&pair, &data->cairo.data[17]); - cpml_pair_to_cairo(&base2, &data->cpml.data[3]); + cpml_pair_to_cairo(&base2, &data->cairo.data[3]); pair.x = base2.x + data->shift.to.x; pair.y = base2.y + data->shift.to.y; - cpml_pair_to_cairo(&pair, &data->cpml.data[19]); + cpml_pair_to_cairo(&pair, &data->cairo.data[19]); /* Calculate the outside segments */ if (outside) { @@ -631,48 +631,48 @@ _adg_arrange(AdgEntity *entity) CpmlVector vector; beyond = adg_dim_style_get_beyond(dim_style); - cpml_pair_from_cairo(&pair, &data->cpml.data[1]); + cpml_pair_from_cairo(&pair, &data->cairo.data[1]); - cpml_pair_from_cairo(&vector, &data->cpml.data[3]); + cpml_pair_from_cairo(&vector, &data->cairo.data[3]); vector.x -= pair.x; vector.y -= pair.y; cpml_vector_set_length(&vector, beyond); - cpml_pair_from_cairo(&pair, &data->cpml.data[1]); - cpml_pair_to_cairo(&pair, &data->cpml.data[5]); + cpml_pair_from_cairo(&pair, &data->cairo.data[1]); + cpml_pair_to_cairo(&pair, &data->cairo.data[5]); pair.x -= vector.x; pair.y -= vector.y; - cpml_pair_to_cairo(&pair, &data->cpml.data[7]); + cpml_pair_to_cairo(&pair, &data->cairo.data[7]); - cpml_pair_from_cairo(&pair, &data->cpml.data[3]); - cpml_pair_to_cairo(&pair, &data->cpml.data[11]); + cpml_pair_from_cairo(&pair, &data->cairo.data[3]); + cpml_pair_to_cairo(&pair, &data->cairo.data[11]); pair.x += vector.x; pair.y += vector.y; - cpml_pair_to_cairo(&pair, &data->cpml.data[9]); + cpml_pair_to_cairo(&pair, &data->cairo.data[9]); - data->cpml.data[2].header.length = 2; + data->cairo.data[2].header.length = 2; } else { - data->cpml.data[2].header.length = 10; + data->cairo.data[2].header.length = 10; } - data->cpml.data[10].header.length = 2; + data->cairo.data[10].header.length = 2; _adg_update_quote(ldim, &base1, &base2, &pos, detach, outside, adg_dim_style_get_quote_shift(dim_style)->x); /* Play with header lengths to show or hide the extension lines */ if (data->has_extension1) { - data->cpml.data[14].header.length = data->has_extension2 ? 2 : 6; + data->cairo.data[14].header.length = data->has_extension2 ? 2 : 6; } else { gint n = ! outside && ! detach ? 2 : 10; - data->cpml.data[14].header.length = 2; - data->cpml.data[n].header.length += 4; + data->cairo.data[14].header.length = 2; + data->cairo.data[n].header.length += 4; if (!data->has_extension2) - data->cpml.data[n].header.length += 4; + data->cairo.data[n].header.length += 4; } - data->cpml.path.status = CAIRO_STATUS_SUCCESS; + data->cairo.path.status = CAIRO_STATUS_SUCCESS; /* Update the markers, if present */ if (data->trail != NULL) { @@ -1000,12 +1000,12 @@ _adg_update_quote(AdgLDim *ldim, CpmlPair *base1, CpmlPair *base2, CpmlPair *pos /* Extends the base line to include the "quote_end" pair, * so a detached quote is properly underlined */ if (outside) { - to_extend = &data->cpml.data[on_side1 ? 7 : 9]; + to_extend = &data->cairo.data[on_side1 ? 7 : 9]; } else { - to_extend = &data->cpml.data[9]; - cpml_pair_to_cairo(&middle, &data->cpml.data[9]); - cpml_pair_to_cairo(on_side1 ? base1 : base2, &data->cpml.data[11]); - data->cpml.data[2].header.length = 6; + to_extend = &data->cairo.data[9]; + cpml_pair_to_cairo(&middle, &data->cairo.data[9]); + cpml_pair_to_cairo(on_side1 ? base1 : base2, &data->cairo.data[11]); + data->cairo.data[2].header.length = 6; } /* Extend the base line only if needed */ @@ -1082,7 +1082,7 @@ _adg_unset_trail(AdgLDim *ldim) if (data->trail != NULL) adg_model_clear((AdgModel *) data->trail); - data->cpml.path.status = CAIRO_STATUS_INVALID_PATH_DATA; + data->cairo.path.status = CAIRO_STATUS_INVALID_PATH_DATA; } static void @@ -1112,7 +1112,7 @@ _adg_dispose_markers(AdgLDim *ldim) } } -static CpmlPath * +static cairo_path_t * _adg_trail_callback(AdgTrail *trail, gpointer user_data) { AdgLDim *ldim; @@ -1121,5 +1121,5 @@ _adg_trail_callback(AdgTrail *trail, gpointer user_data) ldim = (AdgLDim *) user_data; data = ldim->data; - return &data->cpml.path; + return &data->cairo.path; } diff --git a/src/adg/adg-path-private.h b/src/adg/adg-path-private.h index cfad5347..4d61645c 100644 --- a/src/adg/adg-path-private.h +++ b/src/adg/adg-path-private.h @@ -59,9 +59,9 @@ struct _AdgPathPrivate { CpmlPair cp; struct { - CpmlPath path; + cairo_path_t path; GArray *array; - } cpml; + } cairo; CpmlPrimitive last; CpmlPrimitive over; diff --git a/src/adg/adg-path.c b/src/adg/adg-path.c index 410fb4cd..92abb187 100644 --- a/src/adg/adg-path.c +++ b/src/adg/adg-path.c @@ -22,15 +22,15 @@ * SECTION:adg-path * @short_description: The basic model representing a generic path * - * The #AdgPath model represents a virtual #CpmlPath: this class + * The #AdgPath model represents a virtual #cairo_path_t: this class * implements methods to create the path and provides additional * operations specific to technical drawings. * - * #AdgPath overrides the get_cpml_path() method of the parent + * #AdgPath overrides the get_cairo_path() method of the parent * #AdgTrail class, avoiding the need of an #AdgTrailCallback. * The path is constructed programmaticaly: keep in mind any - * method that modifies the path will invalidate the #CpmlPath - * returned by adg_trail_get_cpml_path(). + * method that modifies the path will invalidate the #cairo_path_t + * returned by adg_trail_get_cairo_path(). * * Although some of the provided methods are clearly based on the * original cairo path manipulation API, their behavior could be @@ -81,8 +81,8 @@ static void _adg_finalize (GObject *object); static void _adg_clear (AdgModel *model); static void _adg_clear_parent (AdgModel *model); static void _adg_changed (AdgModel *model); -static CpmlPath * _adg_get_cpml_path (AdgTrail *trail); -static CpmlPath * _adg_read_cpml_path (AdgPath *path); +static cairo_path_t * _adg_get_cairo_path (AdgTrail *trail); +static cairo_path_t * _adg_read_cairo_path (AdgPath *path); static gint _adg_primitive_length (CpmlPrimitiveType type); static void _adg_append_primitive (AdgPath *path, CpmlPrimitive *primitive); @@ -133,7 +133,7 @@ adg_path_class_init(AdgPathClass *klass) model_class->clear = _adg_clear; model_class->changed = _adg_changed; - trail_class->get_cpml_path = _adg_get_cpml_path; + trail_class->get_cairo_path = _adg_get_cairo_path; } static void @@ -143,7 +143,7 @@ adg_path_init(AdgPath *path) AdgPathPrivate); data->cp_is_valid = FALSE; - data->cpml.array = g_array_new(FALSE, FALSE, sizeof(cairo_path_data_t)); + data->cairo.array = g_array_new(FALSE, FALSE, sizeof(cairo_path_data_t)); data->operation.action = ADG_ACTION_NONE; path->data = data; @@ -158,7 +158,7 @@ _adg_finalize(GObject *object) path = (AdgPath *) object; data = path->data; - g_array_free(data->cpml.array, TRUE); + g_array_free(data->cairo.array, TRUE); _adg_clear_operation(path); if (_ADG_OLD_OBJECT_CLASS->finalize) @@ -469,34 +469,33 @@ adg_path_append_segment(AdgPath *path, const CpmlSegment *segment) data = path->data; _adg_clear_parent((AdgModel *) path); - data->cpml.array = g_array_append_vals(data->cpml.array, - segment->data, segment->num_data); + data->cairo.array = g_array_append_vals(data->cairo.array, + segment->data, segment->num_data); } /** - * adg_path_append_cpml_path: - * @path: an #AdgPath - * @cpml_path: the #cairo_path_t path to append + * adg_path_append_cairo_path: + * @path: an #AdgPath + * @cairo_path: (type gpointer): the #cairo_path_t path to append * - * Appends a whole #CpmlPath to @path. #CpmlPath is a superset of - * #cairo_path_t, so this function can be feeded with both. + * Appends a whole #cairo_path_t to @path. * * Since: 1.0 **/ void -adg_path_append_cpml_path(AdgPath *path, const CpmlPath *cpml_path) +adg_path_append_cairo_path(AdgPath *path, const cairo_path_t *cairo_path) { AdgPathPrivate *data; g_return_if_fail(ADG_IS_PATH(path)); - g_return_if_fail(cpml_path != NULL); + g_return_if_fail(cairo_path != NULL); data = path->data; _adg_clear_parent((AdgModel *) path); - data->cpml.array = g_array_append_vals(data->cpml.array, - cpml_path->data, - cpml_path->num_data); + data->cairo.array = g_array_append_vals(data->cairo.array, + cairo_path->data, + cairo_path->num_data); } /** @@ -957,7 +956,7 @@ _adg_clear(AdgModel *model) path = (AdgPath *) model; data = path->data; - g_array_set_size(data->cpml.array, 0); + g_array_set_size(data->cairo.array, 0); _adg_clear_operation(path); _adg_clear_parent(model); } @@ -978,24 +977,24 @@ _adg_changed(AdgModel *model) _ADG_OLD_MODEL_CLASS->changed(model); } -static CpmlPath * -_adg_get_cpml_path(AdgTrail *trail) +static cairo_path_t * +_adg_get_cairo_path(AdgTrail *trail) { _adg_clear_parent((AdgModel *) trail); - return _adg_read_cpml_path((AdgPath *) trail); + return _adg_read_cairo_path((AdgPath *) trail); } -static CpmlPath * -_adg_read_cpml_path(AdgPath *path) +static cairo_path_t * +_adg_read_cairo_path(AdgPath *path) { AdgPathPrivate *data = path->data; - /* Always regenerate the CpmlPath as it is a trivial operation */ - data->cpml.path.status = CAIRO_STATUS_SUCCESS; - data->cpml.path.data = (cairo_path_data_t *) (data->cpml.array)->data; - data->cpml.path.num_data = (data->cpml.array)->len; + /* Always regenerate the cairo_path_t as it is a trivial operation */ + data->cairo.path.status = CAIRO_STATUS_SUCCESS; + data->cairo.path.data = (cairo_path_data_t *) (data->cairo.array)->data; + data->cairo.path.num_data = (data->cairo.array)->len; - return &data->cpml.path; + return &data->cairo.path; } static gint @@ -1024,13 +1023,13 @@ _adg_append_primitive(AdgPath *path, CpmlPrimitive *current) _adg_do_operation(path, path_data); /* Append the path data to the internal path array */ - data->cpml.array = g_array_append_vals(data->cpml.array, + data->cairo.array = g_array_append_vals(data->cairo.array, path_data, length); /* Set path data to point to the recently appended cairo_path_data_t * primitive: the first struct is the header */ - path_data = (cairo_path_data_t *) (data->cpml.array)->data + - (data->cpml.array)->len - length; + path_data = (cairo_path_data_t *) (data->cairo.array)->data + + (data->cairo.array)->len - length; /* Store the over primitive */ memcpy(&data->over, &data->last, sizeof(CpmlPrimitive)); @@ -1129,25 +1128,25 @@ _adg_append_operation(AdgPath *path, AdgAction action, ...) CpmlSegment segment; CpmlPrimitive current; - length = data->cpml.array->len; + length = data->cairo.array->len; /* Ensure the close path primitive is not the only data */ g_return_val_if_fail(length > 1, FALSE); /* Allocate one more item once for all to accept the * conversion from a close to line-to primitive */ - data->cpml.array = g_array_set_size(data->cpml.array, length + 1); - path_data = (cairo_path_data_t *) data->cpml.array->data; - --data->cpml.array->len; + data->cairo.array = g_array_set_size(data->cairo.array, length + 1); + path_data = (cairo_path_data_t *) data->cairo.array->data; + --data->cairo.array->len; /* Set segment and current (the first primitive of segment) */ - cpml_segment_from_cairo(&segment, _adg_read_cpml_path(path)); + cpml_segment_from_cairo(&segment, _adg_read_cairo_path(path)); while (cpml_segment_next(&segment)) ; cpml_primitive_from_segment(¤t, &segment); /* Convert close path to a line-to primitive */ - ++data->cpml.array->len; + ++data->cairo.array->len; path_data[length - 1].header.type = CPML_LINE; path_data[length - 1].header.length = 2; path_data[length] = *current.org; @@ -1159,7 +1158,6 @@ _adg_append_operation(AdgPath *path, AdgAction action, ...) _adg_do_action(path, action, ¤t); } - return TRUE; } @@ -1174,7 +1172,7 @@ _adg_do_operation(AdgPath *path, cairo_path_data_t *path_data) data = path->data; action = data->operation.action; - cpml_segment_from_cairo(&segment, _adg_read_cpml_path(path)); + cpml_segment_from_cairo(&segment, _adg_read_cairo_path(path)); /* Construct the current primitive, that is the primitive to be * mixed with the last primitive with the specified operation. diff --git a/src/adg/adg-path.h b/src/adg/adg-path.h index a0b9d2e4..067fe4a0 100644 --- a/src/adg/adg-path.h +++ b/src/adg/adg-path.h @@ -60,7 +60,6 @@ const CpmlPrimitive * adg_path_last_primitive (AdgPath *path); const CpmlPrimitive * adg_path_over_primitive (AdgPath *path); - void adg_path_append (AdgPath *path, CpmlPrimitiveType type, ...); @@ -77,7 +76,8 @@ void adg_path_append_segment (AdgPath *path, const CpmlSegment *segment); void adg_path_append_cpml_path (AdgPath *path, - const CpmlPath *cpml_path); + const cairo_path_t + *cairo_path); void adg_path_move_to (AdgPath *path, const CpmlPair *pair); void adg_path_move_to_explicit (AdgPath *path, diff --git a/src/adg/adg-rdim-private.h b/src/adg/adg-rdim-private.h index dbf698d3..10828100 100644 --- a/src/adg/adg-rdim-private.h +++ b/src/adg/adg-rdim-private.h @@ -25,7 +25,7 @@ G_BEGIN_DECLS /* - * The cpml.data array is structured in the following way: + * The cairo.data array is structured in the following way: * * [0] = MOVE_TO * [1] = baseline start @@ -40,29 +40,29 @@ G_BEGIN_DECLS typedef struct _AdgRDimPrivate AdgRDimPrivate; struct _AdgRDimPrivate { - AdgTrail *trail; - AdgMarker *marker; + AdgTrail *trail; + AdgMarker *marker; - gboolean geometry_arranged; - gdouble radius; - gdouble angle; + gboolean geometry_arranged; + gdouble radius; + gdouble angle; struct { - CpmlPair base; - } point; + CpmlPair base; + } point; struct { - CpmlPair base; - } shift; + CpmlPair base; + } shift; struct { - cairo_matrix_t global_map; - } quote; + cairo_matrix_t global_map; + } quote; struct { - CpmlPath path; + cairo_path_t path; cairo_path_data_t data[8]; - } cpml; + } cairo; }; G_END_DECLS diff --git a/src/adg/adg-rdim.c b/src/adg/adg-rdim.c index 7ed37c7a..e9ff63bf 100644 --- a/src/adg/adg-rdim.c +++ b/src/adg/adg-rdim.c @@ -89,7 +89,7 @@ static void _adg_update_entities (AdgRDim *rdim); static void _adg_clear_trail (AdgRDim *rdim); static void _adg_dispose_trail (AdgRDim *rdim); static void _adg_dispose_marker (AdgRDim *rdim); -static CpmlPath * _adg_trail_callback (AdgTrail *trail, +static cairo_path_t * _adg_trail_callback (AdgTrail *trail, gpointer user_data); @@ -149,13 +149,13 @@ adg_rdim_init(AdgRDim *rdim) data->shift.base.x = data->shift.base.y = 0; cairo_matrix_init_identity(&data->quote.global_map); - data->cpml.path.status = CAIRO_STATUS_INVALID_PATH_DATA; - data->cpml.path.data = data->cpml.data; - data->cpml.path.num_data = G_N_ELEMENTS(data->cpml.data); - data->cpml.path.data[0] = move_to; - data->cpml.path.data[2] = line_to; - data->cpml.path.data[4] = move_to; - data->cpml.path.data[6] = line_to; + data->cairo.path.status = CAIRO_STATUS_INVALID_PATH_DATA; + data->cairo.path.data = data->cairo.data; + data->cairo.path.num_data = G_N_ELEMENTS(data->cairo.data); + data->cairo.path.data[0] = move_to; + data->cairo.path.data[2] = line_to; + data->cairo.path.data[4] = move_to; + data->cairo.path.data[6] = line_to; rdim->data = data; } @@ -397,7 +397,7 @@ _adg_arrange(AdgEntity *entity) _adg_update_entities(rdim); /* Check for cached result */ - if (data->cpml.path.status == CAIRO_STATUS_SUCCESS) { + if (data->cairo.path.status == CAIRO_STATUS_SUCCESS) { adg_entity_set_global_map(quote_entity, &data->quote.global_map); return; } @@ -419,10 +419,10 @@ _adg_arrange(AdgEntity *entity) base.y += data->shift.base.y; /* baseline start */ - cpml_pair_to_cairo(&base, &data->cpml.data[1]); + cpml_pair_to_cairo(&base, &data->cairo.data[1]); /* baseline end */ - cpml_pair_to_cairo(&ref2, &data->cpml.data[3]); + cpml_pair_to_cairo(&ref2, &data->cairo.data[3]); if (outside) { AdgDimStyle *dim_style; @@ -437,15 +437,15 @@ _adg_arrange(AdgEntity *entity) pair.x = ref2.x + vector.x; pair.y = ref2.y + vector.y; - data->cpml.data[2].header.length = 2; + data->cairo.data[2].header.length = 2; /* Outside segment start */ - cpml_pair_to_cairo(&pair, &data->cpml.data[5]); + cpml_pair_to_cairo(&pair, &data->cairo.data[5]); /* Outside segment end */ - cpml_pair_to_cairo(&ref2, &data->cpml.data[7]); + cpml_pair_to_cairo(&ref2, &data->cairo.data[7]); } else { - data->cpml.data[2].header.length = 6; + data->cairo.data[2].header.length = 6; } /* Arrange the quote */ @@ -454,7 +454,7 @@ _adg_arrange(AdgEntity *entity) adg_alignment_set_factor_explicit(quote, 1, 0); - cpml_pair_from_cairo(&pair, &data->cpml.data[1]); + cpml_pair_from_cairo(&pair, &data->cairo.data[1]); cairo_matrix_init_translate(&map, pair.x, pair.y); cairo_matrix_rotate(&map, data->angle); adg_entity_set_global_map(quote_entity, &map); @@ -464,7 +464,7 @@ _adg_arrange(AdgEntity *entity) adg_matrix_copy(&data->quote.global_map, &map); } - data->cpml.path.status = CAIRO_STATUS_SUCCESS; + data->cairo.path.status = CAIRO_STATUS_SUCCESS; /* Arrange the trail */ if (data->trail != NULL) { @@ -644,7 +644,7 @@ _adg_clear_trail(AdgRDim *rdim) if (data->trail != NULL) adg_model_clear((AdgModel *) data->trail); - data->cpml.path.status = CAIRO_STATUS_INVALID_PATH_DATA; + data->cairo.path.status = CAIRO_STATUS_INVALID_PATH_DATA; } static void @@ -669,7 +669,7 @@ _adg_dispose_marker(AdgRDim *rdim) } } -static CpmlPath * +static cairo_path_t * _adg_trail_callback(AdgTrail *trail, gpointer user_data) { AdgRDim *rdim; @@ -678,5 +678,5 @@ _adg_trail_callback(AdgTrail *trail, gpointer user_data) rdim = (AdgRDim *) user_data; data = rdim->data; - return &data->cpml.path; + return &data->cairo.path; } diff --git a/src/adg/adg-trail.c b/src/adg/adg-trail.c index 1907a94b..1c4d235c 100644 --- a/src/adg/adg-trail.c +++ b/src/adg/adg-trail.c @@ -20,9 +20,9 @@ /** * SECTION:adg-trail - * @short_description: A bare model built around #CpmlPath + * @short_description: A bare model built around #cairo_path_t * - * The #AdgTrail model is a really basic model built around the #CpmlPath + * The #AdgTrail model is a really basic model built around the #cairo_path_t * struct: for a full fledged path model consider using #AdgPath. * * A trail is a path model that demands all the implementation details to @@ -48,9 +48,9 @@ /** * AdgTrailClass: - * @get_cpml_path: virtual method to get the #CpmlPath bound to the trail. + * @get_cairo_path: virtual method to get the #cairo_path_t bound to the trail. * - * The default @get_cpml_path calls the #AdgTrailCallback callback passed + * The default @get_cairo_path calls the #AdgTrailCallback callback passed * to adg_trail_new() during construction. No caching is performed in * between. * @@ -62,12 +62,12 @@ * @trail: an #AdgTrail * @user_data: the general purpose pointer set by adg_trail_new() * - * This is the callback used to generate the #CpmlPath and it is - * called directly by adg_trail_cpml_path(). The caller owns + * This is the callback used to generate the #cairo_path_t and it is + * called directly by adg_trail_cairo_path(). The caller owns * the returned path, that is the finalization of the returned - * #CpmlPath should be made by the caller when appropriate. + * #cairo_path_t should be made by the caller when appropriate. * - * Returns: the #CpmlPath of this trail model + * Returns: the #cairo_path_t of this trail model * * Since: 1.0 **/ @@ -86,6 +86,7 @@ #define _ADG_OLD_OBJECT_CLASS ((GObjectClass *) adg_trail_parent_class) #define _ADG_OLD_MODEL_CLASS ((AdgModelClass *) adg_trail_parent_class) +#define EMPTY_PATH(p) ((p) == NULL || (p)->data == NULL || (p)->num_data <= 0) G_DEFINE_TYPE(AdgTrail, adg_trail, ADG_TYPE_MODEL) @@ -105,7 +106,7 @@ static void _adg_set_property (GObject *object, const GValue *value, GParamSpec *pspec); static void _adg_clear (AdgModel *model); -static CpmlPath * _adg_get_cpml_path (AdgTrail *trail); +static cairo_path_t * _adg_get_cairo_path (AdgTrail *trail); static GArray * _adg_arc_to_curves (GArray *array, const cairo_path_data_t *src, gdouble max_angle); @@ -129,7 +130,7 @@ adg_trail_class_init(AdgTrailClass *klass) model_class->clear = _adg_clear; - klass->get_cpml_path = _adg_get_cpml_path; + klass->get_cairo_path = _adg_get_cairo_path; param = g_param_spec_double("max-angle", P_("Max Angle"), @@ -209,10 +210,10 @@ _adg_set_property(GObject *object, guint prop_id, /** * adg_trail_new: - * @callback: (scope notified): the #CpmlPath constructor function + * @callback: (scope notified): the #cairo_path_t constructor function * @user_data: generic pointer to pass to the callback * - * Creates a new trail model. The #CpmlPath must be constructed by + * Creates a new trail model. The #cairo_path_t must be constructed by * the @callback function: #AdgTrail will not cache anything, so you * should implement any caching mechanism in the callback, if needed. * @@ -242,8 +243,8 @@ adg_trail_new(AdgTrailCallback callback, gpointer user_data) * Gets a pointer to the cairo path of @trail. The returned path is * owned by @trail and must be considered read-only. * - * This function gets the #CpmlPath of @trail by calling - * adg_trail_cpml_path() and converts its #CPML_ARC primitives, + * This function gets the #cairo_path_t of @trail by calling + * adg_trail_cairo_path() and converts its #CPML_ARC primitives, * not recognized by cairo, into approximated Bézier curves * primitives (#CPML_CURVE). The conversion is cached, so any further * request is O(1). This cache is cleared only by the @@ -258,7 +259,6 @@ adg_trail_get_cairo_path(AdgTrail *trail) { AdgTrailPrivate *data; cairo_path_t *cairo_path; - CpmlPath *cpml_path; GArray *dst; const cairo_path_data_t *p_src; int i; @@ -266,22 +266,21 @@ adg_trail_get_cairo_path(AdgTrail *trail) g_return_val_if_fail(ADG_IS_TRAIL(trail), NULL); data = trail->data; - cairo_path = &data->cairo_path; /* Check for cached result */ - if (cairo_path->data != NULL) - return cairo_path; + if (data->cairo_path.data != NULL) + return &data->cairo_path; - cpml_path = adg_trail_cpml_path(trail); - if (cpml_path_is_empty(cpml_path)) + cairo_path = adg_trail_cairo_path(trail); + if (EMPTY_PATH(cairo_path)) return NULL; dst = g_array_sized_new(FALSE, FALSE, - sizeof(cairo_path_data_t), cpml_path->num_data); + sizeof(cairo_path_data_t), cairo_path->num_data); - /* Cycle the CpmlPath and convert arcs to Bézier curves */ - for (i = 0; i < cpml_path->num_data; i += p_src->header.length) { - p_src = (const cairo_path_data_t *) cpml_path->data + i; + /* Cycle the cairo_path_t and convert arcs to Bézier curves */ + for (i = 0; i < cairo_path->num_data; i += p_src->header.length) { + p_src = (const cairo_path_data_t *) cairo_path->data + i; if ((CpmlPrimitiveType) p_src->header.type == CPML_ARC) dst = _adg_arc_to_curves(dst, p_src, data->max_angle); @@ -289,6 +288,7 @@ adg_trail_get_cairo_path(AdgTrail *trail) dst = g_array_append_vals(dst, p_src, p_src->header.length); } + cairo_path = &data->cairo_path; cairo_path->status = CAIRO_STATUS_SUCCESS; cairo_path->num_data = dst->len; cairo_path->data = (cairo_path_data_t *) g_array_free(dst, FALSE); @@ -297,12 +297,12 @@ adg_trail_get_cairo_path(AdgTrail *trail) } /** - * adg_trail_cpml_path: + * adg_trail_cairo_path: * @trail: an #AdgTrail * - * Gets the CPML path structure defined by @trail. The returned + * Gets the cairo path structure defined by @trail. The returned * value is managed by the #AdgTrail implementation, that is this - * function directly calls the #AdgTrailClass::get_cpml_path() + * function directly calls the #AdgTrailClass::get_cairo_path() * virtual method that any trail instance must have. * * Whenever used internally by the ADG project, the returned path @@ -313,24 +313,24 @@ adg_trail_get_cairo_path(AdgTrail *trail) * should be able to modify the trail where they are applied). * * Any further call to this method will probably make the pointer - * previously returned useless because the #CpmlPath could be - * relocated and the old #CpmlPath will likely contain rubbish. + * previously returned useless because the #cairo_path_t could be + * relocated and the old #cairo_path_t will likely contain rubbish. * - * Returns: (transfer none): a pointer to the #CpmlPath or %NULL on errors. + * Returns: (transfer none): a pointer to the #cairo_path_t or %NULL on errors. * * Since: 1.0 **/ -CpmlPath * -adg_trail_cpml_path(AdgTrail *trail) +cairo_path_t * +adg_trail_cairo_path(AdgTrail *trail) { AdgTrailClass *klass; AdgTrailPrivate *data; - CpmlPath *cpml_path; + cairo_path_t *cairo_path; g_return_val_if_fail(ADG_IS_TRAIL(trail), NULL); klass = ADG_TRAIL_GET_CLASS(trail); - if (klass->get_cpml_path == NULL) + if (klass->get_cairo_path == NULL) return NULL; data = trail->data; @@ -341,10 +341,10 @@ adg_trail_cpml_path(AdgTrail *trail) } data->in_construction = TRUE; - cpml_path = klass->get_cpml_path(trail); + cairo_path = klass->get_cairo_path(trail); data->in_construction = FALSE; - return cpml_path; + return cairo_path; } /** @@ -354,7 +354,7 @@ adg_trail_cpml_path(AdgTrail *trail) * @segment: the destination #CpmlSegment * * Convenient function to get a segment from @trail. The segment is - * got from the CPML path: check out adg_trail_cpml_path() for + * got from the cairo path: check out adg_trail_cairo_path() for * further information. * * When the segment is not found, either because @n_segment is out @@ -370,7 +370,7 @@ adg_trail_cpml_path(AdgTrail *trail) gboolean adg_trail_put_segment(AdgTrail *trail, guint n_segment, CpmlSegment *segment) { - CpmlPath *cpml_path; + cairo_path_t *cairo_path; gboolean found; CpmlSegment iterator; guint cnt; @@ -383,9 +383,9 @@ adg_trail_put_segment(AdgTrail *trail, guint n_segment, CpmlSegment *segment) return FALSE; } - cpml_path = adg_trail_cpml_path(trail); - found = !cpml_path_is_empty(cpml_path) && - cpml_segment_from_cairo(&iterator, cpml_path); + cairo_path = adg_trail_cairo_path(trail); + found = ! EMPTY_PATH(cairo_path) && + cpml_segment_from_cairo(&iterator, cairo_path); for (cnt = 1; found && cnt < n_segment; ++cnt) found = cpml_segment_next(&iterator); @@ -421,13 +421,13 @@ adg_trail_get_extents(AdgTrail *trail) data = trail->data; if (!data->extents.is_defined) { - CpmlPath *cpml_path; + cairo_path_t *cairo_path; CpmlSegment segment; CpmlExtents extents; - cpml_path = adg_trail_cpml_path(trail); - if (!cpml_path_is_empty(cpml_path) && - cpml_segment_from_cairo(&segment, cpml_path)) { + cairo_path = adg_trail_cairo_path(trail); + if (! EMPTY_PATH(cairo_path) && + cpml_segment_from_cairo(&segment, cairo_path)) { do { cpml_segment_put_extents(&segment, &extents); cpml_extents_add(&data->extents, &extents); @@ -539,8 +539,8 @@ _adg_clear(AdgModel *model) _ADG_OLD_MODEL_CLASS->clear(model); } -static CpmlPath * -_adg_get_cpml_path(AdgTrail *trail) +static cairo_path_t * +_adg_get_cairo_path(AdgTrail *trail) { AdgTrailPrivate *data = trail->data; diff --git a/src/adg/adg-trail.h b/src/adg/adg-trail.h index 47f89303..7303f356 100644 --- a/src/adg/adg-trail.h +++ b/src/adg/adg-trail.h @@ -39,7 +39,7 @@ G_BEGIN_DECLS typedef struct _AdgTrail AdgTrail; typedef struct _AdgTrailClass AdgTrailClass; -typedef CpmlPath * (*AdgTrailCallback) (AdgTrail *trail, gpointer user_data); +typedef cairo_path_t * (*AdgTrailCallback) (AdgTrail *trail, gpointer user_data); struct _AdgTrail { /*< private >*/ @@ -53,7 +53,7 @@ struct _AdgTrailClass { /*< public >*/ /* Virtual table */ - CpmlPath * (*get_cpml_path) (AdgTrail *trail); + cairo_path_t * (*get_cairo_path) (AdgTrail *trail); }; @@ -62,7 +62,7 @@ AdgTrail * adg_trail_new (AdgTrailCallback callback, gpointer user_data); const cairo_path_t *adg_trail_get_cairo_path (AdgTrail *trail); -CpmlPath * adg_trail_cpml_path (AdgTrail *trail); +cairo_path_t * adg_trail_cairo_path (AdgTrail *trail); gboolean adg_trail_put_segment (AdgTrail *trail, guint n_segment, CpmlSegment *segment); diff --git a/src/cpml/cpml-segment.c b/src/cpml/cpml-segment.c index ed685cdc..3ea7878d 100644 --- a/src/cpml/cpml-segment.c +++ b/src/cpml/cpml-segment.c @@ -36,7 +36,7 @@ * instead a bunch of pointers to the original #cairo_path_t struct: * modifying data throught this struct also changes the original path. * - * Every #CpmlPath struct can contain more than one segment: the CPML + * Every #cairo_path_t struct can contain more than one segment: the CPML * library provides iteration APIs to browse the segments of a path. * Use cpml_segment_reset() to reset the iterator at the start of the * cairo path (will point the first segment) and cpml_segment_next() @@ -50,21 +50,8 @@ **/ /** - * CpmlPath: - * - * This is another name for the #cairo_path_t type. Although phisically - * they are the same struct, #CpmlPath conceptually embodies an important - * difference: it is a cairo path that can embed %CPML_ARC primitives. - * This is not a native cairo primitive and having two different data - * types is a good way to make clear when a function expect or not - * embedded arc-to primitives. - * - * Since: 1.0 - **/ - -/** * CpmlSegment: - * @path: the source #CpmlPath struct + * @path: the source #cairo_path_t struct * @data: the data points of the segment; the first primitive * will always be a %CPML_MOVE * @num_data: size of @data @@ -92,10 +79,10 @@ static int reshape (CpmlSegment *segment); /** * cpml_segment_from_cairo: - * @segment: (out): a #CpmlSegment - * @path: (in): the source #CpmlPath + * @segment: a #CpmlSegment + * @path: (type gpointer): the source #cairo_path_t * - * Builds a CpmlSegment from a #CpmlPath structure. This operation + * Builds a CpmlSegment from a #cairo_path_t structure. This operation * involves stripping the duplicate %CPML_MOVE primitives at the * start of the path and setting num_data * field to the end of the contiguous line, that is when another @@ -113,7 +100,7 @@ static int reshape (CpmlSegment *segment); * Since: 1.0 **/ int -cpml_segment_from_cairo(CpmlSegment *segment, CpmlPath *path) +cpml_segment_from_cairo(CpmlSegment *segment, cairo_path_t *path) { /* The cairo path should be defined and in a perfect state */ if (path == NULL || path->num_data == 0 || @@ -143,24 +130,6 @@ cpml_segment_copy(CpmlSegment *segment, const CpmlSegment *src) } /** - * cpml_path_is_empty: - * @path: a #CpmlPath (or a #cairo_path_t) pointer - * - * Checks if @path is empty. An invalid path is considered empty. - * - * Returns: (type gboolean): %1 if the path is empty or invalid, - * %0 otherwise - * - * Since: 1.0 - **/ -int -cpml_path_is_empty(const CpmlPath *path) -{ - cairo_path_t *cairo_path = (cairo_path_t *) path; - return path == NULL || cairo_path->data == NULL || cairo_path->num_data <= 0; -} - -/** * cpml_segment_reset: * @segment: a #CpmlSegment * diff --git a/src/cpml/cpml-segment.h b/src/cpml/cpml-segment.h index bf00d640..9f6d5b26 100644 --- a/src/cpml/cpml-segment.h +++ b/src/cpml/cpml-segment.h @@ -29,20 +29,18 @@ CAIRO_BEGIN_DECLS -typedef cairo_path_t CpmlPath; typedef struct _CpmlSegment CpmlSegment; struct _CpmlSegment { /*< public >*/ - CpmlPath *path; + cairo_path_t *path; cairo_path_data_t *data; int num_data; }; -int cpml_path_is_empty (const CpmlPath *path); int cpml_segment_from_cairo (CpmlSegment *segment, - CpmlPath *path); + cairo_path_t *path); void cpml_segment_copy (CpmlSegment *segment, const CpmlSegment *src); void cpml_segment_reset (CpmlSegment *segment); -- 2.11.4.GIT