[gtk/curve-ops: 63/67] path: support conic->curve in foreach




commit c8448a4a37202fb271d8cb2a8c2a09420e79e2ee
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Dec 9 19:07:37 2020 -0500

    path: support conic->curve in foreach

 gsk/gskpath.c | 35 ++++++++++++++++++++++++++---------
 1 file changed, 26 insertions(+), 9 deletions(-)
---
diff --git a/gsk/gskpath.c b/gsk/gskpath.c
index fda323992e..d67fb763d9 100644
--- a/gsk/gskpath.c
+++ b/gsk/gskpath.c
@@ -463,6 +463,15 @@ gsk_path_foreach_trampoline_add_line (const graphene_point_t *from,
                            trampoline->user_data);
 }
 
+static gboolean
+gsk_path_foreach_trampoline_add_curve (const graphene_point_t points[4],
+                                       gpointer               data)
+{
+  GskPathForeachTrampoline *trampoline = data;
+
+  return trampoline->func (GSK_PATH_CURVE, points, 4, 0.0f, trampoline->user_data);
+}
+
 static gboolean
 gsk_path_foreach_trampoline (GskPathOperation        op,
                              const graphene_point_t *pts,
@@ -485,9 +494,9 @@ gsk_path_foreach_trampoline (GskPathOperation        op,
 
         if (trampoline->flags & GSK_PATH_FOREACH_ALLOW_CURVE)
           return trampoline->func (op, pts, n_pts, weight, trampoline->user_data);
-        
+
         gsk_curve_init (&curve, gsk_pathop_encode (GSK_PATH_CURVE, pts));
-        return gsk_curve_decompose (&curve, 
+        return gsk_curve_decompose (&curve,
                                     trampoline->tolerance,
                                     gsk_path_foreach_trampoline_add_line,
                                     trampoline);
@@ -495,17 +504,25 @@ gsk_path_foreach_trampoline (GskPathOperation        op,
 
     case GSK_PATH_CONIC:
       {
-        GskCurve curve;
+         GskCurve curve;
 
         if (trampoline->flags & GSK_PATH_FOREACH_ALLOW_CONIC)
           return trampoline->func (op, pts, n_pts, weight, trampoline->user_data);
+        else
+          {
+            gsk_curve_init (&curve, gsk_pathop_encode (GSK_PATH_CONIC, (graphene_point_t[4]) { pts[0], 
pts[1], { weight, }, pts[2] } ));
 
-        /* XXX: decompose into curves if allowed */
-        gsk_curve_init (&curve, gsk_pathop_encode (GSK_PATH_CONIC, (graphene_point_t[4]) { pts[0], pts[1], { 
weight, }, pts[2] } ));
-        return gsk_curve_decompose (&curve, 
-                                    trampoline->tolerance,
-                                    gsk_path_foreach_trampoline_add_line,
-                                    trampoline);
+            if (trampoline->flags & GSK_PATH_FOREACH_ALLOW_CURVE)
+              return gsk_curve_decompose_curve (&curve,
+                                                trampoline->tolerance,
+                                                gsk_path_foreach_trampoline_add_curve,
+                                                trampoline);
+            else
+              return gsk_curve_decompose (&curve,
+                                          trampoline->tolerance,
+                                          gsk_path_foreach_trampoline_add_line,
+                                          trampoline);
+          }
       }
 
 


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