diff options
author | peter1138 <peter1138@openttd.org> | 2011-11-24 12:26:44 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2011-11-24 12:26:44 +0000 |
commit | 15d0a22aac6b90a2055e68d019cab4350376a8fd (patch) | |
tree | 0b94b0f8551f81dcdf924ce628d1a674d7a8fb63 /src/blitter/8bpp_optimized.cpp | |
parent | 4e97261315211c65459b91685537f82e5c454604 (diff) | |
download | openttd-15d0a22aac6b90a2055e68d019cab4350376a8fd.tar.xz |
(svn r23315) -Codechange: Only encode sprites for zoom levels that will be used.
Diffstat (limited to 'src/blitter/8bpp_optimized.cpp')
-rw-r--r-- | src/blitter/8bpp_optimized.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/blitter/8bpp_optimized.cpp b/src/blitter/8bpp_optimized.cpp index ed3d24a77..24b9252b7 100644 --- a/src/blitter/8bpp_optimized.cpp +++ b/src/blitter/8bpp_optimized.cpp @@ -11,6 +11,7 @@ #include "../stdafx.h" #include "../zoom_func.h" +#include "../settings_type.h" #include "../core/math_func.hpp" #include "8bpp_optimized.hpp" @@ -116,7 +117,19 @@ Sprite *Blitter_8bppOptimized::Encode(SpriteLoader::Sprite *sprite, AllocatorPro /* Make memory for all zoom-levels */ uint memory = sizeof(SpriteData); - for (ZoomLevel i = ZOOM_LVL_BEGIN; i < ZOOM_LVL_END; i++) { + ZoomLevel zoom_min; + ZoomLevel zoom_max; + + if (sprite->type == ST_FONT) { + zoom_min = ZOOM_LVL_NORMAL; + zoom_max = ZOOM_LVL_NORMAL; + } else { + zoom_min = _settings_client.gui.zoom_min; + zoom_max = _settings_client.gui.zoom_max; + if (zoom_max == zoom_min) zoom_max = ZOOM_LVL_MAX; + } + + for (ZoomLevel i = zoom_min; i <= zoom_max; i++) { memory += UnScaleByZoom(sprite->height, i) * UnScaleByZoom(sprite->width, i); } @@ -131,7 +144,7 @@ Sprite *Blitter_8bppOptimized::Encode(SpriteLoader::Sprite *sprite, AllocatorPro byte *dst = temp_dst->data; /* Make the sprites per zoom-level */ - for (ZoomLevel i = ZOOM_LVL_BEGIN; i < ZOOM_LVL_END; i++) { + for (ZoomLevel i = zoom_min; i <= zoom_max; i++) { /* Store the index table */ uint offset = dst - temp_dst->data; temp_dst->offset[i] = offset; |