2015-03-07 0:02 GMT+01:00 Nicolai Hess <nicolaihess@web.de>:

One thing that is really slow is painting an image with Athens, because the cairo backend creates a new surface for this image and uses this
image as a pattern paint. The slow part is copying and converting the image data into the surface.
I already proposed an alternative, (it's a bit like cheating), we can use the bitblt to copy and convert the image data into the surface, this again
is much faster.


For example this code with AthensSceneView
(this is not optimized, because I can create the AthensPaint outside of the render block or cache the paint like it is done in ImageMorph>>drawOnAthensCanvas:, but consider the
paint has to be created in the render loop)

| view form angle |
view�� := AthensSceneView new.
form := (ZnEasy getJpeg:'http://upload.wikimedia.org/wikipedia/commons/thumb/e/e3/Kheops-Pyramid.jpg/320px-Kheops-Pyramid.jpg').
angle := 0.
view scene: [:canvas |
������ canvas surface clear:�� Color black.
������ canvas pathTransform translateBy: form extent /2.0.���� ��
������ canvas pathTransform rotateByDegrees: angle.���� ��
������ canvas pathTransform translateBy: form extent /2.0 negated.
������ canvas setPaint: form.
������ canvas drawShape: (0@0 corner:320@197).
������ angle := angle+10.
].
view openInWindow.

The rotation is quite slow.
Now change the implementation of AthensCairoSurface class>>#fromForm:

fromForm: aForm
������ | form surface |
������ form := aForm unhibernate; asFormOfDepth: 32.
������ surface := self extent: aForm extent.
������ (BitBlt
������ ������ destForm: surface asForm
������ ������ sourceForm: aForm
������ ������ fillColor: nil
������ ������ combinationRule: 24
������ ������ destOrigin: 0 @ 0
������ ������ sourceOrigin: 0 @ 0
������ ������ extent: aForm extent
������ ������ clipRect: (0 @ 0 extent: aForm extent)) copyBits.
������ surface markDirty.
������ ^ surface

This is a bit like cheating, the original code computes a new form with
premultiplied alpha and copies the data into the surface.
This one uses BitBlt to copy the data, but AFAIK this paint combination rule (24)
does not create a premultiplied alpha form.

But this one is much faster.




��