Hi Ronie,

Below you said:
> The problem with asForm, is that the form returned can be used after the 
> cairo surface which holds the pixels is garbage collected.

I cannot reproduce this case. You gave a script:

> surface := AthensCairoSurface extent: 640@480.
> surface drawDuring: [ :canvas |
>     surface clear: Color blue.
> ].
> 
> surface asForm asMorph openInWindow


I see a blue window.

Cheers,
Alexandre


> How about changing AthensCairoSurface >> asForm into the following 
> definition?:
> asForm
> 
>     "create a form and copy an image data there"
>     | form |
>     self checkSession.
>     
>     self flush.
>     form := Form extent: (self width@self height) depth: 32.
>     form unhibernate.
>     LibC memCopy: self getDataPtr to: form bits size: self width*self 
> height*4.
>     ^ form
> 
> This involves a whole copy, but it removes completely the dependency on the 
> surface plugin.
> 
> If we want to keep using the surface plugin with Cairo, the old definition of 
> asForm still has a bug, which can be reproduced with the following snippet:
> 
> Smalltalk compiler evaluate: '
> | surface |
> surface := AthensCairoSurface extent: 640@480.
> surface drawDuring: [ :canvas |
>     surface clear: Color blue.
> ].
> 
> surface asForm asMorph openInWindow
> '
> 
> The problem with asForm, is that the form returned can be used after the 
> cairo surface which holds the pixels is garbage collected.

Reply via email to