[cairo] Best strategy for complex screen drawing
Jim Gettys
jg at freedesktop.org
Tue Nov 22 08:20:31 PST 2005
Actually, on X, there is the double buffer extension. Composite is in
fact for different purposes.
- Jim
On Mon, 2005-11-21 at 12:43 -0800, Bill Spitzak wrote:
>
> Timothée Lecomte wrote:
>
> > 1) Would it be more efficient to use a gdk/cairo surface for the screen
> > (via gdk_cairo_create) and use cairo_set_source_surface to copy the
> > image surface to the screen ? (instead of the image buffer conversion) I
> > suppose the answer is no.
> >
> > 2) Would it be more efficient to use a specific backend ? For example,
> > should I draw to an offscreen Xlib pixmap, and use it as a source
> > surface ? Will I benefit from possible render acceleration ?
> >
> > 3) Are there other solutions that I might have forgotten ?
>
> What you want is double buffering, or backing store, or offscreen
> rendering, or any of a dozen other names. This should be provided by the
> system or the toolkit as some kind of modification to an existing window
> object.
>
> You do not want to do your own "fake" double buffering by allocating
> some other object and doing explicit copies. The reason is that the
> "real" double buffering knows that the image and the window are
> explicitly linked, and can be setup to copy very fast, and it can take
> advantage of the fact that the backing store will not be used for any
> purpose other than to update the visible window. It can resize and
> delete it in sync with the real window, and free it if your window has
> not been displayed for a long time.
>
> It is obvious to me that all future systems will always be in permanent
> double-buffered mode (again cryptically named, in X they call this the
> "composite extension" and in the Windows world they talk a lot about
> transparency, thought that is a trivial side effect). If this is true,
> unless a system is *very* clever and able to figure out that the extra
> buffer you are allocating is being used as a double buffer, then any
> attempts you make to create the double buffer will be a waste of time on
> them, and memory as *two* images will be created, and your code will
> copy from one invisible one to another, and then the system will copy
> from there to the screen window.
>
> So the answer is: if you think you have to create two objects, that is
> wrong. Figure out a way so that there is one object per screen area.
> Examine your system and/or toolkit to find out how to turn this on. If
> it does not seem possible, you must switch toolkits.
>
> You may also find that the toolkit provides the interface but internally
> it is using a pixmap just like you were going to. This is ok. It
> indicates the toolkit authors are thinking about the future and plan to
> rewrite this area, so you should plan for it by using their interface.
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://cairographics.org/cgi-bin/mailman/listinfo/cairo
More information about the cairo
mailing list