[gtk/wip/matthiasc/lottie-stroke: 60/60] cleanups




commit e3252f7ad3d4d6c6a0e899061486fe1b10c23186
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Nov 30 02:45:50 2020 -0500

    cleanups

 gsk/gskpathstroke.c | 65 +++++++++++++++++++----------------------------------
 1 file changed, 23 insertions(+), 42 deletions(-)
---
diff --git a/gsk/gskpathstroke.c b/gsk/gskpathstroke.c
index 09a6481175..6088894469 100644
--- a/gsk/gskpathstroke.c
+++ b/gsk/gskpathstroke.c
@@ -408,7 +408,8 @@ cmpfloat (const void *p1, const void *p2)
   return f1 < f2 ? -1 : (f1 > f2 ? 1 : 0);
 }
 
-/* Place intersections between the line and the curve in q.
+/* Place intersections between the line and the curve in q,
+ * and their Bezier positions in t.
  * Return the number of intersections found (0 to 3).
  */
 static int
@@ -515,7 +516,8 @@ curve_intersection_recurse (const graphene_point_t  pts1[4],
   curve_intersection_recurse (p12, p22, t1 + d, t2, s1 + e, s2, t, s, q, pos);
 }
 
-/* Place intersections between the curves in q.
+/* Place intersections between the curves in q, and
+ * their Bezier positions in t and s.
  * Return the number of intersections found (0 to 9).
  */
 static int
@@ -545,25 +547,12 @@ typedef struct
   float angle[2]; /* angles between tangents at the both ends */
 } PathOpData;
 
-
-#if 0
-static const char *
-op_to_string (GskPathOperation op)
-{
-  const char *names[] = { "MOVE", "CLOSE", "LINE", "CURVE" };
-  return names[op];
-}
-#endif
-
 static void
 compute_offsets (PathOpData *op,
                  float       d)
 {
   graphene_vec2_t n1, n2, n3;
 
-  if (op->op == GSK_PATH_MOVE)
-    return;
-
   normal_vector (&op->pts[0], &op->pts[1], &n1);
   normal_vector (&op->pts[op->n_pts - 1], &op->pts[op->n_pts - 2], &n3);
 
@@ -616,11 +605,9 @@ compute_offsets (PathOpData *op,
 static int
 find_smallest (float t[], int n)
 {
-  float d;
-  int i, i0;
-
-  d = t[0];
-  i0 = 0;
+  float d = t[0];
+  int i0 = 0;
+  int i;
 
   for (i = 1; i < n; i++)
     {
@@ -637,11 +624,9 @@ find_smallest (float t[], int n)
 static int
 find_largest (float t[], int n)
 {
-  float d;
-  int i, i0;
-
-  d = t[0];
-  i0 = 0;
+  float d = t[0];
+  int i0 = 0;
+  int i;
 
   for (i = 1; i < n; i++)
     {
@@ -659,9 +644,6 @@ static void
 compute_intersections (PathOpData *op1,
                        PathOpData *op2)
 {
-  if (op1->op == GSK_PATH_MOVE)
-    return;
-
   op1->angle[1] = three_point_angle (&op1->pts[op1->n_pts - 2],
                                      &op1->pts[op1->n_pts - 1],
                                      &op2->pts[1]);
@@ -672,7 +654,10 @@ compute_intersections (PathOpData *op1,
     {
       graphene_point_t left[4];
       graphene_point_t right[4];
-      int i;
+      graphene_point_t p[9];
+      float t[9];
+      float s[9];
+      int i, n;
 
       if (!line_intersection (&op1->r[op1->n_pts - 2], &op1->r[op1->n_pts - 1],
                               &op2->r[0], &op2->r[1],
@@ -686,10 +671,6 @@ compute_intersections (PathOpData *op1,
 
       if (op1->n_pts == 2 && op2->n_pts == 4)
         {
-          float t[3];
-          graphene_point_t p[3];
-          int n;
-
           if (op1->angle[1] > 180.f)
             {
               n = line_curve_intersection (&op1->r[0], &op1->r[1], op2->r, t, p);
@@ -717,10 +698,6 @@ compute_intersections (PathOpData *op1,
         }
       else if (op1->n_pts == 4 && op2->n_pts == 2)
         {
-          float t[3];
-          graphene_point_t p[3];
-          int n;
-
           if (op1->angle[1] > 180.f)
             {
               n = line_curve_intersection (&op2->r[0], &op2->r[1], op1->r, t, p);
@@ -748,11 +725,6 @@ compute_intersections (PathOpData *op1,
         }
       else if (op1->n_pts == 4 && op2->n_pts == 4)
         {
-          graphene_point_t p[9];
-          float t[9];
-          float s[9];
-          int n;
-
           if (op1->angle[1] > 180.f)
             {
               n = curve_intersection (op1->r, op2->r, t, s, p);
@@ -902,6 +874,15 @@ contour_to_ops (const GskContour *contour,
 }
 
 #ifdef STROKE_DEBUG
+
+static const char * op_to_string (GskPathOperation op) G_GNUC_UNUSED;
+static const char *
+op_to_string (GskPathOperation op)
+{
+  const char *names[] = { "MOVE", "CLOSE", "LINE", "CURVE" };
+  return names[op];
+}
+
 enum {
   STROKE_DEBUG_LEFT_CURVES         = 1 << 0,
   STROKE_DEBUG_RIGHT_CURVES        = 1 << 1,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]