summaryrefslogtreecommitdiff
path: root/gsk/gskcontour.c
diff options
context:
space:
mode:
Diffstat (limited to 'gsk/gskcontour.c')
-rw-r--r--gsk/gskcontour.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/gsk/gskcontour.c b/gsk/gskcontour.c
index f90e4cea21..880d6d8ed7 100644
--- a/gsk/gskcontour.c
+++ b/gsk/gskcontour.c
@@ -26,6 +26,7 @@
#include "gskpathprivate.h"
#include "gsksplineprivate.h"
#include "gskstrokeprivate.h"
+#include "gskconvexityprivate.h"
typedef struct _GskContourClass GskContourClass;
@@ -99,6 +100,7 @@ struct _GskContourClass
GskLineJoin line_join,
float miter_limit);
GskContour * (* reverse) (const GskContour *contour);
+ gboolean (* is_convex) (const GskContour *contour);
};
static gsize
@@ -576,6 +578,12 @@ gsk_rect_contour_reverse (const GskContour *contour)
self->height));
}
+static gboolean
+gsk_rect_contour_is_convex (const GskContour *contour)
+{
+ return TRUE;
+}
+
static const GskContourClass GSK_RECT_CONTOUR_CLASS =
{
sizeof (GskRectContour),
@@ -598,6 +606,7 @@ static const GskContourClass GSK_RECT_CONTOUR_CLASS =
gsk_rect_contour_add_stroke,
gsk_rect_contour_offset,
gsk_rect_contour_reverse,
+ gsk_rect_contour_is_convex,
};
GskContour *
@@ -989,6 +998,12 @@ gsk_circle_contour_reverse (const GskContour *contour)
self->start_angle);
}
+static gboolean
+gsk_circle_contour_is_convex (const GskContour *contour)
+{
+ return TRUE;
+}
+
static const GskContourClass GSK_CIRCLE_CONTOUR_CLASS =
{
sizeof (GskCircleContour),
@@ -1011,6 +1026,7 @@ static const GskContourClass GSK_CIRCLE_CONTOUR_CLASS =
gsk_circle_contour_add_stroke,
gsk_circle_contour_offset,
gsk_circle_contour_reverse,
+ gsk_circle_contour_is_convex,
};
GskContour *
@@ -1044,6 +1060,7 @@ struct _GskStandardContour
GskContour contour;
GskPathFlags flags;
+ GskConvexity convexity;
gsize n_ops;
gsize n_points;
@@ -1818,6 +1835,17 @@ gsk_standard_contour_reverse (const GskContour *contour)
return res;
}
+static gboolean
+gsk_standard_contour_is_convex (const GskContour *contour)
+{
+ GskStandardContour *self = (GskStandardContour *) contour;
+
+ if (self->convexity == GSK_CONVEXITY_UNKNOWN)
+ self->convexity = gsk_contour_compute_convexity (contour);
+
+ return self->convexity == GSK_CONVEXITY_CONVEX;
+}
+
static const GskContourClass GSK_STANDARD_CONTOUR_CLASS =
{
sizeof (GskStandardContour),
@@ -1840,6 +1868,7 @@ static const GskContourClass GSK_STANDARD_CONTOUR_CLASS =
gsk_standard_contour_add_stroke,
gsk_standard_contour_offset,
gsk_standard_contour_reverse,
+ gsk_standard_contour_is_convex,
};
/* You must ensure the contour has enough size allocated,
@@ -1861,6 +1890,7 @@ gsk_standard_contour_init (GskContour *contour,
self->contour.klass = &GSK_STANDARD_CONTOUR_CLASS;
self->flags = flags;
+ self->convexity = GSK_CONVEXITY_UNKNOWN;
self->n_ops = n_ops;
self->n_points = n_points;
self->points = (graphene_point_t *) &self->ops[n_ops];
@@ -2061,3 +2091,9 @@ gsk_contour_reverse (const GskContour *src)
{
return src->klass->reverse (src);
}
+
+gboolean
+gsk_contour_is_convex (const GskContour *contour)
+{
+ return contour->klass->is_convex (contour);
+}