[Gambas-user] DrawingArea problems

Benoit Minisini gambas at ...1...
Wed Oct 11 10:31:33 CEST 2006


On Wednesday 11 October 2006 09:21, Timothy Marshal-Nichols wrote:
> > -----Original Message-----
> > From: gambas-user-bounces at lists.sourceforge.net [mailto:gambas-user-
> > bounces at lists.sourceforge.net] On Behalf Of Benoit Minisini
> > Sent: 10 October 2006 18:42
> > To: mailing list for gambas users
> > Subject: Re: [Gambas-user] DrawingArea problems
> >
> > On Tuesday 10 October 2006 19:20, Christopher Brian Jack wrote:
> > > Is there a glitch with drawing to DrawingAreas?
> > >
> > > My former code to use a backbuffer:
> > >
> > > ========== 8x ==================================
> > >
> > > private backBuffer as Picture
> > >
> > > public sub Form_Open()
> > >   '...
> > >   backBuffer=new Picture(640,480,FALSE)
> > >   '...
> > > End
> > >
> > > public sub Render()
> > >   Draw.Begin(GfxArea)  'GfxArea is a DrawingArea
> > >   Draw.Picture(backBuffer,0,0,0,0,640,480) 'buckBuffer is a Picture
> > >   Draw.End()
> > >   'Blank back buffer
> > >   Draw.Begin(backBuffer)
> > >   FillRect(0,0,640,480,&H000000&)
> > >   Draw.End()
> > > End
> > >
> > > ========== 8x ==================================
> > >
> > > Is not drawing to the DrawingArea any more.  Is there a semantic
>
> that
>
> > > changed that makes this so it has to be done differently or is
>
> something
>
> > > in 1.9.44 broken thus causing this...?
> >
> > This won't work if you don't set the Drawing.Cached property.
> >
> > Anyway, what you want to do is what is already done by the
>
> Drawing.Cached
>
> > property. Unless you need the back buffer for doing something other
>
> than
>
> > drawing on it...
>
> I have found that there are two reasons for using a buffer like this:
>
> 1. If you have lots of small objects to draw it can look better as you
> do not see all the background objects draw over the foreground objects.
> You reduce the screen flicker as objects are drawn.

This is exactly what DrawingArea.Cached = True does.

>
> 2. It can be faster, again if you have a lot of objects to draw. Drawing
> to memory is faster than drawing to the screen. So if background objects
> get covered by foreground objects. You can speed things up if you draw a
> more complex picture or image to the screen.
>
> Both these points depend on what you are drawing. They are not true in
> all cases. So you need to experiment.
>
> The other point I would make is that I would make the backBuffer an
> Image. An Image is stored in memory while a Picture is stored on the X
> server.
>

My God, no! Drawing to memory is always slower than drawing to the screen. 
Because of what you said: an Image is stored in the client memory, and a 
Picture is stored on the server. You cannot draw an Image on the screen 
directly, it must be sent to the server first. And this is slow.

There is X extension named XSHM that allows the client to share memory with 
the X server so that you have a direct access to what is drawn. But 
apparently it is buggy and so useless.

Regards,

-- 
Benoit Minisini





More information about the User mailing list