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

Bill Spitzak spitzak at gmail.com
Mon Jan 4 09:34:54 PST 2016


On Mon, Jan 4, 2016 at 3:25 AM, Oded Gabbay <oded.gabbay at gmail.com> wrote:

> On Mon, Jan 4, 2016 at 5:12 AM,  <spitzak at gmail.com> wrote:
> > 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
> >
> > _______________________________________________
> > Pixman mailing list
> > Pixman at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/pixman
>
> I get the big picture of this feature, and it seems useful, but we
> need write this according to standards.
> I would like to see the following changes:
>
> 1. We can do something more nice than a hard-coded #define. Let's add
> a flag to configure.ac called "enable-gnuplot-output". For something
> similar, see "enable-timers" in configure.ac. The default will be
> "no".
>

That makes sense. I actually gave up trying to figure out how to set the
CFLAGS and was forced to edit the source code to turn this on/off, which
meant I often mistakenly checked the code in with it turned on. I guess
configure is the way to go.


> 2. Take your code and put it in a new function in pixman-utils.c, and
> make sure the code inside the function is encompassed with
> #ifdef/#endif around it. In case enable-gluplot-output wasn't called,
> the function will be an empty function.
>
> 3. Call that function from compute_image_info. I guess you will want
> to call it only if:
> ((flags & FAST_PATH_SEPARABLE_CONVOLUTION_FILTER) &&
> image->common.filter_params)
> is true.
> However, we don't need to put #ifdef around the call itself.
>

I would prefer that there not be a call to the empty function there, and
that instead the config option removes the call to it here. In addition the
arguments may be non-trivial as I would like this to be able to print
filters from a future mulit-resolution data structure, to extract this from
the current structure I need to pass the width, subsamples, and pointer to
array.


> I think the above steps will create two patches:
> - Step 1&2 should be the first patch (Adding the utility).
> - Step 3 should be the second patch (Using the utility).
>

Ok.


> Is using this is simple as:
> ./<demo/test binary> | gnuplot     ?
>

Yes that is how it works. It works surprisingly well. It is sometimes
useful to go to the gnuplot window and scroll up/down a bit to lock the
current zoom. Hit the button with the squiggle on the top to go back to
auto-zoom.

If so, put an example of how to use it in the second commit message.
>
> Thanks,
>
> Oded
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/pixman/attachments/20160104/7c6befc8/attachment-0001.html>


More information about the Pixman mailing list