[cairo] Blitting and sprites in Cairo
Donn
donn.ingle at gmail.com
Wed May 15 02:34:05 PDT 2013
On 15/05/2013 11:07, Chris Wilson wrote:
> Assuming you've disposed off the background layer and only have the
> frontbuffer left - yes, you would need to make a copy of the area to
> be damaged (after undoing the old sprite and before applying the
> new).
Not really following you here. Also, how does one make that copy of the
background area (to be damaged)? Which cairo function would extract a
rect from some other surface/pattern?
> However, since you will want to double-buffer the expose event at
> least, you can use that as a composition step and not burn the
> sprites into the backdrop.
Is paint()ing pre-rendered source patterns fast enough?
What if I have quite a long stack of them to draw before I get to the
sprite?
i.e. bg1, bg2, bg3 ... bg22, then a sprite that moved 2 pixels.
In this case, I had hoped to have this kind of approach:
if only the sprite has moved:
do not double buffer - i.e. no clearing.
replace old damage rect (erase sprite)
get damageable rect <-- the unknown factor.
draw sprite in new pos.
else
draw everything from bottom to top + sprite at new pos.
Apropos to this: Is there a way to copy everything on the
surface/window/buffer (I'm not sure of the term - I mean the GTK widget
I'm drawing on - the original context) to a single buffer - so next
frame I can draw once rather than loop and composite all the bgs? (Then
I'd draw the sprite in the new pos.)
\d
More information about the cairo
mailing list