Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2005:
[Freeciv-Dev] (PR#12689) gui-win32: new bitmap cache
Home

[Freeciv-Dev] (PR#12689) gui-win32: new bitmap cache

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12689) gui-win32: new bitmap cache
From: "James Canete" <use_less@xxxxxxxxxxx>
Date: Tue, 29 Mar 2005 03:31:57 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12689 >

This patch implements a new bitmap cache, replacing the old bitmap cache
code in gui-win32.

The old code cached each bitmap as its own hbitmap, which was bad
because win9x/me had a limited number of hbitmaps, and so the bitmap
cache had to be quite small, around 64 images.  This lead to a fairly
bad hit/miss ratio, especially since even the new selected unit
highlight didn't fit in the cache.

This new code caches each bitmap as a portion of a larger hbitmap,
keeping track of clear areas on each hbitmap to place new bitmaps. 
There are no longer any cache misses; if we run out of cache space the
program simply bombs. :)  I've never seen it happen, though, and I
should be able to fix that by simply flushing the cache when full.

Unfortunately, the performance difference is negligible.  This may be in
part because masks are no longer cached, since they require a different
hbitmap format than the normal bitmaps.  Also, the masks are only used
as a speedup; if the mask bitmaps were removed from the sprite struct
the code will happily alpha blend everything.

The packing is quite efficient; in testing, I was able to load a
late-game save file and the cache only used three HBITMAPs of size
512x512.  I haven't tried playing a game from the start, though, which
would use more, different sprites, and probably require more HBITMAPs.

This code is quite steeped in GDI calls right now, but should be
adaptable to any API which requires cacheing sprites, such as OpenGL and
textures.

-James Canete

Attachment: win32-newcache-3.diff
Description: Binary data


[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12689) gui-win32: new bitmap cache, James Canete <=