[cairo] Tentative patch for downscaling in Cairo

Tavmjong Bah tavmjong at free.fr
Thu Sep 5 12:06:24 PDT 2013


On Thu, 2013-09-05 at 16:17 +0100, Chris Wilson wrote:
> On Sun, Mar 31, 2013 at 05:03:36AM +0200, Krzysztof Kosiński wrote:
> > Hello
> > 
> > I had a look at how complex would it be to add correct downscaling to
> > Cairo now that Pixman supports convolution filters. It turns out it
> > this is rather easy. Here is an initial, minimal attempt. It uses
> > convolution filters only if the image is being downscaled by more than
> > half a pixel in at least one dimension.
> > 
> > Some discussion:
> > 
> > 1. The sampling and reconstruction kernels are picked in a way that
> > gives comparable quality when upscaling and downscaling. I paired box
> > sampling with bilinear reconstruction and impulse (point) sampling
> > with box reconstruction. This gives the expected result for NEAREST
> > filter. BEST filter uses Lanczos3 for both kernels.
> > 
> > 2. Subsampling bits are always set to 1, since this doesn't seem to
> > affect quality at all.
> > 
> > 3. I am not sure whether this code works correctly for matrices with a
> > skew component. It should be OK for any combination of scale, rotation
> > and translation.
> > 
> > 4. This patch causes new failures in the test suite:
> > - recording-surface*: possibly an effect of improved quality.
> > - surface-pattern-scale-down*, surface-pattern-big-scale-down: the
> > reference images should be updated.
> > - pthread-same-source: I have no idea why this is failing, since this
> > test shouldn't even trigger the new code.
> > - large-source-roi: this test attempts to downscale an image which is
> > 30000 pixels wide down to 7 pixels. The filter parameters seem to be
> > created correctly, but they might trigger an overflow somewhere in the
> > convolution code; the output rectangle is white instead of red, as if
> > nothing was drawn.
> > - device-offset-scale: there are subtle differences which look like
> > convolution-related smoothing; I'm not sure whether this is OK or not.
> > 
> > Note that master currently fails many more tests, I only listed new
> > failures cause by this patch.
> 
> Merged to cairo-1.13, many thanks.
> -Chris

Excellent!





More information about the cairo mailing list