[cairo] High Quality ImagePattern Scaling
Frédéric Plourde
frederic.plourde at polymtl.ca
Tue Sep 9 05:11:59 PDT 2008
Hi Bill !
We discussed that during a hacking session on the Cairo Summit last week.
Jeff Muizelaar had already developped something close to what you're
talking about and should be pushing that into pixman soon if I'm
correct. It's been decided also that mipmaping would be included in
pixman as well for users with animation needs.
Best,
-fred-
Bill Spitzak a écrit :
> Vladimir Vukicevic wrote:
>
>
>> We actually talked about solving this at the Cairo summit yesterday,
>> and should hopefully have it fixed in a day or so -- there will be a
>> high-quality mipmapping option, as well as a less memory intensive
>> option.
>>
>
> Did you consider the idea I posted where it picks the next larger
> integer down-scale and produces that image, and then uses the current
> interpolation for it?
>
> Creating a mipmap is expensive and it works poorly if the horizontal and
> vertical scales are different or if they are not near powers of 2. It
> only wins if you expect to draw the same image at many scales, such as
> when it is a texture map for a 3D object that moves in Z. Since Cairo
> does not do perspective transforms it cannot do this use case.
>
> If instead this integer-scaled single version was cached using the code
> you plan to use for caching the mipmap, it would speed up the most
> common case (drawing the same image with the same scale over and over),
> produce better scaling, and the cache would be created much faster and
> use less memory than the mipmap.
>
> Some more detail:
>
> From the transform, figure out a scale of x=1/A,y=1/B where A and B are
> integers. If the transform has no rotation, these are
> max(1,ceil(1/fabs(xscale))) and max(1,ceil(1/fabs(yscale))).
>
> Getting A and B when there are rotations is more complicated :-)
>
> If A==B==1 then ignore the cache and use the image. Otherwise see if
> this is the A,B used by the current cached image, if not, throw away the
> cached image and create a new one with this scale. This is really fast
> as each pixel is just the average of a non-overlapping rectangle of
> source pixels.
>
> Divide the transform by this scaling to get the transform from the
> scaled image to the final, and use this to run the existing XRender
> transform.
>
>
More information about the cairo
mailing list