[gtk/curve-ops: 103/109] Add gsk_curve_reverse
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/curve-ops: 103/109] Add gsk_curve_reverse
- Date: Sat, 26 Dec 2020 16:49:30 +0000 (UTC)
commit 14e3ac8fd768e149bc92f0b53703c4bb2ff589c6
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Dec 13 00:42:53 2020 -0500
Add gsk_curve_reverse
This will be used in stroking.
gsk/gskcurve.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++---
gsk/gskcurveprivate.h | 2 ++
2 files changed, 56 insertions(+), 3 deletions(-)
---
diff --git a/gsk/gskcurve.c b/gsk/gskcurve.c
index 775a3c6da4..0d2ca03b2a 100644
--- a/gsk/gskcurve.c
+++ b/gsk/gskcurve.c
@@ -70,6 +70,8 @@ struct _GskCurveClass
void (* offset) (const GskCurve *curve,
float distance,
GskCurve *offset_curve);
+ void (* reverse) (const GskCurve *curve,
+ GskCurve *reverse);
};
static void
@@ -313,6 +315,17 @@ gsk_line_curve_offset (const GskCurve *curve,
gsk_curve_init (offset_curve, gsk_pathop_encode (GSK_PATH_LINE, p));
}
+static void
+gsk_line_curve_reverse (const GskCurve *curve,
+ GskCurve *reverse)
+{
+ const GskLineCurve *self = &curve->line;
+
+ reverse->op = GSK_PATH_LINE;
+ reverse->line.points[0] = self->points[1];
+ reverse->line.points[1] = self->points[0];
+}
+
static const GskCurveClass GSK_LINE_CURVE_CLASS = {
gsk_line_curve_init,
gsk_line_curve_init_foreach,
@@ -329,7 +342,8 @@ static const GskCurveClass GSK_LINE_CURVE_CLASS = {
gsk_line_curve_get_start_end_tangent,
gsk_line_curve_get_bounds,
gsk_line_curve_get_bounds,
- gsk_line_curve_offset
+ gsk_line_curve_offset,
+ gsk_line_curve_reverse
};
/** CURVE **/
@@ -676,6 +690,20 @@ gsk_curve_curve_offset (const GskCurve *curve,
gsk_curve_curve_init_from_points (&offset->curve, p);
}
+static void
+gsk_curve_curve_reverse (const GskCurve *curve,
+ GskCurve *reverse)
+{
+ const GskCurveCurve *self = &curve->curve;
+
+ reverse->op = GSK_PATH_CURVE;
+ reverse->curve.points[0] = self->points[3];
+ reverse->curve.points[1] = self->points[2];
+ reverse->curve.points[2] = self->points[1];
+ reverse->curve.points[3] = self->points[0];
+ reverse->curve.has_coefficients = FALSE;
+}
+
static const GskCurveClass GSK_CURVE_CURVE_CLASS = {
gsk_curve_curve_init,
gsk_curve_curve_init_foreach,
@@ -692,7 +720,8 @@ static const GskCurveClass GSK_CURVE_CURVE_CLASS = {
gsk_curve_curve_get_end_tangent,
gsk_curve_curve_get_bounds,
gsk_curve_curve_get_tight_bounds,
- gsk_curve_curve_offset
+ gsk_curve_curve_offset,
+ gsk_curve_curve_reverse
};
/** CONIC **/
@@ -1285,6 +1314,20 @@ gsk_conic_curve_offset (const GskCurve *curve,
gsk_conic_curve_init_from_points (&offset->conic, p);
}
+static void
+gsk_conic_curve_reverse (const GskCurve *curve,
+ GskCurve *reverse)
+{
+ const GskConicCurve *self = &curve->conic;
+
+ reverse->op = GSK_PATH_CONIC;
+ reverse->conic.points[0] = self->points[3];
+ reverse->conic.points[1] = self->points[1];
+ reverse->conic.points[2] = self->points[2];
+ reverse->conic.points[3] = self->points[0];
+ reverse->conic.has_coefficients = FALSE;
+}
+
static const GskCurveClass GSK_CONIC_CURVE_CLASS = {
gsk_conic_curve_init,
gsk_conic_curve_init_foreach,
@@ -1301,7 +1344,8 @@ static const GskCurveClass GSK_CONIC_CURVE_CLASS = {
gsk_conic_curve_get_end_tangent,
gsk_conic_curve_get_bounds,
gsk_conic_curve_get_tight_bounds,
- gsk_conic_curve_offset
+ gsk_conic_curve_offset,
+ gsk_conic_curve_reverse
};
/** API **/
@@ -1449,3 +1493,10 @@ gsk_curve_offset (const GskCurve *curve,
{
get_class (curve->op)->offset (curve, distance, offset_curve);
}
+
+void
+gsk_curve_reverse (const GskCurve *curve,
+ GskCurve *reverse)
+{
+ get_class (curve->op)->reverse (curve, reverse);
+}
diff --git a/gsk/gskcurveprivate.h b/gsk/gskcurveprivate.h
index e4705f915b..0f721e2016 100644
--- a/gsk/gskcurveprivate.h
+++ b/gsk/gskcurveprivate.h
@@ -135,6 +135,8 @@ int gsk_curve_intersect (const GskCurve
void gsk_curve_offset (const GskCurve *curve,
float distance,
GskCurve *offset_curve);
+void gsk_curve_reverse (const GskCurve *curve,
+ GskCurve *reverse);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]