[gtk/wip/otte/lottie: 2430/2503] path: Collect flags
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/lottie: 2430/2503] path: Collect flags
- Date: Tue, 13 Jul 2021 04:28:05 +0000 (UTC)
commit 890b12e5808a19ec7a6e11ce8057060f4fe4c4cb
Author: Benjamin Otte <otte redhat com>
Date: Wed Nov 18 04:28:21 2020 +0100
path: Collect flags
We don't need them yet, but maybe later.
gsk/gskpath.c | 41 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
---
diff --git a/gsk/gskpath.c b/gsk/gskpath.c
index 0475f97925..050ecad391 100644
--- a/gsk/gskpath.c
+++ b/gsk/gskpath.c
@@ -35,6 +35,12 @@
* The #GskPathBuilder structure is meant to help in this endeavor.
*/
+typedef enum
+{
+ GSK_PATH_FLAT,
+ GSK_PATH_CLOSED
+} GskPathFlags;
+
typedef struct _GskContour GskContour;
typedef struct _GskContourClass GskContourClass;
@@ -49,6 +55,7 @@ struct _GskContourClass
const char *type_name;
gsize (* get_size) (const GskContour *contour);
+ GskPathFlags (* get_flags) (const GskContour *contour);
void (* print) (const GskContour *contour,
GString *string);
void (* to_cairo) (const GskContour *contour,
@@ -73,6 +80,8 @@ struct _GskPath
/*< private >*/
guint ref_count;
+ GskPathFlags flags;
+
gsize n_contours;
GskContour *contours[];
/* followed by the contours data */
@@ -108,6 +117,12 @@ struct _GskRectContour
float height;
};
+static GskPathFlags
+gsk_rect_contour_get_flags (const GskContour *contour)
+{
+ return GSK_PATH_FLAT | GSK_PATH_CLOSED;
+}
+
static void
_g_string_append_double (GString *string,
double d)
@@ -263,6 +278,7 @@ static const GskContourClass GSK_RECT_CONTOUR_CLASS =
sizeof (GskRectContour),
"GskRectContour",
gsk_contour_get_size_default,
+ gsk_rect_contour_get_flags,
gsk_rect_contour_print,
gsk_rect_contour_to_cairo,
gsk_rect_contour_get_bounds,
@@ -310,6 +326,8 @@ struct _GskStandardContour
{
GskContour contour;
+ GskPathFlags flags;
+
gsize n_ops;
gsize n_points;
graphene_point_t *points;
@@ -333,6 +351,14 @@ gsk_standard_contour_get_size (const GskContour *contour)
return gsk_standard_contour_compute_size (self->n_ops, self->n_points);
}
+static GskPathFlags
+gsk_standard_contour_get_flags (const GskContour *contour)
+{
+ const GskStandardContour *self = (const GskStandardContour *) contour;
+
+ return self->flags;
+}
+
static void
gsk_standard_contour_print (const GskContour *contour,
GString *string)
@@ -509,6 +535,7 @@ gsk_standard_contour_free_measure (const GskContour *contour,
static void
gsk_standard_contour_init (GskContour *contour,
+ GskPathFlags flags,
const GskStandardOperation *ops,
gsize n_ops,
const graphene_point_t *points,
@@ -520,7 +547,7 @@ gsk_standard_contour_copy (const GskContour *contour,
{
const GskStandardContour *self = (const GskStandardContour *) contour;
- gsk_standard_contour_init (dest, self->ops, self->n_ops, self->points, self->n_points);
+ gsk_standard_contour_init (dest, self->flags, self->ops, self->n_ops, self->points, self->n_points);
}
static void
@@ -624,6 +651,7 @@ static const GskContourClass GSK_STANDARD_CONTOUR_CLASS =
sizeof (GskStandardContour),
"GskStandardContour",
gsk_standard_contour_get_size,
+ gsk_standard_contour_get_flags,
gsk_standard_contour_print,
gsk_standard_contour_to_cairo,
gsk_standard_contour_get_bounds,
@@ -638,6 +666,7 @@ static const GskContourClass GSK_STANDARD_CONTOUR_CLASS =
*/
static void
gsk_standard_contour_init (GskContour *contour,
+ GskPathFlags flags,
const GskStandardOperation *ops,
gsize n_ops,
const graphene_point_t *points,
@@ -647,6 +676,7 @@ gsk_standard_contour_init (GskContour *contour,
self->contour.klass = &GSK_STANDARD_CONTOUR_CLASS;
+ self->flags = flags;
self->n_ops = n_ops;
memcpy (self->ops, ops, sizeof (GskStandardOperation) * n_ops);
self->n_points = n_points;
@@ -992,6 +1022,7 @@ struct _GskPathBuilder
GSList *contours; /* (reverse) list of already recorded contours */
+ GskPathFlags flags; /* flags for the current path */
GArray *ops; /* operations for current contour - size == 0 means no current contour */
GArray *points; /* points for the operations */
};
@@ -1095,6 +1126,7 @@ gsk_path_builder_end_current (GskPathBuilder *builder)
contour = g_malloc0 (gsk_standard_contour_compute_size (builder->ops->len, builder->points->len));
gsk_standard_contour_init (contour,
+ 0,
(GskStandardOperation *) builder->ops->data,
builder->ops->len,
(graphene_point_t *) builder->points->data,
@@ -1184,12 +1216,14 @@ gsk_path_builder_to_path (GskPathBuilder *builder)
gsize size;
gsize n_contours;
guint8 *contour_data;
+ GskPathFlags flags;
g_return_val_if_fail (builder != NULL, NULL);
gsk_path_builder_end_current (builder);
builder->contours = g_slist_reverse (builder->contours);
+ flags = GSK_PATH_CLOSED | GSK_PATH_FLAT;
size = 0;
n_contours = 0;
for (l = builder->contours; l; l = l->next)
@@ -1199,9 +1233,11 @@ gsk_path_builder_to_path (GskPathBuilder *builder)
n_contours++;
size += sizeof (GskContour *);
size += gsk_contour_get_size (contour);
+ flags &= contour->klass->get_flags (contour);
}
path = gsk_path_alloc (size);
+ path->flags = flags;
path->n_contours = n_contours;
contour_data = (guint8 *) &path->contours[n_contours];
n_contours = 0;
@@ -1296,6 +1332,7 @@ gsk_path_builder_move_to (GskPathBuilder *builder,
gsk_path_builder_end_current (builder);
+ builder->flags = GSK_PATH_FLAT;
g_array_append_vals (builder->ops, &(GskStandardOperation) { GSK_PATH_MOVE, 0 }, 1);
g_array_append_val (builder->points, GRAPHENE_POINT_INIT(x, y));
}
@@ -1334,6 +1371,7 @@ gsk_path_builder_curve_to (GskPathBuilder *builder,
if (builder->ops->len == 0)
gsk_path_builder_move_to (builder, x1, y1);
+ builder->flags &= ~GSK_PATH_FLAT;
gsk_path_builder_append_current (builder,
GSK_PATH_CURVE,
3, (graphene_point_t[3]) {
@@ -1351,6 +1389,7 @@ gsk_path_builder_close (GskPathBuilder *builder)
if (builder->ops->len == 0)
return;
+ builder->flags |= GSK_PATH_CLOSED;
gsk_path_builder_append_current (builder,
GSK_PATH_CLOSE,
1, (graphene_point_t[1]) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]