Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Mon Oct 23, 2017 7:05 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: minimise canvas paint events
PostPosted: Wed May 08, 2013 8:14 pm 
Offline

Joined: Thu Feb 03, 2011 4:15 pm
Posts: 4
I'm creating simple graphs in a canvas. The canvas paint event fires multiple times with each screen refresh. This is not a problem when only a few hundred points are being plotted, but the time to display tens of thousands of points is unaccepatble. Is there som way to have the canvas paint event only fire once?

Thanks

Brian


Top
 Profile  
Reply with quote  
 Post subject: Re: minimise canvas paint events
PostPosted: Wed May 08, 2013 10:35 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
It usually does fire only once. Do you have controls that overlap the canvas? Are you calling Refresh in more than one place?


Top
 Profile  
Reply with quote  
 Post subject: Re: minimise canvas paint events
PostPosted: Thu May 09, 2013 6:15 pm 
Offline

Joined: Thu Feb 03, 2011 4:15 pm
Posts: 4
Thanks for thte thought Tim.

There are no controls that overlap the canvas. I do have a couple that come to 1 pixel outside the canvas, both to the left of the canvas and below the canvas.

Canvas painting is done by a button that fires the refresh method. Both self.refresh and canvas.refresh have been tested. Self.refresh is being used because with canvas.refresh controls to the left of the canvas are no longer visible. Running 2011r4.1

Brian


Top
 Profile  
Reply with quote  
 Post subject: Re: minimise canvas paint events
PostPosted: Thu May 09, 2013 8:38 pm 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
Try replacing REFRESH with INVALIDATE instead

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: minimise canvas paint events
PostPosted: Thu May 09, 2013 9:24 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
d_tran wrote:
I do have a couple that come to 1 pixel outside the canvas, both to the left of the canvas and below the canvas.

That is too close. I think you need 2 px minimum, maybe more. 1 pixel away is the same as overlapping, on Windows.


Top
 Profile  
Reply with quote  
 Post subject: Re: minimise canvas paint events
PostPosted: Sun May 19, 2013 6:29 pm 
Offline

Joined: Thu Feb 03, 2011 4:15 pm
Posts: 4
Thanks for your input.

I have moved the controls to the right of the canvas and now refreshing the canvas doesn't hide them.

The controls are still only 1 px away from the canvas and a window refresh fires the paint event at least twice so I woll put a greater gap between them.

I'm having trouble getting my head around the INVALIDATE concept. Somehow the concept of the word invalidate in a non-comp sci usage doesn't seem to address changing what is being presented on the screen.


Top
 Profile  
Reply with quote  
 Post subject: Re: minimise canvas paint events
PostPosted: Sun May 19, 2013 6:37 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
Invalidate marks the canvas as needing to be redrawn. It will be redrawn in the next cycle of the event loop. Refresh forces the canvas to be redrawn immediately. The benefit to invalidate is that you can call it multiple times and the canvas may only be redrawn once (if the invalidate calls all happen before the next cycle of the event loop). Calling refresh multiple times causes the canvas to be redrawn multiple times. Invalidate can be easier on the system resources and make your app feel snappier, provided of course that your code isn't blocking the event loop.


Top
 Profile  
Reply with quote  
 Post subject: Re: minimise canvas paint events
PostPosted: Sun May 19, 2013 6:39 pm 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
REFRESH updates your control IMMEDIATELY... call canvas.refresh 100x and it fires PAINT event 100x, probably 99 times more than necessary.

INVALIDATE marks the control as NEEDING to be refreshed. call canvas.invalidate 100x and it may call PAINT once....but it will call it when it can/has to thus removing the need for you to keep track (most of the time).

When I first changed an app from REFRESH to INVALIDATE (no other changes)... it ran 10-20x faster.... and the visual results were exactly what I wanted and what I expected.



AND TIM GOT THERE FIRST :)

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: minimise canvas paint events
PostPosted: Sun May 19, 2013 6:47 pm 
Offline

Joined: Thu Feb 03, 2011 4:15 pm
Posts: 4
Thanks Tim and Dave,

A clear description.

I'm just curious to know how frequently does the event loop run? I know it must be the order of microseconds to pick up random mouse clicks.

If this is straying too far from topic, please accept my apologies.

Cheers

Brian


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group