[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [DotGNU]DrawString / Performence

From: Thomas Fritzsche
Subject: RE: [DotGNU]DrawString / Performence
Date: 24 Sep 2003 01:18:58 +0200

Hello Neil+dotnet hackers,

Am Mon, 2003-09-22 um 21.06 schrieb Neil Cawse:

> > But I think I should rewrite this methods, because it pinvoke the
> system
> > string measure feature very often and this could be one of the
> performence
> > problems of the current SWF implementation. What do you think?
> Definitely! Rhys and I discussed this. The way that I originally did it
> is slow. There are two options:
> 1) Cache each request to the toolkit for each font size/style/letter.
> 2) Use a smart approach to actually measuring a word at a time and going
> down to letters where needed.

This are the methods I'm thinking about too. But maybe this is a more
general problem. If this is true that this performence issue comes from
the large number pinvoke calls then it could be usefull to collect
pinvoke graphic calls and then send them in an array/Collection to the

> Some of this is background..
> There are essentially 3 System.Graphics methods and a separate
> requirement for drawing the textbox that we need to cater for
> (RichTextBox later):
> MeasureCharacterRanges - here you define a collection of a range of the
> characters in a string that you want to measure eg. 1 to 5 and 6 to 10.
> MeasureString - measure the entire string
> DrawString - render the string
> For textbox, we need to be able to specify the character range that is
> highlighted.

This is from the Microsoft specification. Isn't it?

> We want to support all the StringFormat options for these methods, these
> include:
> * Alignments vertically and horizontally
> * DigitSubstitution for characters that cant be displayed
> * DirectionRightToLeft

> Now in order to draw the string, we need to measure it first to know if
> we must for example wrap the word, put in the ellipse etc. For the very
> simple case of no StringFormat, we could get away with no measuring.

I think here I found the first problem that I wrote about on the mailing
list. Look at the second DrawString example screenshot (win-version).
This is a call without StringFormat and they made word wraps here. This
is clear because you didn't set NoWrap Format option. This was one of
the problems that I fixed in my patch, but this breaked the other stuff.
I guess the calling methods don't expect this word wrap.

> Thomas, I will leave this up to your ingenuity - if you need or want to
> bounce some ideas, mail. Or if any DotGNU'ers have some smart ideas??
> This stuff is very core and very important. We need to get it slick and
> fast. I did already take a look at the api's in wine the implementation
> that do this and I put my tail between my legs and left ;)

I will try to write a patch, but this week I'm overloaded with other
work. So I hopefully  can start at the weekend. Keep also in mind, that
I just started C# programing, so don't expect to much.
Hopefully at the begin of the next week I can send you a first patch
that fixes the "main" layout features, includes word wrap and saves some
time by caching measuring results.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]