[cairo] [Pixman] Supersampling - 2nd attempt

Soeren Sandmann sandmann at daimi.au.dk
Fri Aug 13 20:48:40 PDT 2010


M Joonas Pihlaja <jpihlaja at cc.helsinki.fi> writes:

> > 3. Automatic sampling rate: by default, when the filter is better than
> > nearest neighbor, the image's sampling rate is automatically adjusted
> > to match the transform.
> 
> Okay, this sounds like a good idea, and the results are indeed a vast 
> improvement!
> 
> > This can be turned off by explicitly setting a sampling rate using 
> > pixman_image_set_sampling_rate.
> 
> I don't think pixman needs to expose explicit controls over parameters 
> of a specific algorithm like this function does (it sets individual 
> rates for x and y.)  

For pixman, I think it's important that it is well-defined what it
does. The image pipeline that I'm always going on about:

        - extend the sample grid in all directions

        - convert to premultiplied argb

        - interpolate to define the image on a continuous domain

        - transform

        - resample

        - composite

Currently, the resample step is "point sample", which is why
downscaling looks so bad. It clearly needs to be fixed, but I really
don't want it to become "magic happens here to make it look good". It
should be such that within reason, you can predict what each pixel
will look like.

It may be that cairo should take a more magical approach though. If
so, it might make sense to have a

        pixman_image_set_transform_and_filter (image, transform)

that would set the transform and then compute good filter/sampling
settings based on that transform. 

Also consider that we'll like want to add better resampling to XRender
too. There magic seems even less desirable, so pixman would need to
expose some controls anyway.

> There are lots ways to sample and filter the 
> source, and walking across a regular sampling grid might not always be 
> the best way to go about it.

I agree that the regular super sampling is not necessarily the best
way to do it in all cases, or perhaps even most cases. For example if
people get serious about projective transforms, then adding
anisotropic filtering would make sense. Gradients would likely benefit
from adaptive sampling.



More information about the cairo mailing list