[cairo] Cairo double buffer example
David Björkevik
david at bjorkevik.se
Fri Mar 13 09:33:39 PDT 2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Davide Calaminici wrote:
> i'm trying to make a simple screensaver in cairo. The problem that cairo -
> for the system i use - is not yet hardware accelerated and the drawing
> result very slow. There is an example, somewhere, that explain how to create
> and use a double buffer? Draw in a buffer, then swap to the main buffer on
> video. I hope this can increase the speed.
Not an example, but an outline and some pointers:
1. Create a cairo image surface using cairo_image_surface_create
2. Create a cairo context using cairo_create(surface)
3. Do drawing to your new context
4. Destroy the context
5. Using your original (screen) context, use
cairo_set_source_surface(context,surface,0,0)
6. Use cairo_paint(contxt) to transfer the thing
7. cairo_surface_destroy(surface)
For newer cairo you can also use cairo_push_group and
cairo_pop_group_to_source.
Hope this helps.
/David
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iEYEARECAAYFAkm6iuMACgkQXhAbONZozjJ+bQCbB2RDK0f2m1Xk/cfCXHuOyUUa
BIsAn0alAaWToNF1PCPMxbKpNc/vWAu3
=MiJ/
-----END PGP SIGNATURE-----
More information about the cairo
mailing list