diff options
author | frosch <frosch@openttd.org> | 2012-05-15 20:37:42 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2012-05-15 20:37:42 +0000 |
commit | d351f3dae5367b626fa93d97fd864dff545d67b7 (patch) | |
tree | 4e1a78438f581b721f524845a9670f12a4dadd11 | |
parent | 48a6e31f365d2295ba5cef4708677ad9a371fe1d (diff) | |
download | openttd-d351f3dae5367b626fa93d97fd864dff545d67b7.tar.xz |
(svn r24252) -Fix [FS#5162]: Change the unit of the sprite-cache size setting from megabytes to megapixels, so it depends on the blitter being used. Also increase it from 64 to 128, and change the name in the cfg file, so everyone gets the new default.
-rw-r--r-- | src/spritecache.cpp | 12 | ||||
-rw-r--r-- | src/table/misc_settings.ini | 4 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/spritecache.cpp b/src/spritecache.cpp index 4b705fc94..202f2f028 100644 --- a/src/spritecache.cpp +++ b/src/spritecache.cpp @@ -79,6 +79,7 @@ struct MemBlock { static uint _sprite_lru_counter; static MemBlock *_spritecache_ptr; +static uint _allocated_sprite_cache_size = 0; static int _compact_cache_counter; static void CompactSpriteCache(); @@ -843,10 +844,17 @@ void *GetRawSprite(SpriteID sprite, SpriteType type, AllocatorProc *allocator) static void GfxInitSpriteCache() { /* initialize sprite cache heap */ - if (_spritecache_ptr == NULL) _spritecache_ptr = (MemBlock*)MallocT<byte>(_sprite_cache_size * 1024 * 1024); + int bpp = BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth(); + uint target_size = _sprite_cache_size * 1024 * 1024 * max(1, bpp / 8); + + if (_spritecache_ptr == NULL || _allocated_sprite_cache_size != target_size) { + free(_spritecache_ptr); + _allocated_sprite_cache_size = target_size; + _spritecache_ptr = (MemBlock*)MallocT<byte>(_allocated_sprite_cache_size); + } /* A big free block */ - _spritecache_ptr->size = ((_sprite_cache_size * 1024 * 1024) - sizeof(MemBlock)) | S_FREE_MASK; + _spritecache_ptr->size = (_allocated_sprite_cache_size - sizeof(MemBlock)) | S_FREE_MASK; /* Sentinel block (identified by size == 0) */ NextBlock(_spritecache_ptr)->size = 0; } diff --git a/src/table/misc_settings.ini b/src/table/misc_settings.ini index 7e3c1539e..eeca619f1 100644 --- a/src/table/misc_settings.ini +++ b/src/table/misc_settings.ini @@ -213,10 +213,10 @@ var = _freetype.mono_aa def = false [SDTG_VAR] -name = ""max_sprite_cache_size"" +name = ""sprite_cache_size_px"" type = SLE_UINT var = _sprite_cache_size -def = 64 +def = 128 min = 1 max = 512 |