[Pixman] [PATCH v8 03/14] pixman-image: Added enable-gnuplot config to view filters in gnuplot
spitzak at gmail.com
spitzak at gmail.com
Mon Jan 4 21:48:50 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
v8: Use config option
Moved code to the filter generator
Modified scale demo to not call filter generator a second time.
v7: First time this ability was included
Signed-off-by: Bill Spitzak <spitzak at gmail.com>
---
configure.ac | 13 +++++++++++++
demos/scale.c | 29 +++++++++++++++++++----------
pixman/pixman-filter.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 77 insertions(+), 10 deletions(-)
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/demos/scale.c b/demos/scale.c
index 06821e3..881004e 100644
--- a/demos/scale.c
+++ b/demos/scale.c
@@ -258,16 +258,25 @@ rescale (GtkWidget *may_be_null, app_t *app)
pixman_transform_from_pixman_f_transform (&transform, &ftransform);
pixman_image_set_transform (app->original, &transform);
- params = pixman_filter_create_separable_convolution (
- &n_params,
- sx * 65536.0 + 0.5,
- sy * 65536.0 + 0.5,
- get_value (app, filters, "reconstruct_x_combo_box"),
- get_value (app, filters, "reconstruct_y_combo_box"),
- get_value (app, filters, "sample_x_combo_box"),
- get_value (app, filters, "sample_y_combo_box"),
- gtk_adjustment_get_value (app->subsample_adjustment),
- gtk_adjustment_get_value (app->subsample_adjustment));
+ if (get_value (app, filter_types, "filter_combo_box") ==
+ PIXMAN_FILTER_SEPARABLE_CONVOLUTION)
+ {
+ params = pixman_filter_create_separable_convolution (
+ &n_params,
+ sx * 65536.0 + 0.5,
+ sy * 65536.0 + 0.5,
+ get_value (app, filters, "reconstruct_x_combo_box"),
+ get_value (app, filters, "reconstruct_y_combo_box"),
+ get_value (app, filters, "sample_x_combo_box"),
+ get_value (app, filters, "sample_y_combo_box"),
+ gtk_adjustment_get_value (app->subsample_adjustment),
+ gtk_adjustment_get_value (app->subsample_adjustment));
+ }
+ else
+ {
+ params = 0;
+ n_params = 0;
+ }
pixman_image_set_filter (app->original,
get_value (app, filter_types, "filter_combo_box"),
diff --git a/pixman/pixman-filter.c b/pixman/pixman-filter.c
index b2bf53f..fe0d261 100644
--- a/pixman/pixman-filter.c
+++ b/pixman/pixman-filter.c
@@ -297,6 +297,47 @@ create_1d_filter (int *width,
return params;
}
+#if 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
*/
@@ -346,5 +387,9 @@ out:
free (horz);
free (vert);
+#if PIXMAN_GNUPLOT
+ gnuplot_filter(width, subsample_x, params+4);
+#endif
+
return params;
}
--
1.9.1
More information about the Pixman
mailing list