[cairo] Slow painting of images

Haakon Riiser haakon.riiser at fys.uio.no
Sat Nov 5 15:42:29 PST 2005


> On Wed, 26 Oct 2005 14:12:26 +0200, Haakon Riiser wrote:
> > 
> > I've recently started experimenting with the Cairo library, and I
> > think I'm doing something wrong.  I'm trying to display some PNG
> > images, and although it works, it is _extremely_ slow.  Take a look
> > at the test program shown below
> 
> The code in your program looks just fine.
> 
> I think what's happening here is that your X server is using a very
> slow means of transforming images. Try commenting out the call to
> cairo_scale in your program and see if it doesn't get much faster. If
> it does, then we know it's the image transformation operation that is
> hurting.

Most of the slowness is caused by the scale operation.  On my
laptop, a 1.6 GHz Pentium M, scaling a 600x600 PNG to fit a
1024x768 window takes approximately 2.9 seconds.  Displaying a
1024x768 PNG in a window of the same size takes 0.7 seconds,
so the scale operation is mostly to blame.  Still, I timed the 0.7
second operation to see where its CPU time went, and most of it
(75 %) was still used by the X server to display the image.
Subtracting the time spent in the client program, it takes the X
server 0.5 seconds to paint a 1024x768 image, which is still quite
slow. :-/

> Cairo uses the X server's Render extension to transform images. With
> some combinations of hardware and X server drivers the Render
> extension can provide accelerated image transformation. However, when
> this is not available, you get Render's software image transformation
> which is a piece of code that clearly needs some optimization work.
> 
> I don't know what your application needs are, but you might be able to
> work around slow image transformation by transforming once, (for
> example, paint into an intermediate surface created with
> cairo_surface_create_similar), and then subsequently using that result
> without additional transformation.
> 
> I hope that's of some help.

Yes, thank you.  Didn't know that Cairo used the Render extension.
My X log says

(WW) RADEON(0): Direct rendering not yet supported on Radeon 9500 and newer
(II) RADEON(0): Render acceleration disabled

so that explains some things.  Anyway, I don't really need
the scaling, so I can live with it being slow when it's done
in software, but it's a bigger problem that painting images in
native size is also slow.  Could this also be related to the Render
thing?  Other applications, like Firefox, have no problems and
clearly use 2D hardware acceleration, so there has to be something
that could be improved here.

-- 
 Haakon


More information about the cairo mailing list