[Pixman] [PATCH 3/3] BILINEAR->NEAREST filter optimization for simple rotation and translation

Andrea Canciani ranma42 at gmail.com
Sun May 22 23:43:50 PDT 2011


On Sun, May 22, 2011 at 11:15 PM, Siarhei Siamashka
<siarhei.siamashka at gmail.com> wrote:
> From: Siarhei Siamashka <siarhei.siamashka at nokia.com>
>
> Simple rotation and translation are the additional cases when BILINEAR
> filter can be safely reduced to NEAREST.

I believe that this reduction is valid for any matrix which describes
a unit transform followed
by an integer translation (i.e. rotation(90 degrees), scale(-1,1),
translate(1,0) composed
in any possible way).

This happens whenever the translational component of the matrix is
integral, the projective
component is identity (already tested by AFFINE_TRANSFORM) and the
upper-left 2x2
matrix multiplied by its transpose results in the 2x2 identity.

Andrea

> ---
>  pixman/pixman-image.c |   37 +++++++++++++++++++++++++++++++++++++
>  1 files changed, 37 insertions(+), 0 deletions(-)
>
> diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c
> index 4784c22..583e7a7 100644
> --- a/pixman/pixman-image.c
> +++ b/pixman/pixman-image.c
> @@ -256,6 +256,43 @@ compute_image_info (pixman_image_t *image)
>        {
>            flags |= FAST_PATH_NEAREST_FILTER;
>        }
> +       else if (
> +                /* affine and integer translation components in matrix ... */
> +                ((flags & FAST_PATH_AFFINE_TRANSFORM) &&
> +                 !pixman_fixed_frac (image->common.transform->matrix[0][2] |
> +                                     image->common.transform->matrix[1][2])) &&
> +                (
> +                 /* ... combined with a simple rotation */
> +                 (flags & (FAST_PATH_ROTATE_90_TRANSFORM |
> +                           FAST_PATH_ROTATE_180_TRANSFORM |
> +                           FAST_PATH_ROTATE_270_TRANSFORM)) ||
> +                 /* ... or combined with a simple non-rotated translation */
> +                 (image->common.transform->matrix[0][0] == pixman_fixed_1 &&
> +                  image->common.transform->matrix[1][1] == pixman_fixed_1 &&
> +                  image->common.transform->matrix[0][1] == 0 &&
> +                  image->common.transform->matrix[1][0] == 0)
> +                )
> +               )
> +       {
> +           /* FIXME: there are some affine-test failures, showing that
> +            * handling of BILINEAR and NEAREST filter is not quite
> +            * equivalent when getting close to 32K for the translation
> +            * components of the matrix. That's likely some bug, but for
> +            * now just skip BILINEAR->NEAREST optimization in this case.
> +            */
> +           pixman_fixed_t magic_limit = pixman_int_to_fixed (30000);
> +           if (image->common.transform->matrix[0][2] > magic_limit  ||
> +               image->common.transform->matrix[1][2] > magic_limit  ||
> +               image->common.transform->matrix[0][2] < -magic_limit ||
> +               image->common.transform->matrix[1][2] < -magic_limit)
> +           {
> +               flags |= FAST_PATH_BILINEAR_FILTER;
> +           }
> +           else
> +           {
> +               flags |= FAST_PATH_NEAREST_FILTER;
> +           }
> +       }
>        else
>        {
>            flags |= FAST_PATH_BILINEAR_FILTER;
> --
> 1.7.3.4
>
> _______________________________________________
> Pixman mailing list
> Pixman at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/pixman
>


More information about the Pixman mailing list