Canvas transform bug when rendering text?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
29 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Canvas transform bug when rendering text?

David Harvey
Hi list,

I'm writing a little charting morph, and while playing with rotating text for axis labels came across something which I've noted in Morphs text handling a couple of times. 

If I apply a transform in a drawing operation, rotated text _appears_ to be drawn twice, slightly offset, giving a scrappy bold look. It seems only to do this when drawing on a form canvas that's backed onto the display: if you pick and drag the morph, the text is rendered beautifully.

The test morph attached isolates the problem. The transcript logging is an attempt to see what might be happening: looking at the output it appears that there are circumstances in which the during: block is invoked twice.

Any thoughts?

David

------------------
David Harvey
www.teamsandtechnology.com
www.cateams.com
@david_harvey

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

TextRotationBug.st (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Canvas transform bug when rendering text?

Henrik Sperre Johansen

On Apr 7, 2010, at 1:45 49PM, David Harvey wrote:

Hi list,

I'm writing a little charting morph, and while playing with rotating text for axis labels came across something which I've noted in Morphs text handling a couple of times. 

If I apply a transform in a drawing operation, rotated text _appears_ to be drawn twice, slightly offset, giving a scrappy bold look. It seems only to do this when drawing on a form canvas that's backed onto the display: if you pick and drag the morph, the text is rendered beautifully.

The test morph attached isolates the problem. The transcript logging is an attempt to see what might be happening: looking at the output it appears that there are circumstances in which the during: block is invoked twice.

Any thoughts?

David


Basically, transform doesn't work with depth 32.
Workarounds are described in the thread.

Cheers,
Henry


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Canvas transform bug when rendering text?

Henrik Sperre Johansen
On 07.04.2010 14:26, Henrik Johansen wrote:

On Apr 7, 2010, at 1:45 49PM, David Harvey wrote:

Hi list,

I'm writing a little charting morph, and while playing with rotating text for axis labels came across something which I've noted in Morphs text handling a couple of times. 

If I apply a transform in a drawing operation, rotated text _appears_ to be drawn twice, slightly offset, giving a scrappy bold look. It seems only to do this when drawing on a form canvas that's backed onto the display: if you pick and drag the morph, the text is rendered beautifully.

The test morph attached isolates the problem. The transcript logging is an attempt to see what might be happening: looking at the output it appears that there are circumstances in which the during: block is invoked twice.

Any thoughts?

David


Basically, transform doesn't work with depth 32.
Workarounds are described in the thread.

Cheers,
Henry

David, Lukas, whomever else it may concern.

Of course I turned out to be (partly) wrong when looking into it.
Transform does indeed not work with alpha, but not because of bugs in WarpBlt as I assumed, but because FormCanvas always uses the Paint rule when rotating...
Try the attached code, and you should get better results. (you probably want to use smoothing > 1 if displaying text with rotation other than a multiple of 90 degrees).

This seems to be more of a generic problem though, looking at the number of places a= 32 ifTrue: [] check is made, I'll try to come up with a more consistent solution for a system-wide patch. (which amongst other things would also fix the black border appearing around a window while zooming back to old position when you drag and drop it outside main window)
 
Cheers,
Henry

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

FormCanvas-transformByclippingToduringsmoothing.st (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Canvas transform bug when rendering text?

Stéphane Ducasse
thanks!

PS: I will integrate some other fixes when back to the garage later today....
Got stuck on the highway without gaz :) ... yesterday.

>>>
>
> David, Lukas, whomever else it may concern.
>
> Of course I turned out to be (partly) wrong when looking into it.
> Transform does indeed not work with alpha, but not because of bugs in WarpBlt as I assumed, but because FormCanvas always uses the Paint rule when rotating...
> Try the attached code, and you should get better results. (you probably want to use smoothing > 1 if displaying text with rotation other than a multiple of 90 degrees).
>
> This seems to be more of a generic problem though, looking at the number of places a= 32 ifTrue: [] check is made, I'll try to come up with a more consistent solution for a system-wide patch. (which amongst other things would also fix the black border appearing around a window while zooming back to old position when you drag and drop it outside main window)
>  
> Cheers,
> Henry
> <FormCanvas-transformByclippingToduringsmoothing.st>_______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Canvas transform bug when rendering text?

Lukas Renggli
Pay attention there is a #haltOnce in the code. Also there is
something wrong with the line endings in the change-set.

The change solves the problem with the vertical text in eCompletion,
so this is very cool.

However it also breaks some window refreshing, see attached screenshot.

Lukas



On 9 April 2010 08:51, Stéphane Ducasse <[hidden email]> wrote:

> thanks!
>
> PS: I will integrate some other fixes when back to the garage later today....
> Got stuck on the highway without gaz :) ... yesterday.
>>>>
>>
>> David, Lukas, whomever else it may concern.
>>
>> Of course I turned out to be (partly) wrong when looking into it.
>> Transform does indeed not work with alpha, but not because of bugs in WarpBlt as I assumed, but because FormCanvas always uses the Paint rule when rotating...
>> Try the attached code, and you should get better results. (you probably want to use smoothing > 1 if displaying text with rotation other than a multiple of 90 degrees).
>>
>> This seems to be more of a generic problem though, looking at the number of places a= 32 ifTrue: [] check is made, I'll try to come up with a more consistent solution for a system-wide patch. (which amongst other things would also fix the black border appearing around a window while zooming back to old position when you drag and drop it outside main window)
>>
>> Cheers,
>> Henry
>> <FormCanvas-transformByclippingToduringsmoothing.st>_______________________________________________
>> Pharo-project mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>


--
Lukas Renggli
www.lukas-renggli.ch

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Screen shot 2010-04-09 at 11.13.42 .png (49K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Canvas transform bug when rendering text?

Stéphane Ducasse
funny way to type code.

Stef



_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Canvas transform bug when rendering text?

Lukas Renggli
I don't write code like this. Rotating a window is just a good test to
see if works, because it calls all kind of different code.

If you rotate a more complex window than a workspace, my system hangs
btw. So there must be other stuff broken there.

Lukas

On 9 April 2010 11:20, Stéphane Ducasse <[hidden email]> wrote:

> funny way to type code.
>
> Stef
>
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>



--
Lukas Renggli
www.lukas-renggli.ch

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Canvas transform bug when rendering text?

Stéphane Ducasse

On Apr 9, 2010, at 11:28 AM, Lukas Renggli wrote:

> I don't write code like this.

It was a joke :)
but I really like the visual effect

> Rotating a window is just a good test to
> see if works, because it calls all kind of different code.
>
> If you rotate a more complex window than a workspace, my system hangs
> btw. So there must be other stuff broken there.

oops
with the fix too?

>
> Lukas
>
> On 9 April 2010 11:20, Stéphane Ducasse <[hidden email]> wrote:
>> funny way to type code.
>>
>> Stef
>>
>>
>>
>> _______________________________________________
>> Pharo-project mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>
>
>
>
> --
> Lukas Renggli
> www.lukas-renggli.ch
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Canvas transform bug when rendering text?

Lukas Renggli
>> If you rotate a more complex window than a workspace, my system hangs
>> btw. So there must be other stuff broken there.
>
> oops
> with the fix too?

Yes, with and without the change.

Lukas

--
Lukas Renggli
www.lukas-renggli.ch

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Canvas transform bug when rendering text?

Henrik Sperre Johansen
In reply to this post by Stéphane Ducasse

On Apr 9, 2010, at 11:40 38AM, Stéphane Ducasse wrote:

>
> On Apr 9, 2010, at 11:28 AM, Lukas Renggli wrote:
>
>> I don't write code like this.
>
> It was a joke :)
> but I really like the visual effect
>
>> Rotating a window is just a good test to
>> see if works, because it calls all kind of different code.
>>
>> If you rotate a more complex window than a workspace, my system hangs
>> btw. So there must be other stuff broken there.
>
> oops
> with the fix too?

Yes. The fix was for which draw mode is used, and nothing else.
The transformBy: method still creates a new Form of extent and depth same as the Tranformation each draw call, so it gives the GC a real workout.
Sometimes this manifests as system hangs, others as a constantly higher CPU usage. (depending on how large your transformed morph is)

Cheers,
Henry



_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Canvas transform bug when rendering text?

Chris Muller-3
In reply to this post by Henrik Sperre Johansen
Thank you Henrik, it looks like a huge improvement!  The attached
screen shots help explain why I only said "improvement" instead of
"perfect".  Look at the color of my translucent morph when it is
upright vs. rotated.  The translucency is now preserved, which is
great!  However, do you know why the color seems to lose so much
saturation?


2010/4/8 Henrik Sperre Johansen <[hidden email]>:

> On 07.04.2010 14:26, Henrik Johansen wrote:
>
> On Apr 7, 2010, at 1:45 49PM, David Harvey wrote:
>
> Hi list,
> I'm writing a little charting morph, and while playing with rotating text
> for axis labels came across something which I've noted in Morphs text
> handling a couple of times.
> If I apply a transform in a drawing operation, rotated text _appears_ to be
> drawn twice, slightly offset, giving a scrappy bold look. It seems only to
> do this when drawing on a form canvas that's backed onto the display: if you
> pick and drag the morph, the text is rendered beautifully.
> The test morph attached isolates the problem. The transcript logging is an
> attempt to see what might be happening: looking at the output it appears
> that there are circumstances in which the during: block is invoked twice.
> Any thoughts?
> David
>
> http://n4.nabble.com/Problem-with-TransformationMorph-td1691811.html#a1691811
> Basically, transform doesn't work with depth 32.
> Workarounds are described in the thread.
> Cheers,
> Henry
>
> David, Lukas, whomever else it may concern.
>
> Of course I turned out to be (partly) wrong when looking into it.
> Transform does indeed not work with alpha, but not because of bugs in
> WarpBlt as I assumed, but because FormCanvas always uses the Paint rule when
> rotating...
> Try the attached code, and you should get better results. (you probably want
> to use smoothing > 1 if displaying text with rotation other than a multiple
> of 90 degrees).
>
> This seems to be more of a generic problem though, looking at the number of
> places a= 32 ifTrue: [] check is made, I'll try to come up with a more
> consistent solution for a system-wide patch. (which amongst other things
> would also fix the black border appearing around a window while zooming back
> to old position when you drag and drop it outside main window)
>
> Cheers,
> Henry
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

upright.png (50K) Download Attachment
rotatedWithFix.png (57K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Canvas transform bug when rendering text?

Henrik Sperre Johansen
Not entirely sure sesong as I write this from a phone with no code  
nearby, but a hunch would be checking the method in question, and try  
disabling the shadow drawing,

Cheers,
Henry

Den 9. apr. 2010 kl. 23.42 skrev Chris Muller <[hidden email]>:

> Thank you Henrik, it looks like a huge improvement!  The attached
> screen shots help explain why I only said "improvement" instead of
> "perfect".  Look at the color of my translucent morph when it is
> upright vs. rotated.  The translucency is now preserved, which is
> great!  However, do you know why the color seems to lose so much
> saturation?
>
>
> 2010/4/8 Henrik Sperre Johansen <[hidden email]>:
>> On 07.04.2010 14:26, Henrik Johansen wrote:
>>
>> On Apr 7, 2010, at 1:45 49PM, David Harvey wrote:
>>
>> Hi list,
>> I'm writing a little charting morph, and while playing with  
>> rotating text
>> for axis labels came across something which I've noted in Morphs text
>> handling a couple of times.
>> If I apply a transform in a drawing operation, rotated text  
>> _appears_ to be
>> drawn twice, slightly offset, giving a scrappy bold look. It seems  
>> only to
>> do this when drawing on a form canvas that's backed onto the  
>> display: if you
>> pick and drag the morph, the text is rendered beautifully.
>> The test morph attached isolates the problem. The transcript  
>> logging is an
>> attempt to see what might be happening: looking at the output it  
>> appears
>> that there are circumstances in which the during: block is invoked  
>> twice.
>> Any thoughts?
>> David
>>
>> http://n4.nabble.com/Problem-with-TransformationMorph-td1691811.html#a1691811
>> Basically, transform doesn't work with depth 32.
>> Workarounds are described in the thread.
>> Cheers,
>> Henry
>>
>> David, Lukas, whomever else it may concern.
>>
>> Of course I turned out to be (partly) wrong when looking into it.
>> Transform does indeed not work with alpha, but not because of bugs in
>> WarpBlt as I assumed, but because FormCanvas always uses the Paint  
>> rule when
>> rotating...
>> Try the attached code, and you should get better results. (you  
>> probably want
>> to use smoothing > 1 if displaying text with rotation other than a  
>> multiple
>> of 90 degrees).
>>
>> This seems to be more of a generic problem though, looking at the  
>> number of
>> places a= 32 ifTrue: [] check is made, I'll try to come up with a  
>> more
>> consistent solution for a system-wide patch. (which amongst other  
>> things
>> would also fix the black border appearing around a window while  
>> zooming back
>> to old position when you drag and drop it outside main window)
>>
>> Cheers,
>> Henry
>>
>> _______________________________________________
>> Pharo-project mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>
> <upright.png>
> <rotatedWithFix.png>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Canvas transform bug when rendering text?

Michael Rueger-6
In reply to this post by Chris Muller-3
On 4/9/2010 11:42 PM, Chris Muller wrote:
> Thank you Henrik, it looks like a huge improvement!  The attached
> screen shots help explain why I only said "improvement" instead of
> "perfect".  Look at the color of my translucent morph when it is
> upright vs. rotated.  The translucency is now preserved, which is

With Freetype now being used for text rendering it might be possible to
do it right by performing a transformed rendering instead of rotating a
bitmap.
Actually a nasty surprise we had in the Sophie project when it turned
out that even Tweak only did the bitmap trick, but Rome came to the
rescue :-)

Michael

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Canvas transform bug when rendering text?

hilaire
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Canvas transform bug when rendering text?

Michael Rueger-6
On 4/10/2010 10:02 AM, Hilaire Fernandes wrote:

> Does Polymoprh based on Rome is something making sense, or is it just
> non-sense (ie not related). I try to understand what is the value behing
> Rome.

Rome (in this case especially Rome Cairo) brings true vector based
drawing to Squeak/Pharo allowing for drawing with transformations and
lossless scaling.
Rome is also a framework to unify drawing using different backends,
which right now isn't the case as the different Canvas classes support
different protocols. Or even worse implement some calls differently.

Most of the drawing code in Morphic would need to be rewritten though,
so it isn't that simple a task.

Michael

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Canvas transform bug when rendering text?

hilaire
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Canvas transform bug when rendering text?

Michael Rueger-6
On 4/10/2010 10:31 AM, Hilaire Fernandes wrote:
> Is it correct to say a well integrated Rome Cairo framework in Moprhic
> could simplify the whole graphic framework of the system.

Yes it should.
Alain did some work with Rome in Miro, so he might have more experience
with it.

> Will it allow us to have vector based UI element or is non sense?

No, not non sense :-), that is exactly what it would allow.

Michael

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Canvas transform bug when rendering text?

hilaire
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Canvas transform bug when rendering text?

Michael Rueger-6
On 4/10/2010 10:51 AM, Hilaire Fernandes wrote:

> Michael Rueger a écrit :
>> On 4/10/2010 10:31 AM, Hilaire Fernandes wrote:
>>
>>> Will it allow us to have vector based UI element or is non sense?
>>
>> No, not non sense :-), that is exactly what it would allow.
>
> Yes, vector based UI is where we should move to keep in the course.
> Is it what you did for Sophie? If so, did you use some bitmap caching
> technic?

Tweak does (or did back then) some caching. You have to be careful
though with caching, as you might end up copying a lot of bits around
even if caching doesn't really make sense for your particular application.
IIRC (it's been a while) in Tweak you  first draw to the cache, then the
cache is drawn to the Squeak Display bitmap and then that is drawn to
the screen. No great when you are playing e.g. a video.

Michael

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Canvas transform bug when rendering text?

hilaire
CONTENTS DELETED
The author has deleted this message.
12