[gtk/wip/matthiasc/lottie-stroke: 9/10] wip: more subdivision tweakery
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/lottie-stroke: 9/10] wip: more subdivision tweakery
- Date: Mon, 30 Nov 2020 19:02:24 +0000 (UTC)
commit 581a6efeb96de1c537daf60184fb47ffc2813690
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Nov 30 01:11:56 2020 -0500
wip: more subdivision tweakery
gsk/gskpathstroke.c | 44 +++++++++++++++++++++++++++++++++++++++++---
1 file changed, 41 insertions(+), 3 deletions(-)
---
diff --git a/gsk/gskpathstroke.c b/gsk/gskpathstroke.c
index 2761d963dd..db94b1ed9b 100644
--- a/gsk/gskpathstroke.c
+++ b/gsk/gskpathstroke.c
@@ -870,7 +870,7 @@ path_op_data_new (GskPathOperation op,
d->pts[i] = pts[i];
d->n_pts = n_pts;
-#if 1
+#if 0
/* detect uninitialized values */
for (i = 0; i < n_pts; i++)
d->l[i].x = d->l[i].y = d->r[i].x = d->r[i].y = NAN;
@@ -908,6 +908,7 @@ subdivide_and_add (const graphene_point_t pts[4],
GList *l, *pass1 = NULL;
graphene_point_t p[4];
graphene_point_t *segment;
+ float t0, t1;
n += get_cubic_extrema (pts[0].x, pts[1].x, pts[2].x, pts[3].x, &pos[n]);
n += get_cubic_extrema (pts[0].y, pts[1].y, pts[2].y, pts[3].y, &pos[n]);
@@ -921,6 +922,8 @@ subdivide_and_add (const graphene_point_t pts[4],
pass1 = NULL;
+ t0 = 0.1;
+ t1 = 0.9;
for (i = 0; i < n; i++)
{
graphene_point_t left[4];
@@ -928,7 +931,7 @@ subdivide_and_add (const graphene_point_t pts[4],
float t;
t = pos[i];
- if (t < 0.1 || t > 0.9)
+ if (t < t0 || t > t1)
continue;
split_bezier (p, 4, t, left, right);
@@ -941,7 +944,10 @@ subdivide_and_add (const graphene_point_t pts[4],
p[k] = right[k];
for (k = i + 1; k < n; k++)
- pos[k] = pos[k] / (1 - pos[i]);
+ pos[k] = (pos[k] - pos[i]) / (1 - pos[i]);
+
+ t0 = 0;
+ t1 = (t1 - pos[i]) / (1 - pos[i]);
}
segment = g_new (graphene_point_t, 4);
@@ -1219,6 +1225,38 @@ gsk_contour_to_stroke (const GskContour *contour,
}
}
+#if 0
+ /* Subdivide */
+ sops = NULL;
+ for (l = ops; l; l = l->next)
+ {
+ op = l->data;
+
+ switch (op->op)
+ {
+ case GSK_PATH_MOVE:
+ g_assert_not_reached ();
+ break;
+
+ case GSK_PATH_LINE:
+ case GSK_PATH_CLOSE:
+ sops = g_list_prepend (sops, op);
+ break;
+
+ case GSK_PATH_CURVE:
+ subdivide_and_add (op, &sops);
+ g_free (op);
+ break;
+
+ default:
+ g_assert_not_reached ();
+ }
+ }
+
+ g_list_free (ops);
+ ops = g_list_reverse (sops);
+#endif
+
for (l = ops; l; l = l->next)
{
int i;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]