Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2001:
[Freeciv-Dev] GTK+ client speedup patch (+ optional scrollbuttons)
Home

[Freeciv-Dev] GTK+ client speedup patch (+ optional scrollbuttons)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] GTK+ client speedup patch (+ optional scrollbuttons)
From: Kevin Brown <kevin@xxxxxxxxxxxxxx>
Date: Wed, 8 Aug 2001 20:31:36 -0700

In looking through the GTK+ client code, I noticed that there was a
lot of extra drawing happening on the canvas.  Makes sense, given that
each tile is built of one or more sprites layered on top of each
other.

So I thought I'd see if I could optimize this process a bit.  What I
came up with is a cache of pre-combined sprites that are used when
possible.  There are some limitations right now, namely all sprites
that are combined this way have to be the same size.  But the end
result is that I'm seeing noticeable speedups in drawing speeds.  As
it's a cache, it's a tradeoff between memory usage on the X server and
speed, but I think it's a reasonable tradeoff.  It's most effective
when you're using something like fog-of-war where most displayed tiles
are composed of two or more sprites.

If you do a "civclient --help", it'll describe the options.  You turn
it on with "--use-tile-cache".  You can tune the size of the cache
with "--tile-cache-size" (default 1024 entries) and tune the lower
limit on the number of sprites that have to be in the tile before
it'll cache it with "--min-cached-tile-depth" (default 2, which gets
any tiles that are "fogged").

Note that because of the way this works, it's probably not worth
setting min-cached-tile-depth to 1 because fetching from the cache and
then drawing the resulting fetch is slower than just drawing the one
sprite to the tile.  And setting min-cached-tile-depth to 3 causes
most fogged tiles to not be fetched from the cache.  So the sweet spot
for this seems to be 2, the default.


I've written some comments above get_cached_tile(), the function that
does all the cacheing work.  Some of you might find it slightly
interesting reading.


The following patch incorporates:

        - Changes to argument handling to make gui-specific option
          handling work properly.

        - The tile cache.  Requires the argument handling changes.

        - Optional scroll buttons with acceleration as a substitute
          for scrollbars (turn on scroll buttons with
          --use-scroll-buttons).  Requires the argument handling
          changes.


If you guys would like, I'll separate the cache/argument handling
changes from the scroll button changes.  I haven't done that yet
because I'm lazy.  :-)


I haven't actually benchmarked the frame drawing time before and
after, but it looks to me like I get a speedup of 20% or so, just by
eyeballing it.  It might be more than that, but I don't want to
overestimate.  :-)


The patch is against 1.11.10.  Sorry, I haven't tried to work with
1.11.12 yet.  Hopefully you won't have too much trouble applying the
patch.


Note that this patch doesn't speed up isometric displays.  I haven't
tried applying this technique to that but it looks like it'll be a bit
trickier because it looks like I'd have to figure out how to combine
clipping masks in the cached result.


Comments?




-- 
Kevin Brown                                           kevin@xxxxxxxxxxxxxx

    It's really hard to define what "unexpected behavior" means when you're
                       talking about Windows.

Attachment: freeciv-1.11.10-gtk-improvements.patch.gz
Description: application/gunzip


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