A little font rendering speedup

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

A little font rendering speedup

Igor Stasenko
This is an image-side change, which makes a primitiveDisplayString to
not fail because StrikeFontSet returns nil for (font
characterToGlyphMap).

Since the code, which using fast primitive looks like following:

        self primDisplayString: aString from: startIndex to: stopIndex
                        map: font characterToGlyphMap xTable: font xTable
                        kern: kernDelta

I thought, why one would return nil in ( font characterToGlyphMap ).
Since #xTable in StrikeFontSet implemented as following:

xTable
        "Answer an Array of the left x-coordinate of characters in glyphs."

        ^ (fontArray  at: 1) xTable.

i think it is safe to do similar in characterToGlyphMap ,
this allows the primitive to work w/o failure, because otherwise, if
you look at implementation of

primDisplayString: aString from: startIndex to: stopIndex map:
glyphMap xTable: xTable kern: kernDelta

in fallback code it does same thing again (and ignoring glyphMap at all, btw).


To bench a difference, leave a couple of windows with text in world and then do:

[10 timesRepeat: [World fullDrawOn: World assuredCanvas] ] timeToRun

before change:

 645

after change:

 545

P.S. since i did this in a fresh pharo-10284-dev, where changesorter
is completely broken(do you aware of it?), i filed out this method as
.st file.

--
Best regards,
Igor Stasenko AKA sig.

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

StrikeFontSet-characterToGlyphMap.st (758 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: A little font rendering speedup

Damien Cassou
Please report an issue on the issue tracker.

2009/4/19 Igor Stasenko <[hidden email]>:

> This is an image-side change, which makes a primitiveDisplayString to
> not fail because StrikeFontSet returns nil for (font
> characterToGlyphMap).
>
> Since the code, which using fast primitive looks like following:
>
>        self primDisplayString: aString from: startIndex to: stopIndex
>                        map: font characterToGlyphMap xTable: font xTable
>                        kern: kernDelta
>
> I thought, why one would return nil in ( font characterToGlyphMap ).
> Since #xTable in StrikeFontSet implemented as following:
>
> xTable
>        "Answer an Array of the left x-coordinate of characters in glyphs."
>
>        ^ (fontArray  at: 1) xTable.
>
> i think it is safe to do similar in characterToGlyphMap ,
> this allows the primitive to work w/o failure, because otherwise, if
> you look at implementation of
>
> primDisplayString: aString from: startIndex to: stopIndex map:
> glyphMap xTable: xTable kern: kernDelta
>
> in fallback code it does same thing again (and ignoring glyphMap at all, btw).
>
>
> To bench a difference, leave a couple of windows with text in world and then do:
>
> [10 timesRepeat: [World fullDrawOn: World assuredCanvas] ] timeToRun
>
> before change:
>
>  645
>
> after change:
>
>  545
>
> P.S. since i did this in a fresh pharo-10284-dev, where changesorter
> is completely broken(do you aware of it?), i filed out this method as
> .st file.
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>



--
Damien Cassou
http://damiencassou.seasidehosting.st

_______________________________________________
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
|

Fwd: A little font rendering speedup

Igor Stasenko
In reply to this post by Igor Stasenko
I put this on mantis, since i'm sure this applies to squeak3.10 and Pharo both.

http://bugs.squeak.org/view.php?id=7338


---------- Forwarded message ----------
From: Igor Stasenko <[hidden email]>
Date: 2009/4/19
Subject: A little font rendering speedup
To: Pharo Development <[hidden email]>


This is an image-side change, which makes a primitiveDisplayString to
not fail because StrikeFontSet returns nil for (font
characterToGlyphMap).

Since the code, which using fast primitive looks like following:

       self primDisplayString: aString from: startIndex to: stopIndex
                       map: font characterToGlyphMap xTable: font xTable
                       kern: kernDelta

I thought, why one would return nil in ( font characterToGlyphMap ).
Since #xTable in StrikeFontSet implemented as following:

xTable
       "Answer an Array of the left x-coordinate of characters in glyphs."

       ^ (fontArray  at: 1) xTable.

i think it is safe to do similar in characterToGlyphMap ,
this allows the primitive to work w/o failure, because otherwise, if
you look at implementation of

primDisplayString: aString from: startIndex to: stopIndex map:
glyphMap xTable: xTable kern: kernDelta

in fallback code it does same thing again (and ignoring glyphMap at all, btw).


To bench a difference, leave a couple of windows with text in world and then do:

[10 timesRepeat: [World fullDrawOn: World assuredCanvas] ] timeToRun

before change:

 645

after change:

 545




--
Best regards,
Igor Stasenko AKA sig.

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

StrikeFontSet-characterToGlyphMap.st (758 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Fwd: A little font rendering speedup

Adrian Lienhard
Thanks, Igor,

I created an entry in the Pharo tracker with a link to the Mantis  
entry to allow us to keep track of its integration into Pharo.

http://code.google.com/p/pharo/issues/detail?id=758

Cheers,
Adrian


http://code.google.com/p/pharo/issues/detail?id=758
On Apr 19, 2009, at 15:36 , Igor Stasenko wrote:

> I put this on mantis, since i'm sure this applies to squeak3.10 and  
> Pharo both.
>
> http://bugs.squeak.org/view.php?id=7338
>
>
> ---------- Forwarded message ----------
> From: Igor Stasenko <[hidden email]>
> Date: 2009/4/19
> Subject: A little font rendering speedup
> To: Pharo Development <[hidden email]>
>
>
> This is an image-side change, which makes a primitiveDisplayString to
> not fail because StrikeFontSet returns nil for (font
> characterToGlyphMap).
>
> Since the code, which using fast primitive looks like following:
>
>        self primDisplayString: aString from: startIndex to: stopIndex
>                        map: font characterToGlyphMap xTable: font  
> xTable
>                        kern: kernDelta
>
> I thought, why one would return nil in ( font characterToGlyphMap ).
> Since #xTable in StrikeFontSet implemented as following:
>
> xTable
>        "Answer an Array of the left x-coordinate of characters in  
> glyphs."
>
>        ^ (fontArray  at: 1) xTable.
>
> i think it is safe to do similar in characterToGlyphMap ,
> this allows the primitive to work w/o failure, because otherwise, if
> you look at implementation of
>
> primDisplayString: aString from: startIndex to: stopIndex map:
> glyphMap xTable: xTable kern: kernDelta
>
> in fallback code it does same thing again (and ignoring glyphMap at  
> all, btw).
>
>
> To bench a difference, leave a couple of windows with text in world  
> and then do:
>
> [10 timesRepeat: [World fullDrawOn: World assuredCanvas] ] timeToRun
>
> before change:
>
>  645
>
> after change:
>
>  545
>
>
>
>
> --
> Best regards,
> Igor Stasenko AKA sig.
> <StrikeFontSet-characterToGlyphMap.st>


_______________________________________________
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: [squeak-dev] Fwd: A little font rendering speedup

Igor Stasenko
A more deeper analysis shows, that it looks like things around
characterToGlyphMap is either incomplete, or over-engineered.

By looking through all characterToGlyphMap uses, most methods simply
assigns nil to it.
The only method which would assign something different is
HostFont>>#fontName:size:emphasis:rangesArray:

in [ characterToGlyphMap := self isoToSqueakMap ]

but what a surprise! it implemented as following:

isoToSqueakMap
        ^nil

IMO character to glyph mapping for strike fonts is redundant, because
you can simply remap the xTable to achieve same effect.

Also, since Pharo fully supports FreeType, doesn't it makes a HostFont
a candidate to wipe out?
If so, then i would really recomment to ignore characterToGlyphMap for
displaying ByteString(s) and use single class var which holds an
identity mapping for ascii chars.
This is, of course just to make a primitiveDisplayString happy. A more
aggressive way would be to rewrite this primitive and remove the
characterToGlyphMap argument from use.


2009/4/19 Adrian Lienhard <[hidden email]>:

> Thanks, Igor,
>
> I created an entry in the Pharo tracker with a link to the Mantis
> entry to allow us to keep track of its integration into Pharo.
>
> http://code.google.com/p/pharo/issues/detail?id=758
>
> Cheers,
> Adrian
>
>
> http://code.google.com/p/pharo/issues/detail?id=758
> On Apr 19, 2009, at 15:36 , Igor Stasenko wrote:
>
>> I put this on mantis, since i'm sure this applies to squeak3.10 and
>> Pharo both.
>>
>> http://bugs.squeak.org/view.php?id=7338
>>
>>
>> ---------- Forwarded message ----------
>> From: Igor Stasenko <[hidden email]>
>> Date: 2009/4/19
>> Subject: A little font rendering speedup
>> To: Pharo Development <[hidden email]>
>>
>>
>> This is an image-side change, which makes a primitiveDisplayString to
>> not fail because StrikeFontSet returns nil for (font
>> characterToGlyphMap).
>>
>> Since the code, which using fast primitive looks like following:
>>
>>        self primDisplayString: aString from: startIndex to: stopIndex
>>                        map: font characterToGlyphMap xTable: font
>> xTable
>>                        kern: kernDelta
>>
>> I thought, why one would return nil in ( font characterToGlyphMap ).
>> Since #xTable in StrikeFontSet implemented as following:
>>
>> xTable
>>        "Answer an Array of the left x-coordinate of characters in
>> glyphs."
>>
>>        ^ (fontArray  at: 1) xTable.
>>
>> i think it is safe to do similar in characterToGlyphMap ,
>> this allows the primitive to work w/o failure, because otherwise, if
>> you look at implementation of
>>
>> primDisplayString: aString from: startIndex to: stopIndex map:
>> glyphMap xTable: xTable kern: kernDelta
>>
>> in fallback code it does same thing again (and ignoring glyphMap at
>> all, btw).
>>
>>
>> To bench a difference, leave a couple of windows with text in world
>> and then do:
>>
>> [10 timesRepeat: [World fullDrawOn: World assuredCanvas] ] timeToRun
>>
>> before change:
>>
>>  645
>>
>> after change:
>>
>>  545
>>
>>
>>
>>
>> --
>> Best regards,
>> Igor Stasenko AKA sig.
>> <StrikeFontSet-characterToGlyphMap.st>
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>



--
Best regards,
Igor Stasenko AKA sig.

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