Yes - use a cache form for drawing the points directly and pass the entire image to FormCanvas, ala:
"Create some random points" rnd _ Random new. points _ (1 to: 5000) collect:[:i| (rnd next @ rnd next * 400) asIntegerPoint]. "Make us a canvas" fc _ FormCanvas on: Display. "Create a cached form for drawing all these points" cacheForm _ Form extent: 400@400 depth: Display depth. "Setup BB" bb _ BitBlt toForm: cacheForm. bb combinationRule: Form over. bb width: 1; height: 1. bb fillColor: Color red. "Now draw these points offscreen" points do:[:pt| bb destOrigin: pt; copyBits]. "And finally paint the entire image" fc paintImage: cacheForm at: 0@0.
This should be a lot faster than anything else.
- Andreas
-----Original Message----- From: Gerardo Richarte [mailto:core.lists.squeak@core-sdi.com] Sent: Tuesday, May 02, 2000 6:20 PM To: squeak@cs.uiuc.edu Cc: recipient list not shown Subject: Re: BitBlt >> #pixelAt:put: speed
Andres Valloud wrote:
Is there anything faster I can do? for example using Balloon somehow?
Are you trying to do that directly on the World's canvas? Did you try to draw them in a buffer and then draw the buffer form?
Eh! Andres! (que haces? como va todo por ahi?)
I'm not sure what am I doing, I'm just drawing on the canvas I get as argument in Morph >> #drawOn: So you think I should use an intermediate Canvas for this?
Thanks!
Liencistas Bye! (just for spanish speaking people, sorry) Richie++
"Raab, Andreas" wrote:
Yes - use a cache form for drawing the points directly and pass the entire image to FormCanvas, ala:
bb _ BitBlt toForm: cacheForm. bb combinationRule: Form over. bb width: 1; height: 1. bb fillColor: Color red. "Now draw these points offscreen"
Hey! Thanks a lot to you all...
Using your code, I speeded everything from ~2000 ms to ~350 ms.
BUT, I didn't need to use an itermediate cacheForm, I'm just drawing to the Form I get as argument to #drawOn: (aCanvas form), insted of creating a new one, and the performance is the same (a little better because I'm not copying from form to form). The major speed gain is in caching the 1 by 1 BitBlt, and then using it to draw in the canvas. Now 99% of the time is consumed in primitives... is there anything else I can do? Or from here on do I need to improve the algorithm?
Improved Bye! Richie++
PS: Here's my #drawOn:, just in case somebody is interested in it.
drawOn: aCanvas | limit elements t1 t2 cacheForm bb | self wrapee elementCount < 10 ifTrue: [ aCanvas line: self bounds origin to: self bounds corner color: Color blue]. limit _ self rectangle extent / (self bounds extent).
t1 _ Time millisecondsToRun: [ elements _ self wrapee elementsInRectangle: self rectangle limit: limit].
cacheForm _ aCanvas form. "Form extent: self bounds extent depth: aCanvas depth." bb _ BitBlt toForm: cacheForm. bb combinationRule: Form over. bb width: 1; height: 1. bb fillColor: Color blue. "Now draw these points offscreen"
t2 _ Time millisecondsToRun: [ elements do: [:each | bb destOrigin: (self toCanvasCoord: each position); copyBits]].
" aCanvas paintImage: cacheForm at: self bounds origin." Transcript print: t1; space; print: t2; space; show: elements size printString; cr.
And the times shown in Transcript are:
| time to get the points | time to draw the points | number of points |
"without the cacheForm, the 2nd col. was between: 1500 and: 3000 "
38 646 6818 "Direct to aCavnas form" 44 737 6818 "Using a real cacheCanvas" 38 740 6818 "Using a real cacheCanvas" 49 733 6818 "Using a real cacheCanvas" 50 739 6818 "Using a real cacheCanvas" 39 757 6818 "Using a real cacheCanvas" 45 687 6818 "Direct to aCavnas form"
-- A390 1BBA 2C58 D679 5A71 - 86F9 404F 4B53 3944 C2D0 Investigacion y Desarrollo - CoreLabs - Core SDI http://www.core-sdi.com
--- For a personal reply use gera@core-sdi.com
squeak-dev@lists.squeakfoundation.org