BitBlt >> #pixelAt:put: speed
Gerardo Richarte
core.lists.squeak at core-sdi.com
Wed May 3 18:46:59 UTC 2000
"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 at core-sdi.com
More information about the Squeak-dev
mailing list
|