[cairo] [PATCH] CAIRO_FILTER_BEST uses NEAREST filter when possible
Bill Spitzak
spitzak at gmail.com
Fri Aug 1 19:24:26 PDT 2014
This avoids slow filtering for identity transforms when BEST is used.
Pixman is already handling the GOOD case.
---
src/cairo-image-source.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/src/cairo-image-source.c b/src/cairo-image-source.c
index b6b6b9f..3d10953 100644
--- a/src/cairo-image-source.c
+++ b/src/cairo-image-source.c
@@ -955,6 +955,25 @@ _pixman_image_set_properties (pixman_image_t *pixman_image,
}
break;
case CAIRO_FILTER_BEST:
+ /* Check for 1:1 pixel transfer and use NEAREST for that */
+ if (_cairo_fixed_is_integer (_cairo_fixed_from_double
+ (pattern->matrix.x0)) &&
+ _cairo_fixed_is_integer (_cairo_fixed_from_double
+ (pattern->matrix.y0))) {
+ cairo_fixed_t xx = _cairo_fixed_from_double(pattern->matrix.xx);
+ cairo_fixed_t xy = _cairo_fixed_from_double(pattern->matrix.xy);
+ cairo_fixed_t yx = _cairo_fixed_from_double(pattern->matrix.yx);
+ cairo_fixed_t yy = _cairo_fixed_from_double(pattern->matrix.yy);
+ if ((xy == 0 && yx == 0 &&
+ abs(xx) == CAIRO_FIXED_ONE &&
+ abs(yy) == CAIRO_FIXED_ONE) ||
+ (xx == 0 && yy == 0 &&
+ abs(xy) == CAIRO_FIXED_ONE &&
+ abs(yx) == CAIRO_FIXED_ONE)) {
+ pixman_filter = PIXMAN_FILTER_NEAREST;
+ break;
+ }
+ }
pixman_filter = PIXMAN_FILTER_BEST;
pixman_filter = PIXMAN_FILTER_SEPARABLE_CONVOLUTION;
kernel = KERNEL_CATMULL_ROM; /* LANCZOS3 is better but not much */
--
1.7.9.5
More information about the cairo
mailing list