Re: [scintilla] Pango support on GTK+ 2.x

On Sun, 2003-03-09 at 16:18, Neil Hodgson wrote:
> Havoc Pennington:
> > Also be sure Scintilla isn't doing anything really easily fixable,
> > like keeping a PangoLayout around permanently for every line, or
> > computing them all at once, or (some people have done this) using a
> > PangoLayout for every character cell.
>    The main drawing strategy code is for each expose/draw:
> # font descriptions already created at style definition time
> gtk_widget_create_pango_context()
> pango_layout_new()
> for each line:
>   for each text run in one style:
>      gdk_gc_set_foreground()
>      pango_layout_set_text()
>      pango_layout_set_font_description()
>      pango_layout_get_line()
>      gdk_draw_layout_line()
> unref layout and context
>    Possibly it may pay to insert all the runs into one pango layout and then
> render the whole line at once. Plain text (one style for the whole document)
> is rendered significantly faster by this code. The target text is source
> code and so is made up of many short runs with individual operator
> characters often styled in different colours or weights to neighbouring
> text.

Other thoughts here beyond what I mentioned earlier:

 - Pango is fast enough that the overhead of creating and
   destroying PangoLayout objects for each line is quite
   noticeable in my experience.

 - I'm not sure it will be faster currently, but I'd definitely
   suggest using one layout per line and setting color attributes
   on ranges.

 - Is the problem layout speed or rendering speed? I'd guess that
   scintilla can assume constant-height-lines, but perhaps
   it still needs to go over the entire file to deal with 
   line widths. (or if there is wrapping involved)

 - It takes GtkTextView around 1.5s to lay out a 11,000 line
   source file on 1 ghz machine. Which I wouldn't consider 
   _slow_ but probably is still slow enough that if you 
   have to lay out the entire file, you are going to need
   to do it incrementally. 

 - If layout is the bottleneck, then one useful optimization
   is that when doing the layout (but not the rendering), 
   omit the color attributes.

 - In looking at Pango performance in Gnumeric ... I found it
   very helpful to have a benchmark that used just Pango and 
   GDK but did approximately the same thing that Gnumeric was 
   doing (laying out lots of short strings of numbers.)


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