Re: Gnome-terminal (vte) drawing



On Sun, 2005-11-20 at 15:58 -0800, Travis Reitter wrote:
> One plan I have to hopefully reduce gnome-terminal's CPU usage and time
> to output text is to only redraw the terminal widget (vte) a certain
> number of times a second.
> 
> My goal would be about 200 full refreshes per second (which should be
> well above human ability to notice visual change). Right now, it looks
> like we just update as fast as possible (leading to a lot of wasted
> effort).

You only need to repaint as fast as the display's refresh rate.  Don't
bother figuring out the exact value right now unless it is super-easy to
do; hardcoding a value of about 50 Hz should be enough.

> I tried throwing in a simple check within the main vte redraw function,
> to only redraw if the last redraw was at least a minimum time ago. The
> obvious bug with this is that redraws only get one chance. Any lost
> redraws are never recovered (leading to an almost never-redrawn
> terminal).

VTE can queue up changes until it decides to repaint, can't it?  I mean,
it maintains its own grid of characters and everything.

Your lowest-level function that modifies the character grid could do
this:

  static void
  vte_frob_character_grid (VTE *vte, frobparams params)
  {
    if (!vte->update_timer)
      vte->update_timer = g_timeout_add (20, refresh_cb, vte); /* That's 50 Hz */

    really_frob_the_character_grid (params);
  }

  static gboolean
  refresh_cb (VTE *vte)
  {
    vte->update_timer = 0;

    gtk_widget_queue_draw (vte->widget);
    return FALSE;
  }

  Federico




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