Yes, you can get back initial canvas performance through using multiple canvas items. This method may work best if your previously placed items are static and should be behind any newer items. If there are multiple dynamic layers between multiple static layers, more than two canvas items may be the route to go.
In short, you can create a canvas, load as much as you want on it, and when you want better performance, create a new canvas, and add items to it. Upon creating the new canvas, you want to first display any older canvases you have, in order of creation (or whatever z-order you see fit), and then display the new canvas. The important thing to note is that you need to sleep between the show methods on each canvas (otherwise the previous show() method doesn't finish). In my testing, I showed 11 milliseconds to be sufficient between show commands (10 ms didn't work), but I have by canvas show method wrapped in a class, so there may be some additional delay imposed from that. I suspect 20 ms would be fine in all cases.
The following pseudo-code should illustrate how I tested this (the actual code uses some classes I created that make my life easier, but explaining this harder, so pseudo code is probably the best choice here):
canvas = new canvas
cavas.port(new port)
nextlayer=0
for i=1 to 50
' draw random image to canvas at random location
nextlayer = nextlayer +1
canvas.setlayer(nextlayer, random_image_random_location())
end for
canvas.show()
canvas_stack = []
while true
msg = wait on canvas event
if type(msg) = canvas event
' if we get a play button, start a new canvas to get better performance
if buttonpress = play
canvas_stack.push(canvas)
for each c in canvas_stack
c.show()
sleep(20)
end for
canvas = new canvas
canvas.port(original canvas port)
end if
' draw random image to canvas at random location
nextlayer = nextlayer +1
canvas.setlayer(nextlayer, random_image_random_location())
canvas.show()
end if
end while
What you see with this is that after about 30-60 images on a canvas, it starts to really lag as you add more images, to the point where it can take 2-3 seconds to actually display it, instead of the 100 ms you generally see for new blank canvas items. Pressing the play button after noticing this will throw the current canvas onto the stack so it can be redisplayed at will, and reassigns a new canvas to the current canvas var.
Note: I'm re-showing all the canvas objects when creating a new one, but since I'm strictly advancing the layer I could omit this, but I included it to show that it does work with the delay I mentioned.
-- GandK Labs
Check out Reversi! in the channel store!