curve: Add gsk_curve_reverse
This will be used in stroking.
This commit is contained in:
@@ -76,6 +76,8 @@ struct _GskCurveClass
|
||||
void (* offset) (const GskCurve *curve,
|
||||
float distance,
|
||||
GskCurve *offset_curve);
|
||||
void (* reverse) (const GskCurve *curve,
|
||||
GskCurve *reverse);
|
||||
};
|
||||
|
||||
static void
|
||||
@@ -330,6 +332,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,
|
||||
@@ -349,6 +362,7 @@ static const GskCurveClass GSK_LINE_CURVE_CLASS = {
|
||||
gsk_line_curve_get_curvature,
|
||||
gsk_line_curve_print,
|
||||
gsk_line_curve_offset,
|
||||
gsk_line_curve_reverse,
|
||||
};
|
||||
|
||||
/** QUADRATIC **/
|
||||
@@ -708,6 +722,19 @@ gsk_quad_curve_offset (const GskCurve *curve,
|
||||
gsk_quad_curve_init_from_points (&offset->quad, p);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_quad_curve_reverse (const GskCurve *curve,
|
||||
GskCurve *reverse)
|
||||
{
|
||||
const GskCubicCurve *self = &curve->cubic;
|
||||
|
||||
reverse->op = GSK_PATH_QUAD;
|
||||
reverse->cubic.points[0] = self->points[2];
|
||||
reverse->cubic.points[1] = self->points[1];
|
||||
reverse->cubic.points[2] = self->points[0];
|
||||
reverse->cubic.has_coefficients = FALSE;
|
||||
}
|
||||
|
||||
static const GskCurveClass GSK_QUAD_CURVE_CLASS = {
|
||||
gsk_quad_curve_init,
|
||||
gsk_quad_curve_init_foreach,
|
||||
@@ -727,6 +754,7 @@ static const GskCurveClass GSK_QUAD_CURVE_CLASS = {
|
||||
gsk_quad_curve_get_curvature,
|
||||
gsk_quad_curve_print,
|
||||
gsk_quad_curve_offset,
|
||||
gsk_quad_curve_reverse,
|
||||
};
|
||||
|
||||
/** CUBIC **/
|
||||
@@ -1192,6 +1220,20 @@ gsk_cubic_curve_offset (const GskCurve *curve,
|
||||
gsk_cubic_curve_init_from_points (&offset->cubic, p);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_cubic_curve_reverse (const GskCurve *curve,
|
||||
GskCurve *reverse)
|
||||
{
|
||||
const GskCubicCurve *self = &curve->cubic;
|
||||
|
||||
reverse->op = GSK_PATH_CUBIC;
|
||||
reverse->cubic.points[0] = self->points[3];
|
||||
reverse->cubic.points[1] = self->points[2];
|
||||
reverse->cubic.points[2] = self->points[1];
|
||||
reverse->cubic.points[3] = self->points[0];
|
||||
reverse->cubic.has_coefficients = FALSE;
|
||||
}
|
||||
|
||||
static const GskCurveClass GSK_CUBIC_CURVE_CLASS = {
|
||||
gsk_cubic_curve_init,
|
||||
gsk_cubic_curve_init_foreach,
|
||||
@@ -1211,6 +1253,7 @@ static const GskCurveClass GSK_CUBIC_CURVE_CLASS = {
|
||||
gsk_cubic_curve_get_curvature,
|
||||
gsk_cubic_curve_print,
|
||||
gsk_cubic_curve_offset,
|
||||
gsk_cubic_curve_reverse,
|
||||
};
|
||||
|
||||
/** CONIC **/
|
||||
@@ -1864,6 +1907,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,
|
||||
@@ -1883,6 +1940,7 @@ static const GskCurveClass GSK_CONIC_CURVE_CLASS = {
|
||||
gsk_conic_curve_get_curvature,
|
||||
gsk_conic_curve_print,
|
||||
gsk_conic_curve_offset,
|
||||
gsk_conic_curve_reverse,
|
||||
};
|
||||
|
||||
/** API **/
|
||||
@@ -2088,6 +2146,13 @@ 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);
|
||||
}
|
||||
|
||||
static inline void
|
||||
_sincosf (float angle,
|
||||
float *out_s,
|
||||
|
||||
@@ -158,6 +158,8 @@ void gsk_curve_get_tight_bounds (const GskCurve
|
||||
void gsk_curve_offset (const GskCurve *curve,
|
||||
float distance,
|
||||
GskCurve *offset_curve);
|
||||
void gsk_curve_reverse (const GskCurve *curve,
|
||||
GskCurve *reverse);
|
||||
|
||||
int gsk_curve_intersect (const GskCurve *curve1,
|
||||
const GskCurve *curve2,
|
||||
|
||||
Reference in New Issue
Block a user