[cairo] MIPMAPPING cairo.

Jeff Muizelaar jeff at infidigm.net
Thu Oct 16 08:31:19 PDT 2008

On Thu, Oct 16, 2008 at 09:19:33AM -0400, Frédéric Plourde wrote:
> >
> >The other one I would like to try is integer-sized box filtering 
> >followed by the bilinear filter. The idea is to reuse the XRender 
> >code, but get better down-scaling. And there would be a slight amount 
> >of caching for similar scales.
> Ok, let's debate about that and find pros and cons of both box filtering 
> approaches that were proposed here :
> 1 - First, if I understand Bill correctly, the first approach would be 
> to box-filter-downscale at nearest integer level, + bilinear to the 
> target factor.
> Example :
>   let's say we're downscaling a 100 X 100 image by a factor of 0.22 
> (4.54 X downscale) , you would first generate a scaled image at 
> downscale factor 0.25 (4X and  "25 X 25" pixels) and cache it.
>   second, you'd bilinearly downscale that cached image to size 22 X 22, 
> and since that last scale is under 0.5 factor, the bilinear result is 
> valid, since there's no "hole" in the bilinear sampling process.
> 2 - Jeff's idea is more straightforward. It goes directly to target 
> factor without caching.
> Example:
>   starting with that first 100 X 100 image, the first and only step 
> would be to box-filter-downscale it to 22 X 22.

Further, if the affine transformation is not rectangular, the 22x22
image is then sampled bilinearly to the appropriate transformation.

> Pros and cons:
> ------------------
> I personally think that the "best" choice is tightly bound to someone's 
> intended usage of it. For example, here at Mozilla, we've tried the 
> mipmapping approach for "best" downscaling quality in Firefox3, but it 
> would take too much memory, and the speed gain was not too satisfying 
> because the end user would not zoom web pages across multiple zoom 
> factors so much. So our goal for a new sampling technique in Cairo would 
> be the "smallest memory needs"... and we would go for Jeff's solution.
> On the other hand, if such memory requirements were not an issue, one 
> could definitely choose Bill's solution.
> I'm pretty sure both solution could get similar final quality... the 
> question is really about memory usage and performance.

Resizing directly should have a significant performance advantage
especially for the common case where the transform is only scaling.


> Because of that specific need from one of cairo's most important users, 
> I would definitely go for the simplest case : "plain box filtering to 
> target scale factor",  for now (before Firefox 3.1 release, of course 
> ;-) and be open to move on with Bill's solution later on.

I agree.


More information about the cairo mailing list