[Pixman] [PATCH 1/4] Change conditions for setting FAST_PATH_SAMPLES_COVER_CLIP flags

Ben Avison bavison at riscosopen.org
Fri Sep 11 17:26:48 PDT 2015

On Fri, 11 Sep 2015 10:13:08 +0100, Pekka Paalanen <ppaalanen at gmail.com> wrote:
> If you actually want to document things, then I think
> pixman/rounding.txt would be the right place (and another patch). After
> all, commit messages are only used to justify the patch, they are not
> documentation people usually read.

Somehow, I don't remember ever having noticed that file! Perhaps it was
because it was called rounding.txt that it never occurred to me that
filtering might be documented there?

It's an odd omission that it doesn't talk about BILINEAR filtering,
though. However, having briefly read through the text, even though some
of it goes over my head a bit, I'd say it's describing from a strictly
mathematical point of view. Discussion of exactly which pixels get loaded
 from memory in order to reach this mathematical outcome feels outside the
scope of that document to me.

Here's a draft section for BILINEAR filtering, comments welcome:

---- 8< -----

-- BILINEAR filtering:

The BILINEAR filter calculates the linear interpolation between (i.e. a
weighted mean of) the two closest pixels to the given position - one
found by rounding down, one by rounding up.

      round_up(x) = ceil(x - o) + o
      round_down(x) = floor(x - o) + o

The weight factor applied to each of these is given by

      1 - abs(round(x) - x)

except in the case where two to rounding functions amount to the same
pixel - which only occurs if the given position aligns precisely with one
pixel. In that case, that one pixel value is used directly.

A common simplification, to avoid having to treat this case differently,
is to define one (and only one) of the two round functions such that when
the given positions aligns with a pixel, abs(round(x) - x) = 1, and hence
the corresponding weight factor is 0. Either of the following pairs of
definitions satisfy this requirement:

      round_down(x) = floor(x - o) + o
      round_up(x) = round_down(x) + 1

      round_up(x) = ceil(x - o) + o
      round_down(x) = round_up(x) - 1

---- 8< -----


More information about the Pixman mailing list