path: Collect flags
We don't need them yet, but maybe later.
This commit is contained in:
@@ -35,6 +35,12 @@
|
|||||||
* The #GskPathBuilder structure is meant to help in this endeavor.
|
* 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 _GskContour GskContour;
|
||||||
typedef struct _GskContourClass GskContourClass;
|
typedef struct _GskContourClass GskContourClass;
|
||||||
|
|
||||||
@@ -49,6 +55,7 @@ struct _GskContourClass
|
|||||||
const char *type_name;
|
const char *type_name;
|
||||||
|
|
||||||
gsize (* get_size) (const GskContour *contour);
|
gsize (* get_size) (const GskContour *contour);
|
||||||
|
GskPathFlags (* get_flags) (const GskContour *contour);
|
||||||
void (* print) (const GskContour *contour,
|
void (* print) (const GskContour *contour,
|
||||||
GString *string);
|
GString *string);
|
||||||
void (* to_cairo) (const GskContour *contour,
|
void (* to_cairo) (const GskContour *contour,
|
||||||
@@ -73,6 +80,8 @@ struct _GskPath
|
|||||||
/*< private >*/
|
/*< private >*/
|
||||||
guint ref_count;
|
guint ref_count;
|
||||||
|
|
||||||
|
GskPathFlags flags;
|
||||||
|
|
||||||
gsize n_contours;
|
gsize n_contours;
|
||||||
GskContour *contours[];
|
GskContour *contours[];
|
||||||
/* followed by the contours data */
|
/* followed by the contours data */
|
||||||
@@ -108,6 +117,12 @@ struct _GskRectContour
|
|||||||
float height;
|
float height;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static GskPathFlags
|
||||||
|
gsk_rect_contour_get_flags (const GskContour *contour)
|
||||||
|
{
|
||||||
|
return GSK_PATH_FLAT | GSK_PATH_CLOSED;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_g_string_append_double (GString *string,
|
_g_string_append_double (GString *string,
|
||||||
double d)
|
double d)
|
||||||
@@ -263,6 +278,7 @@ static const GskContourClass GSK_RECT_CONTOUR_CLASS =
|
|||||||
sizeof (GskRectContour),
|
sizeof (GskRectContour),
|
||||||
"GskRectContour",
|
"GskRectContour",
|
||||||
gsk_contour_get_size_default,
|
gsk_contour_get_size_default,
|
||||||
|
gsk_rect_contour_get_flags,
|
||||||
gsk_rect_contour_print,
|
gsk_rect_contour_print,
|
||||||
gsk_rect_contour_to_cairo,
|
gsk_rect_contour_to_cairo,
|
||||||
gsk_rect_contour_get_bounds,
|
gsk_rect_contour_get_bounds,
|
||||||
@@ -310,6 +326,8 @@ struct _GskStandardContour
|
|||||||
{
|
{
|
||||||
GskContour contour;
|
GskContour contour;
|
||||||
|
|
||||||
|
GskPathFlags flags;
|
||||||
|
|
||||||
gsize n_ops;
|
gsize n_ops;
|
||||||
gsize n_points;
|
gsize n_points;
|
||||||
graphene_point_t *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);
|
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
|
static void
|
||||||
gsk_standard_contour_print (const GskContour *contour,
|
gsk_standard_contour_print (const GskContour *contour,
|
||||||
GString *string)
|
GString *string)
|
||||||
@@ -509,6 +535,7 @@ gsk_standard_contour_free_measure (const GskContour *contour,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gsk_standard_contour_init (GskContour *contour,
|
gsk_standard_contour_init (GskContour *contour,
|
||||||
|
GskPathFlags flags,
|
||||||
const GskStandardOperation *ops,
|
const GskStandardOperation *ops,
|
||||||
gsize n_ops,
|
gsize n_ops,
|
||||||
const graphene_point_t *points,
|
const graphene_point_t *points,
|
||||||
@@ -520,7 +547,7 @@ gsk_standard_contour_copy (const GskContour *contour,
|
|||||||
{
|
{
|
||||||
const GskStandardContour *self = (const GskStandardContour *) 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
|
static void
|
||||||
@@ -624,6 +651,7 @@ static const GskContourClass GSK_STANDARD_CONTOUR_CLASS =
|
|||||||
sizeof (GskStandardContour),
|
sizeof (GskStandardContour),
|
||||||
"GskStandardContour",
|
"GskStandardContour",
|
||||||
gsk_standard_contour_get_size,
|
gsk_standard_contour_get_size,
|
||||||
|
gsk_standard_contour_get_flags,
|
||||||
gsk_standard_contour_print,
|
gsk_standard_contour_print,
|
||||||
gsk_standard_contour_to_cairo,
|
gsk_standard_contour_to_cairo,
|
||||||
gsk_standard_contour_get_bounds,
|
gsk_standard_contour_get_bounds,
|
||||||
@@ -638,6 +666,7 @@ static const GskContourClass GSK_STANDARD_CONTOUR_CLASS =
|
|||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
gsk_standard_contour_init (GskContour *contour,
|
gsk_standard_contour_init (GskContour *contour,
|
||||||
|
GskPathFlags flags,
|
||||||
const GskStandardOperation *ops,
|
const GskStandardOperation *ops,
|
||||||
gsize n_ops,
|
gsize n_ops,
|
||||||
const graphene_point_t *points,
|
const graphene_point_t *points,
|
||||||
@@ -647,6 +676,7 @@ gsk_standard_contour_init (GskContour *contour,
|
|||||||
|
|
||||||
self->contour.klass = &GSK_STANDARD_CONTOUR_CLASS;
|
self->contour.klass = &GSK_STANDARD_CONTOUR_CLASS;
|
||||||
|
|
||||||
|
self->flags = flags;
|
||||||
self->n_ops = n_ops;
|
self->n_ops = n_ops;
|
||||||
memcpy (self->ops, ops, sizeof (GskStandardOperation) * n_ops);
|
memcpy (self->ops, ops, sizeof (GskStandardOperation) * n_ops);
|
||||||
self->n_points = n_points;
|
self->n_points = n_points;
|
||||||
@@ -992,6 +1022,7 @@ struct _GskPathBuilder
|
|||||||
|
|
||||||
GSList *contours; /* (reverse) list of already recorded contours */
|
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 *ops; /* operations for current contour - size == 0 means no current contour */
|
||||||
GArray *points; /* points for the operations */
|
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));
|
contour = g_malloc0 (gsk_standard_contour_compute_size (builder->ops->len, builder->points->len));
|
||||||
gsk_standard_contour_init (contour,
|
gsk_standard_contour_init (contour,
|
||||||
|
0,
|
||||||
(GskStandardOperation *) builder->ops->data,
|
(GskStandardOperation *) builder->ops->data,
|
||||||
builder->ops->len,
|
builder->ops->len,
|
||||||
(graphene_point_t *) builder->points->data,
|
(graphene_point_t *) builder->points->data,
|
||||||
@@ -1184,12 +1216,14 @@ gsk_path_builder_to_path (GskPathBuilder *builder)
|
|||||||
gsize size;
|
gsize size;
|
||||||
gsize n_contours;
|
gsize n_contours;
|
||||||
guint8 *contour_data;
|
guint8 *contour_data;
|
||||||
|
GskPathFlags flags;
|
||||||
|
|
||||||
g_return_val_if_fail (builder != NULL, NULL);
|
g_return_val_if_fail (builder != NULL, NULL);
|
||||||
|
|
||||||
gsk_path_builder_end_current (builder);
|
gsk_path_builder_end_current (builder);
|
||||||
|
|
||||||
builder->contours = g_slist_reverse (builder->contours);
|
builder->contours = g_slist_reverse (builder->contours);
|
||||||
|
flags = GSK_PATH_CLOSED | GSK_PATH_FLAT;
|
||||||
size = 0;
|
size = 0;
|
||||||
n_contours = 0;
|
n_contours = 0;
|
||||||
for (l = builder->contours; l; l = l->next)
|
for (l = builder->contours; l; l = l->next)
|
||||||
@@ -1199,9 +1233,11 @@ gsk_path_builder_to_path (GskPathBuilder *builder)
|
|||||||
n_contours++;
|
n_contours++;
|
||||||
size += sizeof (GskContour *);
|
size += sizeof (GskContour *);
|
||||||
size += gsk_contour_get_size (contour);
|
size += gsk_contour_get_size (contour);
|
||||||
|
flags &= contour->klass->get_flags (contour);
|
||||||
}
|
}
|
||||||
|
|
||||||
path = gsk_path_alloc (size);
|
path = gsk_path_alloc (size);
|
||||||
|
path->flags = flags;
|
||||||
path->n_contours = n_contours;
|
path->n_contours = n_contours;
|
||||||
contour_data = (guint8 *) &path->contours[n_contours];
|
contour_data = (guint8 *) &path->contours[n_contours];
|
||||||
n_contours = 0;
|
n_contours = 0;
|
||||||
@@ -1294,6 +1330,7 @@ gsk_path_builder_move_to (GskPathBuilder *builder,
|
|||||||
|
|
||||||
gsk_path_builder_end_current (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_vals (builder->ops, &(GskStandardOperation) { GSK_PATH_MOVE, 0 }, 1);
|
||||||
g_array_append_val (builder->points, GRAPHENE_POINT_INIT(x, y));
|
g_array_append_val (builder->points, GRAPHENE_POINT_INIT(x, y));
|
||||||
}
|
}
|
||||||
@@ -1332,6 +1369,7 @@ gsk_path_builder_curve_to (GskPathBuilder *builder,
|
|||||||
if (builder->ops->len == 0)
|
if (builder->ops->len == 0)
|
||||||
gsk_path_builder_move_to (builder, x1, y1);
|
gsk_path_builder_move_to (builder, x1, y1);
|
||||||
|
|
||||||
|
builder->flags &= ~GSK_PATH_FLAT;
|
||||||
gsk_path_builder_append_current (builder,
|
gsk_path_builder_append_current (builder,
|
||||||
GSK_PATH_CURVE,
|
GSK_PATH_CURVE,
|
||||||
3, (graphene_point_t[3]) {
|
3, (graphene_point_t[3]) {
|
||||||
@@ -1349,6 +1387,7 @@ gsk_path_builder_close (GskPathBuilder *builder)
|
|||||||
if (builder->ops->len == 0)
|
if (builder->ops->len == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
builder->flags |= GSK_PATH_CLOSED;
|
||||||
gsk_path_builder_append_current (builder,
|
gsk_path_builder_append_current (builder,
|
||||||
GSK_PATH_CLOSE,
|
GSK_PATH_CLOSE,
|
||||||
1, (graphene_point_t[1]) {
|
1, (graphene_point_t[1]) {
|
||||||
|
|||||||
Reference in New Issue
Block a user