Double-buffering, scrolling and clipping
Hi List, On WinXP I double-buffer my main application pane with a backing pixmap. I also have a power-of-two zoom facility, and my assumption has been that in order to maintain buffering whilst scrolling I have to create a pixmap as large as the scroll-width of my displayed pane. Obviously with power-of-two zooming the off-screen buffer quickly becomes VERY big. Possibly the above is a naive approach, and I'm now searching for an alternative. It seems wasteful, especially since all my drawing is clipped - surely I should be clipping my pixmap as well. Two (related) ideas I have in mind are: 1. Draw directly to the pane, but cache a backing pixmap which is only as big as the viewport. At the end of a paint event copy all pixels from the pane to the pixmap, and then just copy back from the pixmap to any damaged regions later. A new pixmap should be generated on any resize or zoom event. 2. Generate a pixmap with each paint event, and cache it. On scrolling simply copy the relevant section from the cached pixmap to the new one, but shift it by the width of the newly exposed region (which is drawn directly to the pixmap). I suspect this is how a lot of applications manage it, though I haven't found much to go on. I suspect it might not be so efficient in the CAPI, though. The following Qt-related post suggests something like option 2: http://labs.trolltech.com/blogs/2009/02/06/improvements-to-qgraphicsitemcachemodes-insides/ I would be very interested in any thoughts on this (thorny) topic! Many thanks, Chris