diff options
Diffstat (limited to 'src/blitter')
-rw-r--r-- | src/blitter/32bpp_optimized.cpp | 21 | ||||
-rw-r--r-- | src/blitter/8bpp_optimized.cpp | 17 |
2 files changed, 32 insertions, 6 deletions
diff --git a/src/blitter/32bpp_optimized.cpp b/src/blitter/32bpp_optimized.cpp index 8449fb154..b7d252721 100644 --- a/src/blitter/32bpp_optimized.cpp +++ b/src/blitter/32bpp_optimized.cpp @@ -11,6 +11,7 @@ #include "../stdafx.h" #include "../zoom_func.h" +#include "../settings_type.h" #include "../core/math_func.hpp" #include "32bpp_optimized.hpp" @@ -274,7 +275,19 @@ Sprite *Blitter_32bppOptimized::Encode(SpriteLoader::Sprite *sprite, AllocatorPr /* lengths of streams */ uint32 lengths[ZOOM_LVL_COUNT][2]; - for (ZoomLevel z = ZOOM_LVL_BEGIN; z < ZOOM_LVL_END; z++) { + 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 z = zoom_min; z <= zoom_max; z++) { const SpriteLoader::Sprite *src_orig = ResizeSprite(sprite, z); uint size = src_orig->height * src_orig->width; @@ -358,7 +371,7 @@ Sprite *Blitter_32bppOptimized::Encode(SpriteLoader::Sprite *sprite, AllocatorPr } uint len = 0; // total length of data - for (ZoomLevel z = ZOOM_LVL_BEGIN; z < ZOOM_LVL_END; z++) { + for (ZoomLevel z = zoom_min; z <= zoom_max; z++) { len += lengths[z][0] + lengths[z][1]; } @@ -371,8 +384,8 @@ Sprite *Blitter_32bppOptimized::Encode(SpriteLoader::Sprite *sprite, AllocatorPr SpriteData *dst = (SpriteData *)dest_sprite->data; - for (ZoomLevel z = ZOOM_LVL_BEGIN; z < ZOOM_LVL_END; z++) { - dst->offset[z][0] = z == ZOOM_LVL_BEGIN ? 0 : lengths[z - 1][1] + dst->offset[z - 1][1]; + for (ZoomLevel z = zoom_min; z <= zoom_max; z++) { + dst->offset[z][0] = z == zoom_min ? 0 : lengths[z - 1][1] + dst->offset[z - 1][1]; dst->offset[z][1] = lengths[z][0] + dst->offset[z][0]; memcpy(dst->data + dst->offset[z][0], dst_px_orig[z], lengths[z][0]); 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; |