[gtk/path-work-rebased: 43/71] curve: Add gsk_curve_print




commit 81dae3e15f1e6012bc5dc3b5ecab9458cd978582
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Mar 21 15:55:41 2022 -0400

    curve: Add gsk_curve_print
    
    Useful for debugging.

 gsk/gskcurve.c        | 44 ++++++++++++++++++++++++++++++++++++++++++--
 gsk/gskcurveprivate.h |  3 +++
 2 files changed, 45 insertions(+), 2 deletions(-)
---
diff --git a/gsk/gskcurve.c b/gsk/gskcurve.c
index 14e17c40fe..573f2c48c6 100644
--- a/gsk/gskcurve.c
+++ b/gsk/gskcurve.c
@@ -74,6 +74,8 @@ struct _GskCurveClass
                                                          GskCurve               *reverse);
   float                         (* get_curvature)       (const GskCurve         *curve,
                                                          float                   t);
+
+  void                          (* print)               (const GskCurve         *curve);
 };
 
 /* {{{ Line implementation */
@@ -334,6 +336,14 @@ gsk_line_curve_get_curvature (const GskCurve *curve,
   return 0;
 }
 
+static void
+gsk_line_curve_print (const GskCurve *curve)
+{
+  g_print ("M %g %g L %g %g",
+           curve->line.points[0].x, curve->line.points[0].y,
+           curve->line.points[1].x, curve->line.points[1].y);
+}
+
 static const GskCurveClass GSK_LINE_CURVE_CLASS = {
   gsk_line_curve_init,
   gsk_line_curve_init_foreach,
@@ -352,7 +362,8 @@ static const GskCurveClass GSK_LINE_CURVE_CLASS = {
   gsk_line_curve_get_bounds,
   gsk_line_curve_offset,
   gsk_line_curve_reverse,
-  gsk_line_curve_get_curvature
+  gsk_line_curve_get_curvature,
+  gsk_line_curve_print,
 };
 
 /* }}} */
@@ -871,6 +882,16 @@ gsk_curve_curve_get_curvature (const GskCurve *curve,
   return num / denom;
 }
 
+static void
+gsk_curve_curve_print (const GskCurve *curve)
+{
+  g_print ("M %g %g C %g %g %g %g %g %g",
+           curve->curve.points[0].x, curve->curve.points[0].y,
+           curve->curve.points[1].x, curve->curve.points[1].y,
+           curve->curve.points[2].x, curve->curve.points[2].y,
+           curve->curve.points[3].x, curve->curve.points[3].y);
+}
+
 static const GskCurveClass GSK_CURVE_CURVE_CLASS = {
   gsk_curve_curve_init,
   gsk_curve_curve_init_foreach,
@@ -890,6 +911,7 @@ static const GskCurveClass GSK_CURVE_CURVE_CLASS = {
   gsk_curve_curve_offset,
   gsk_curve_curve_reverse,
   gsk_curve_curve_get_curvature,
+  gsk_curve_curve_print,
 };
 
 /* }}} */
@@ -1593,6 +1615,17 @@ gsk_conic_curve_get_curvature (const GskCurve *curve,
   return num / denom;
 }
 
+static void
+gsk_conic_curve_print (const GskCurve *curve)
+{
+  g_print ("M %g %g C %g %g %g %g %g",
+           curve->conic.points[0].x, curve->conic.points[0].y,
+           curve->conic.points[1].x, curve->conic.points[1].y,
+           curve->conic.points[2].x,
+           curve->conic.points[3].x, curve->conic.points[3].y);
+
+}
+
 static const GskCurveClass GSK_CONIC_CURVE_CLASS = {
   gsk_conic_curve_init,
   gsk_conic_curve_init_foreach,
@@ -1611,7 +1644,8 @@ static const GskCurveClass GSK_CONIC_CURVE_CLASS = {
   gsk_conic_curve_get_tight_bounds,
   gsk_conic_curve_offset,
   gsk_conic_curve_reverse,
-  gsk_conic_curve_get_curvature
+  gsk_conic_curve_get_curvature,
+  gsk_conic_curve_print,
 };
 
 /* }}} */
@@ -1806,6 +1840,12 @@ gsk_curve_get_curvature (const GskCurve   *curve,
   return k;
 }
 
+void
+gsk_curve_print (const GskCurve *curve)
+{
+  get_class (curve->op)->print (curve);
+}
+
 /* }}} */
 
 /* vim:set foldmethod=marker expandtab: */
diff --git a/gsk/gskcurveprivate.h b/gsk/gskcurveprivate.h
index 5af65f6fa9..c3ffd0d99f 100644
--- a/gsk/gskcurveprivate.h
+++ b/gsk/gskcurveprivate.h
@@ -149,6 +149,9 @@ float                   gsk_curve_get_curvature                 (const GskCurve
                                                                  float                   t,
                                                                  graphene_point_t       *center);
 
+void                    gsk_curve_print                         (const GskCurve         *curve);
+
+
 G_END_DECLS
 
 #endif /* __GSK_CURVE_PRIVATE_H__ */


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