[gtk/path-stroke: 360/361] stroke: Add back some debugging
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/path-stroke: 360/361] stroke: Add back some debugging
- Date: Sat, 19 Dec 2020 05:24:24 +0000 (UTC)
commit 068f5005de331895b327de6a1768d9c71a7ab9f7
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Dec 17 23:26:26 2020 -0500
stroke: Add back some debugging
Draw the on-curve points if STROKE_DEBUG is set.
This shows how we subdivide curves.
gsk/gskpathstroke.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
---
diff --git a/gsk/gskpathstroke.c b/gsk/gskpathstroke.c
index d14a18290a..244e040258 100644
--- a/gsk/gskpathstroke.c
+++ b/gsk/gskpathstroke.c
@@ -26,6 +26,8 @@
#include "gskpathdashprivate.h"
#include "gskpathopprivate.h"
+#define STROKE_DEBUG
+
#define RAD_TO_DEG(r) ((r)*180.0/M_PI)
#define DEG_TO_RAD(d) ((d)*M_PI/180.0)
@@ -358,6 +360,10 @@ typedef struct
GskCurve c0; // first segment of the path
GskCurve l0; // first segment of left contour
GskCurve r0; // first segment of right contour
+
+#ifdef STROKE_DEBUG
+ GskPathBuilder *debug;
+#endif
} StrokeData;
static void
@@ -486,6 +492,41 @@ add_segments (StrokeData *stroke_data,
stroke_data->l = *l;
}
+#ifdef STROKE_DEBUG
+static void
+add_debug (StrokeData *stroke_data,
+ const GskCurve *curve)
+{
+ const graphene_point_t *p;
+
+ if (g_getenv ("STROKE_DEBUG"))
+ {
+ switch (curve->op)
+ {
+ case GSK_PATH_LINE:
+ case GSK_PATH_CLOSE:
+ p = curve->line.points;
+ gsk_path_builder_add_circle (stroke_data->debug, &p[0], 3);
+ gsk_path_builder_add_circle (stroke_data->debug, &p[1], 3);
+ break;
+ case GSK_PATH_CURVE:
+ p = curve->curve.points;
+ gsk_path_builder_add_circle (stroke_data->debug, &p[0], 3);
+ gsk_path_builder_add_circle (stroke_data->debug, &p[3], 3);
+ break;
+ case GSK_PATH_CONIC:
+ p = curve->conic.points;
+ gsk_path_builder_add_circle (stroke_data->debug, &p[0], 3);
+ gsk_path_builder_add_circle (stroke_data->debug, &p[3], 3);
+ break;
+ case GSK_PATH_MOVE:
+ default:
+ g_assert_not_reached ();
+ }
+ }
+}
+#endif
+
/* Add a curve to the in-progress stroke. We look at the angle between
* the previous curve and this one to determine on which side we need
* to intersect the curves, and on which to add a join.
@@ -499,6 +540,10 @@ add_curve (StrokeData *stroke_data,
gsk_curve_offset (curve, - stroke_data->stroke->line_width / 2, &l);
gsk_curve_offset (curve, stroke_data->stroke->line_width / 2, &r);
+#ifdef STROKE_DEBUG
+ add_debug (stroke_data, curve);
+#endif
+
if (!stroke_data->has_current_curve)
{
stroke_data->c0 = *curve;
@@ -896,6 +941,10 @@ gsk_contour_default_add_stroke (const GskContour *contour,
stroke_data.builder = builder;
stroke_data.stroke = stroke;
+#ifdef STROKE_DEBUG
+ stroke_data.debug = gsk_path_builder_new ();
+#endif
+
if (stroke->dash_length <= 0)
gsk_contour_foreach (contour, GSK_PATH_TOLERANCE_DEFAULT, stroke_op, &stroke_data);
else
@@ -903,6 +952,12 @@ gsk_contour_default_add_stroke (const GskContour *contour,
if (stroke_data.has_current_point)
cap_and_connect_contours (&stroke_data);
+
+#ifdef STROKE_DEBUG
+ GskPath *path = gsk_path_builder_free_to_path (stroke_data.debug);
+ gsk_path_builder_add_path (builder, path);
+ gsk_path_unref (path);
+#endif
}
/* vim:set foldmethod=marker expandtab: */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]