[cairo] MIPMAPPING cairo.

Frédéric Plourde frederic.plourde at polymtl.ca
Thu Oct 16 06:19:33 PDT 2008


>
> 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.


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.


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.

-fred-



More information about the cairo mailing list