[cairo] MIPMAPPING cairo.

Jeff Muizelaar jeff at infidigm.net
Wed Oct 15 12:59:24 PDT 2008

On Wed, Oct 15, 2008 at 09:14:04AM -0400, Frédéric Plourde wrote:
> > Are you sure this bilinear sample is correct? It looks far worse than 
> > anything I have seen. Looks more like the image was scaled to 50% and 
> > the binlinearly scaled up. The current algorithim only fails if the 
> > scale is less than 60% or so.
> Mhh.. yep, pretty sure. What's happening maybe is that the source image 
> "http://img58.imageshack.us/img58/8669/src1231x1504np1.png" gets 
> automatically resized in FF3 (and other browsers ?), but is really 
> bigger than it seems. So, we're really talking about downscaling with a 
> large factor.... which kills text image as you've seen.

It looks to me like
is the wrong image. Bilinear filtering shouldn't look that, and it
doesn't match what I get when I run the test program myself.

> >
> > Users are interested in these settings:
> >
> > 1. "nice" scaling. They don't care one bit about the algorithm. This 
> > is the default, and emulation of the existing Cairo API should turn 
> > "BILINEAR" into this.
> >
> > 2. "no antialiasing" which is the same as "nearest" here. The purpose 
> > is to emulate really bad backends. Emulation of the existing Cario API 
> > should turn "NEAREST" into this.
> >
> > 3. *maybe* they are interested in "even nicer but slower". However in 
> > my experience all backends eventually merge "nice" and "even nicer but 
> > slower" into the same algorithm.
> >

"even nicer but slower" could use a lanczos filter which is probably
overkill for most situations but a good fit for BEST.

> Anyway,  mipmapping is good, as we all know, for animation-like series 
> of redrawings. That's where it wins... if not, the pyramid-building step 
> overhead is so large that we certainly DON'T want to use mipmapping for 
> one-shot scalings !  That's why a simple yet very nice box filtering 
> algorithm (written by jeff muizelaar) is on its way to be reviewed here 
> within the next few days.

I think it may make sense to have an API to control the generation of
mip-maps. I'm not sure what it would look like though.

Skia has:
	SkBitmap::buildMipMap(bool forceRebuild);
Which does what you'd expect. I'm guessing the forceRebuild flag is used
for when you modify the bitmap contents and need to regenerate the

Qt has code for generating OpenGL mipmaps using GL_GENERATE_MIPMAP_SGIS,
though it's not clear to me when it's used and when it isn't.


More information about the cairo mailing list