New topic: 

Canvas rendering too slow?

<http://forums.realsoftware.com/viewtopic.php?t=41599>

         Page 1 of 1
   [ 4 posts ]                 Previous topic | Next topic          Author  
Message        lukus001          Post subject: Canvas rendering too 
slow?Posted: Sun Nov 27, 2011 6:51 pm                         
Joined: Sat Jul 16, 2011 2:45 pm
Posts: 30                Hi all,

I have a Window with a container control within it - it's set up so that the 
container control always matches the size of the window.  Within the container 
control is an array of canvases (82 currently) that are of all equal sizes and 
equally spaced out filling up the window...

The problem is, is that it's taking a good 2-3 seconds after the window was 
resized for the canvases to display 

Upon being resized my method is fired which simply re-calculates the position 
of all the canvases, so it does some basic number calculations then there is a 
loop 1-82 setting the x,y positions of each canvas... is there any reason why 
it would have such a large delay?

It briefly looks like you can see them all shifting places pretty much 
instantly then they all dissapear and then all reappear at the same time after 
about 2+ seconds ?   
                             Top                 timhare          Post subject: 
Re: Canvas rendering too slow?Posted: Sun Nov 27, 2011 7:14 pm                  
       
Joined: Fri Jan 06, 2006 3:21 pm
Posts: 10500
Location: Portland, OR  USA                Check how many times the paint event 
of each canvas is firing.  If the canvases are too close together, any changes 
will ripple back and forth until they all settle down.  If you have them 
positioned less than 4 pixels or so from one another, then you may need to 
refactor the design to use a single canvas with multiple display areas.   
                             Top                DaveS          Post subject: 
Re: Canvas rendering too slow?Posted: Sun Nov 27, 2011 8:44 pm                  
               
Joined: Sun Aug 05, 2007 10:46 am
Posts: 3312
Location: San Diego, CA                why not use ONE canvas... and one 
Picture object

divide the picture object into 82 rectangles (or what ever to represent your 
current 82 canvas).

Update the picture object only when a change is required.... 

in the Canvas PAINT event  simply put

Code:
g.drawpicture picobject,0,0



Done right, you can get well over 30 frames per second animation that way      
_________________
Dave Sisemore
MacPro, OSX 10.6.8 RB2011r3
Note : I am not  interested in any solutions that involve custom Plug-ins of 
any kind  
                             Top                lukus001          Post subject: 
Re: Canvas rendering too slow?Posted: Sun Nov 27, 2011 11:50 pm                 
        
Joined: Sat Jul 16, 2011 2:45 pm
Posts: 30                timhare wrote:Check how many times the paint event of 
each canvas is firing.  If the canvases are too close together, any changes 
will ripple back and forth until they all settle down.  If you have them 
positioned less than 4 pixels or so from one another, then you may need to 
refactor the design to use a single canvas with multiple display areas.Well I 
just did some tests and added a counter in - canvas(0) paint event gets fired 
twice which suggests every canvas gets fired twice (82*2) which doesn't seem 
that bad to be honest?

I bound the repositioning to the mouse-down event of the window so the delay is 
somewhere between my repositioning code and the rendering of the images...

So i added a timer - (ticks) at the start and end of my positioning code, which 
takes 28/60th of a second... not sure if that is good or bad but I dont think 
it is too bad personally...

Somewhere after this, 1.5 seconds are being spent displaying these canvases?  

Also, adding code or even just a comment /space to the paint event of the 
canvas or container control changes how the windows responds with the canvases 
strangly enough 

Now the canvases dont instantly dissapear- they only flicker just as they 
change - so once immediatly after the resize (they all get shifted to follow 
the left side of the window as they are all locked to the left size ) and then 
again after my reposition occurs, + now the first image (and a small square 
region in the top left) disappears /gets clipped at the start of my positioning 
code untill they all re-render for some reason unknown to me?



Quote:why not use ONE canvas... and one Picture object

divide the picture object into 82 rectangles (or what ever to represent your 
current 82 canvas).

Update the picture object only when a change is required....

in the Canvas PAINT event simply putit did cross my mind afterwards that maybe 
i should have 1 canvas where i split it up into sections, however I do need 
interactivity that a canvas would easily provide.

Certainly it is posibile to impliment all the features I want with using just 1 
canvas (and it would probably run faster too) but it would make things a bit 
harder to do and manage :/   
                             Top            Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 4 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to