[Commits] [wesnoth/wesnoth] 8e5eb9: cache minimap images in mp create screen

GitHub noreply at github.com
Sat Nov 8 04:07:00 UTC 2014


  Branch: refs/heads/master
  Home:   https://github.com/wesnoth/wesnoth
  Commit: 8e5eb9a8d4edf8da33dd19540495b6aa60b28375
      https://github.com/wesnoth/wesnoth/commit/8e5eb9a8d4edf8da33dd19540495b6aa60b28375
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-11-07 (Fri, 07 Nov 2014)

  Changed paths:
    M src/game_initialization/create_engine.cpp
    M src/game_initialization/create_engine.hpp
    M src/game_initialization/multiplayer_create.cpp

  Log Message:
  -----------
  cache minimap images in mp create screen

When we are actually in the game, the image.cpp file uses an
elaborate collection of caches to make sure that all images are
cached and reloaded rather than redoing work (even scaling). It's
questionable whether the amount of caching going on there is
appropriate, it seems it might even be faster if we did less. But
one place that we don't do any caching and performance is bad is
in the mp create screen. There was a bug report in 1.12:

https://gna.org/bugs/?func=detailitem&item_id=21801

In this commit, I implement quick and dirty caching for scenario
minimap images. Each scenario record holds a surface (an SDL
reference counted pointer to image data), and when a minimap is
rendered this gets saved, along with the md5 hash of the map that
got rendered. Whenever a minimap is requested, we hash it first
and check if the cache is dirty. If so we recalculate, otherwise
we return the cached image.

The code is also cleaner and a bit less convoluted than the
previous code -- the previous author seemed to think that surfaces
are "object" types and not "pointer" types, that require an
additional layer of memory management with boost scoped pointer
etc. This was in fact redundant.

I don't know if this commit will actually help report 21801,
the profiling seemed to suggest that it's the minimap rendering
code that is actually slow. But it seems that this can't hurt,
and may at least mitigate the slowness, since except for random
maps it means the minimap calculation won't be repeated.


  Commit: d3273cfb6bda490e1a837deadbd6414eb27d8b82
      https://github.com/wesnoth/wesnoth/commit/d3273cfb6bda490e1a837deadbd6414eb27d8b82
  Author: Chris Beck <beck.ct at gmail.com>
  Date:   2014-11-07 (Fri, 07 Nov 2014)

  Changed paths:
    M src/game_initialization/create_engine.cpp
    M src/game_initialization/create_engine.hpp
    M src/game_initialization/multiplayer_create.cpp

  Log Message:
  -----------
  Merge pull request #327 from cbeck88/add_map_image_caching_to_mp_create_screen

cache minimap images in mp create screen


Compare: https://github.com/wesnoth/wesnoth/compare/64536df6059e...d3273cfb6bda


More information about the Commits mailing list