[Pixman] [PATCH 03/13] pixman-image: Added GNUPLOT_OUTPUT compile-time option to view filters in gnuplot

spitzak at gmail.com spitzak at gmail.com
Sun Jan 3 19:12:07 PST 2016


From: Bill Spitzak <spitzak at gmail.com>

If GNUPLOT_OUTPUT is set, then you can pipe the output of a pixman-using program
to gnuplot and get a continuously-updated plot of the horizontal filter. This
works well with demos/scale to test the filter generation.

The plot is all the different subposition filters shuffled together. This is
misleading in a few cases:

  IMPULSE.BOX - goes up and down as the subfilters have different numbers of non-zero samples
  IMPULSE.TRIANGLE - somewhat crooked for the same reason
  1-wide filters - looks triangular, but a 1-wide box would be more accurate
---
 pixman/pixman-image.c | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c
index 1ff1a49..69743c4 100644
--- a/pixman/pixman-image.c
+++ b/pixman/pixman-image.c
@@ -531,6 +531,46 @@ compute_image_info (pixman_image_t *image)
 
     image->common.flags = flags;
     image->common.extended_format_code = code;
+/* If GNUPLOT_OUTPUT is set, then you can pipe the output of a pixman-using program
+ * to gnuplot and get a continuously-updated plot of the horizontal filter. This
+ * works well with demos/scale to test the filter generation.
+ *
+ * The plot is all the different subposition filters shuffled together. This is
+ * misleading in a few cases:
+ *
+ *  IMPULSE.BOX - goes up and down as the subfilters have different numbers of non-zero samples
+ *  IMPULSE.TRIANGLE - somewhat crooked for the same reason
+ *  1-wide filters - looks triangular, but a 1-wide box would be more accurate
+ */
+/* #define GNUPLOT_OUTPUT 1 */
+#if GNUPLOT_OUTPUT
+    if ((flags & FAST_PATH_SEPARABLE_CONVOLUTION_FILTER) && image->common.filter_params) {
+	const pixman_fixed_t* p = image->common.filter_params;
+	int width = pixman_fixed_to_int(p[0]);
+	int samples = 1 << pixman_fixed_to_int(p[2]);
+	int x,y;
+	p += 4;
+	printf("plot '-' with linespoints\n");
+	printf("%g 0\n", - width * .5);
+	for (x = 0; x < width; ++x) {
+	    for (y = 0; y < samples; ++y) {
+		int yy;
+		if (width & 1)
+		    yy = y;
+		else if (y >= samples / 2)
+		    yy = y - samples / 2;
+		else
+		    yy = samples / 2 + y;
+		printf("%g %g\n",
+		       x - width * .5 + (y + .5) * (1.0 / samples),
+		       pixman_fixed_to_double(p[(yy + 1) * width - x - 1]));
+	    }
+	}
+	printf("%g 0\n", width * .5);
+	printf("e\n");
+	fflush(stdout);
+    }
+#endif
 }
 
 void
-- 
1.9.1



More information about the Pixman mailing list