[Pixman] [PATCH v10 04/15] pixman-image: Added enable-gnuplot config to view filters in gnuplot
spitzak at gmail.com
spitzak at gmail.com
Mon Feb 1 22:28:09 PST 2016
From: Bill Spitzak <spitzak at gmail.com>
If enable-gnuplot is configured, 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
v7: First time this ability was included
v8: Use config option
Moved code to the filter generator
Modified scale demo to not call filter generator a second time.
v10: Only print if successful generation of plots
Use #ifdef, not #if
Signed-off-by: Bill Spitzak <spitzak at gmail.com>
---
configure.ac | 13 +++++++++++++
pixman/pixman-filter.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 58 insertions(+)
diff --git a/configure.ac b/configure.ac
index 6b2134e..8066cb2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -834,6 +834,19 @@ fi
AC_SUBST(PIXMAN_TIMERS)
dnl ===================================
+dnl gnuplot
+
+AC_ARG_ENABLE(gnuplot,
+ [AC_HELP_STRING([--enable-gnuplot],
+ [enable output of filters that can be piped to gnuplot [default=no]])],
+ [enable_gnuplot=$enableval], [enable_gnuplot=no])
+
+if test $enable_gnuplot = yes ; then
+ AC_DEFINE(PIXMAN_GNUPLOT, 1, [enable output that can be piped to gnuplot])
+fi
+AC_SUBST(PIXMAN_GNUPLOT)
+
+dnl ===================================
dnl GTK+
AC_ARG_ENABLE(gtk,
diff --git a/pixman/pixman-filter.c b/pixman/pixman-filter.c
index b2bf53f..11c8548 100644
--- a/pixman/pixman-filter.c
+++ b/pixman/pixman-filter.c
@@ -297,6 +297,47 @@ create_1d_filter (int *width,
return params;
}
+#ifdef PIXMAN_GNUPLOT
+/* If enable-gnuplot is configured, 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
+ */
+static void
+gnuplot_filter(int width, int samples, const pixman_fixed_t* p)
+{
+ int x,y;
+ 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 * 0.5 + (y + 0.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
+
/* Create the parameter list for a SEPARABLE_CONVOLUTION filter
* with the given kernels and scale parameters
*/
@@ -342,6 +383,10 @@ pixman_filter_create_separable_convolution (int *n_values,
memcpy (params + 4 + width * subsample_x, vert,
height * subsample_y * sizeof (pixman_fixed_t));
+#ifdef PIXMAN_GNUPLOT
+ gnuplot_filter(width, subsample_x, params+4);
+#endif
+
out:
free (horz);
free (vert);
--
1.9.1
More information about the Pixman
mailing list