[Pixman] [PATCH v9 03/15] pixman-image: Added enable-gnuplot config to view filters in gnuplot

Oded Gabbay oded.gabbay at gmail.com
Mon Feb 1 06:11:56 PST 2016


On Mon, Feb 1, 2016 at 4:10 PM, Oded Gabbay <oded.gabbay at gmail.com> wrote:
> On Fri, Jan 22, 2016 at 11:42 AM,  <spitzak at gmail.com> wrote:
>> 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

One more thing. The vX comments should be ordered from first to last
(old to new), so:
v7: ...
v8: ...

Oded

>>
>> 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;
>> +    }
>
> Wait, what the above code has to do with this patch ?
> It wasn't in the previous version (v7) and I don't see how it is
> related to the gnuplot.
> This seems like a fix to the demo code.
> If what I said is correct, please split it into a different patch.
>
>>
>>      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
>
> To keep consistency with other defines checks, please use #ifdef when
> checking just one define
>
>> +/* 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
>
> To keep consistency with other defines checks, please use #ifdef when
> checking just one define
>
>> +    gnuplot_filter(width, subsample_x, params+4);
>> +#endif
>> +
>
> What's the point in printing the filter after the out: label ?
> You can get here in cases where there were errors in the function.
> Why not put the call to gnuplot_filter() just before the out: label ?
>
> Thanks,
>
>        Oded
>
>>      return params;
>>  }
>> --
>> 1.9.1
>>
>> _______________________________________________
>> Pixman mailing list
>> Pixman at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/pixman


More information about the Pixman mailing list