To: alex at baretta.com Cc: lablgtk at kaba.or.jp Subject: Re: Scrolling an image efficiently In-Reply-To: <402D1FA6.2000203 at baretta.com> References: <402D1FA6.2000203 at baretta.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20040214192441Q.garrigue at kurims.kyoto-u.ac.jp> Date: Sat, 14 Feb 2004 19:24:41 +0900 From: Jacques Garrigue Lines: 45 From: Alex Baretta > I need to scroll a fullscreen image efficiently, at constant speed (a > full screen's width every 3-10 seconds), with a constant framerate, and > in sync the actual screen refresh. Even if this seems a banal task, the > stringent requirement of refreshing the screens buffer synchronously > makes it far from trivial. > > Theoretically all I need to do is create a number of pixmaps containing > each a slice of the image I need to scroll and redraw all the slices > afther shifting them by one between screen refreshes. However, I have to > redraw a 1280x1024 32bit screen at close to 100Hz (worst case scenario). > I fear the object oriented style of lablgtk might make this library too > slow to achieve such performace (at least without hogging the cpu). I don't know exactly how you plan to do it. Nor where the performance bottleneck lies. If you have to draw your image point-by-point, then you should definitely use a Gdk image rather than directly write to a pixmap, to avoid context switches. And I don't think that there is an OO-level interface to Gdk images in lablgtk (they are there for performance). Using X, it's probably a good idea to make them `SHARED. So I would see something like * Create the original image, and build a pixmap from it with GDraw.drawable#put_image Then for the scrolling * Create a one-line shared image for the new part * create a new pixmap, and copy the old pixmap to it with GDraw.drawable#put_pixmap; add the new line with GDraw.drawable#put_image You could of course use Gdk.Draw rather than GDraw.drawable, but there is little point: the cost of the method call is here negligible compared to the operation cost, particularly if you think that the actual work has to be done on the server side, after a context switch. Note also that you may need to do a Gdk.X.flush after writing your pixmap to the screen, to be sure you keep in sync. Hope this helps. Maybe somebody has actual experience with doing this: my suggestions are only theoretical. Jacques