[Pixman] [PATCH] test: Add cover-test

Søren Sandmann soren.sandmann at gmail.com
Wed Sep 2 07:57:27 PDT 2015


On Wed, Sep 2, 2015 at 7:56 AM, Pekka Paalanen <ppaalanen at gmail.com> wrote:


> Right. I looked at fast_bilinear_cover_iter_init() and
> fast_fetch_bilinear_cover() -> fetch_horizontal(), and yes, that really
> is how it is implemented. The leftmost pixel is chosen essentially by
> n = pixman_fixed_to_int(x - pixman_fixed_1 / 2).
>
> So, pixman_fixed_1 / 2 -> 0, not -1.
>
> The thing that confuses me is that with nearest, x=0 will sample pixel
> n=-1. However with bilinear, x=0.5 will sample pixels n=0 and n=1, not
> n=-1 and n=0.
>
>
Pixman's rounding rules can be confusing, but they do have an internal
logic:
The important thing to understand is that pixel 0 has coordinate 0.5, pixel
-1
has coordinate -0.5, pixel 1 has coordinate 1.5. In general, pixel n has
coordinate
n + 0.5.

Given that, and given that we always break ties by rounding down, we find
that,
for NEAREST: a coordinate of 0.5 is exactly at pixel 0, so we should use
that.
A coordinate of 0 is precisely midways between pixels -1 and 0, so since we
round
down, pixel -1 is the one to use.

For BILINEAR, x=0.5 is precisely at pixel 0, so that must be used with a
weight of 1.
The other pixel could be either -1 or 1 since it will have a weight of 0 in
either case.
But since we round down, -1 it is.

There are some more details about rounding in the file pixman/rounding.txt.



Søren
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/pixman/attachments/20150902/3c5a4650/attachment.html>


More information about the Pixman mailing list