27#include "table/strings.h"
33uint _sprite_cache_size = 4;
36static std::vector<SpriteCache> _spritecache;
37static std::vector<std::unique_ptr<SpriteFile>> _sprite_files;
39static inline SpriteCache *GetSpriteCache(uint index)
41 return &_spritecache[index];
46 if (index >= _spritecache.size()) {
48 uint items =
Align(index + 1, 1024);
50 Debug(sprite, 4,
"Increasing sprite cache to {} items ({} bytes)", items, items *
sizeof(
SpriteCache));
52 _spritecache.resize(items);
55 return GetSpriteCache(index);
65 for (
auto &f : _sprite_files) {
66 if (f->GetFilename() == filename) {
92 if (file ==
nullptr) {
93 file = _sprite_files.insert(std::end(_sprite_files), std::make_unique<SpriteFile>(filename, subdir, palette_remap))->get();
105static uint _sprite_lru_counter;
107static uint _allocated_sprite_cache_size = 0;
108static int _compact_cache_counter;
126 int size = (i == 0) ? 0x80 : i;
127 if (size > num)
return false;
143 if (
id >= _spritecache.size())
return false;
146 if (
id == 0)
return true;
147 return !(GetSpriteCache(
id)->file_pos == 0 && GetSpriteCache(
id)->
file ==
nullptr);
158 return GetSpriteCache(sprite)->
type;
168 if (!SpriteExists(sprite))
return nullptr;
169 return GetSpriteCache(sprite)->
file;
179 if (!SpriteExists(sprite))
return 0;
180 return GetSpriteCache(sprite)->id;
193 if (file ==
nullptr)
return 0;
196 for (
SpriteID i = begin; i != end; i++) {
197 if (SpriteExists(i)) {
199 if (sc->
file == file) {
201 Debug(sprite, 4,
"Sprite: {}", i);
218 return static_cast<SpriteID>(_spritecache.size());
226 if (sprite[src].width * scaled_1 > UINT16_MAX || sprite[src].height * scaled_1 > UINT16_MAX)
return false;
228 sprite[tgt].width = sprite[src].width * scaled_1;
229 sprite[tgt].height = sprite[src].height * scaled_1;
230 sprite[tgt].x_offs = sprite[src].x_offs * scaled_1;
231 sprite[tgt].y_offs = sprite[src].y_offs * scaled_1;
232 sprite[tgt].colours = sprite[src].colours;
234 sprite[tgt].AllocateData(tgt,
static_cast<size_t>(sprite[tgt].width) * sprite[tgt].height);
237 for (
int y = 0; y < sprite[tgt].height; y++) {
239 for (
int x = 0; x < sprite[tgt].width; x++) {
240 *dst = src_ln[x / scaled_1];
257 sprite[zoom].AllocateData(zoom,
static_cast<size_t>(sprite[zoom].height) * sprite[zoom].width);
263 for (uint y = 0; y < sprite[zoom].height; y++) {
265 assert(src_ln <= src_end);
266 for (uint x = 0; x < sprite[zoom].width; x++) {
267 assert(src < src_ln);
268 if (src + 1 != src_ln && (src + 1)->a != 0) {
276 src = src_ln + sprite[zoom - 1].width;
282 uint width = sprite->
width + pad_left + pad_right;
283 uint height = sprite->
height + pad_top + pad_bottom;
285 if (width > UINT16_MAX || height > UINT16_MAX)
return false;
288 size_t sprite_size =
static_cast<size_t>(sprite->
width) * sprite->
height;
289 std::vector<SpriteLoader::CommonPixel> src_data(sprite->
data, sprite->
data + sprite_size);
290 sprite->
AllocateData(zoom,
static_cast<size_t>(width) * height);
295 for (uint y = 0; y < height; y++) {
296 if (y < pad_top || pad_bottom + y >= height) {
309 src += sprite->
width;
310 data += sprite->
width;
321 sprite->
width = width;
323 sprite->
x_offs -= pad_left;
324 sprite->
y_offs -= pad_top;
332 int min_xoffs = INT32_MAX;
333 int min_yoffs = INT32_MAX;
335 if (
HasBit(sprite_avail, zoom)) {
336 min_xoffs = std::min(min_xoffs,
ScaleByZoom(sprite[zoom].x_offs, zoom));
337 min_yoffs = std::min(min_yoffs,
ScaleByZoom(sprite[zoom].y_offs, zoom));
342 int max_width = INT32_MIN;
343 int max_height = INT32_MIN;
345 if (
HasBit(sprite_avail, zoom)) {
346 max_width = std::max(max_width,
ScaleByZoom(sprite[zoom].width + sprite[zoom].x_offs -
UnScaleByZoom(min_xoffs, zoom), zoom));
347 max_height = std::max(max_height,
ScaleByZoom(sprite[zoom].height + sprite[zoom].y_offs -
UnScaleByZoom(min_yoffs, zoom), zoom));
354 max_width =
Align(max_width, align);
355 max_height =
Align(max_height, align);
360 if (
HasBit(sprite_avail, zoom)) {
363 int pad_left = std::max(0, sprite[zoom].x_offs -
UnScaleByZoom(min_xoffs, zoom));
364 int pad_top = std::max(0, sprite[zoom].y_offs -
UnScaleByZoom(min_yoffs, zoom));
365 int pad_right = std::max(0,
UnScaleByZoom(max_width, zoom) - sprite[zoom].width - pad_left);
366 int pad_bottom = std::max(0,
UnScaleByZoom(max_height, zoom) - sprite[zoom].height - pad_top);
368 if (pad_left > 0 || pad_right > 0 || pad_top > 0 || pad_bottom > 0) {
369 if (!PadSingleSprite(&sprite[zoom], zoom, pad_left, pad_top, pad_right, pad_bottom))
return false;
382 if (!ResizeSpriteIn(sprite, first_avail,
ZOOM_LVL_MIN))
return false;
387 if (!PadSprites(sprite, sprite_avail, encoder))
return false;
393 if (
HasBit(sprite_avail, zoom)) {
402 if (!
HasBit(sprite_avail, zoom)) ResizeSpriteOut(sprite, zoom);
428 static const uint RECOLOUR_SPRITE_SIZE = 257;
429 uint8_t *dest = allocator.
Allocate<uint8_t>(std::max(RECOLOUR_SPRITE_SIZE, num));
431 file.
SeekTo(file_pos, SEEK_SET);
433 uint8_t *dest_tmp =
new uint8_t[std::max(RECOLOUR_SPRITE_SIZE, num)];
436 if (num < RECOLOUR_SPRITE_SIZE) memset(dest_tmp, 0, RECOLOUR_SPRITE_SIZE);
440 for (uint i = 1; i < RECOLOUR_SPRITE_SIZE; i++) {
441 dest[i] = _palmap_w2d[dest_tmp[
_palmap_d2w[i - 1] + 1]];
466 size_t file_pos = sc->file_pos;
470 assert(sc->
type == sprite_type);
472 Debug(sprite, 9,
"Load sprite {}",
id);
475 uint8_t sprite_avail = 0;
476 uint8_t avail_8bpp = 0;
477 uint8_t avail_32bpp = 0;
483 sprite_avail = sprite_loader.
LoadSprite(sprite, file, file_pos, sprite_type,
true, sc->
control_flags, avail_8bpp, avail_32bpp);
485 if (sprite_avail == 0) {
486 sprite_avail = sprite_loader.
LoadSprite(sprite, file, file_pos, sprite_type,
false, sc->
control_flags, avail_8bpp, avail_32bpp);
490 sprite_avail = make_indexed.
LoadSprite(sprite, file, file_pos, sprite_type,
true, sc->
control_flags, sprite_avail, avail_32bpp);
494 if (sprite_avail == 0) {
496 if (
id == SPR_IMG_QUERY) UserError(
"Okay... something went horribly wrong. I couldn't load the fallback sprite. What should I do?");
519 uint8_t *dest = s->
data;
528 if (!ResizeSprites(sprite, sprite_avail, encoder)) {
529 if (
id == SPR_IMG_QUERY) UserError(
"Okay... something went horribly wrong. I couldn't resize the fallback sprite. What should I do?");
543 return encoder->
Encode(sprite, allocator);
548 uint8_t control_flags;
575 size_t old_pos = file.
GetPos();
576 file.
SeekTo(data_offset, SEEK_CUR);
586 offset.file_pos = file.
GetPos() - 4;
587 offset.control_flags = 0;
597 if (colour != 0 && zoom == 0) {
601 if (colour != 0 && zoom == 2) {
611 file.
SeekTo(old_pos, SEEK_SET);
626 size_t file_pos = file.
GetPos();
630 if (num == 0)
return false;
634 void *data =
nullptr;
635 uint8_t control_flags = 0;
636 if (grf_type == 0xFF) {
655 file_pos = iter->second.file_pos;
656 control_flags = iter->second.control_flags;
671 UserError(
"Tried to load too many sprites (#{}; max {})", load_index,
MAX_SPRITES);
674 bool is_mapgen = IsMapgenSpriteID(load_index);
677 if (type !=
SpriteType::Normal) UserError(
"Uhm, would you be so kind not to load a NewGRF that changes the type of the map generator sprites?");
683 sc->file_pos = file_pos;
687 sc->id = file_sprite_id;
702 scnew->file_pos = scold->file_pos;
703 scnew->ptr =
nullptr;
704 scnew->id = scold->id;
719static_assert(
sizeof(
MemBlock) ==
sizeof(
size_t));
721static_assert((
sizeof(size_t) & (
sizeof(
size_t) - 1)) == 0);
728static size_t GetSpriteCacheUsage()
733 for (s = _spritecache_ptr; s->size != 0; s = NextBlock(s)) {
741void IncreaseSpriteLRU()
744 if (_sprite_lru_counter > 16384) {
745 Debug(sprite, 5,
"Fixing lru {}, inuse={}", _sprite_lru_counter, GetSpriteCacheUsage());
748 if (sc.ptr !=
nullptr) {
751 }
else if (sc.lru != -32768) {
756 _sprite_lru_counter = 0;
760 if (++_compact_cache_counter >= 740) {
762 _compact_cache_counter = 0;
774 Debug(sprite, 3,
"Compacting sprite cache, inuse={}", GetSpriteCacheUsage());
776 for (s = _spritecache_ptr; s->size != 0;) {
786 if (next->size == 0)
break;
789 for (i = 0; GetSpriteCache(i)->ptr != next->data; i++) {
790 assert(i != _spritecache.size());
793 GetSpriteCache(i)->ptr = s->data;
796 memmove(s, next, next->size);
802 s->size += NextBlock(s)->size & ~S_FREE_MASK;
823 for (s = _spritecache_ptr; s->size != 0; s = NextBlock(s)) {
826 s->size += NextBlock(s)->size & ~S_FREE_MASK;
834 Debug(sprite, 3,
"DeleteEntryFromSpriteCache, inuse={}", GetSpriteCacheUsage());
837 int cur_lru = 0xffff;
839 if (sc.ptr !=
nullptr && sc.lru < cur_lru) {
847 if (best ==
nullptr) FatalError(
"Out of sprite memory");
863 for (s = _spritecache_ptr; s->size != 0; s = NextBlock(s)) {
865 size_t cur_size = s->size & ~S_FREE_MASK;
869 if (cur_size == mem_req ||
870 cur_size >= mem_req +
sizeof(
MemBlock)) {
875 if (cur_size != mem_req) {
876 NextBlock(s)->size = (cur_size - mem_req) |
S_FREE_MASK;
894 return MallocT<uint8_t>(size);
899 this->data = std::make_unique<uint8_t[]>(size);
900 return this->data.get();
914 static const char *
const sprite_types[] = {
927 uint8_t warning_level = sc->
warned ? 6 : 0;
929 Debug(sprite, warning_level,
"Tried to load {} sprite #{} as a {} sprite. Probable cause: NewGRF interference", sprite_types[
static_cast<uint8_t
>(available)], sprite, sprite_types[
static_cast<uint8_t
>(requested)]);
933 if (sprite == SPR_IMG_QUERY) UserError(
"Uhm, would you be so kind not to load a NewGRF that makes the 'query' sprite a non-normal sprite?");
938 if (sprite == PALETTE_TO_DARK_BLUE) UserError(
"Uhm, would you be so kind not to load a NewGRF that makes the 'PALETTE_TO_DARK_BLUE' sprite a non-remap sprite?");
962 if (!SpriteExists(sprite)) {
963 Debug(sprite, 1,
"Tried to load non-existing sprite #{}. Probable cause: Wrong/missing NewGRFs", sprite);
966 sprite = SPR_IMG_QUERY;
973 if (allocator ==
nullptr && encoder ==
nullptr) {
978 sc->lru = ++_sprite_lru_counter;
981 if (sc->ptr ==
nullptr) {
985 sc->ptr =
ReadSprite(sc, sprite, type, cache_allocator,
nullptr);
992 return ReadSprite(sc, sprite, type, *allocator, encoder);
997static void GfxInitSpriteCache()
1001 uint target_size = (bpp > 0 ? _sprite_cache_size * bpp / 8 : 1) * 1024 * 1024;
1004 static uint last_alloc_attempt = 0;
1006 if (_spritecache_ptr ==
nullptr || (_allocated_sprite_cache_size != target_size && target_size != last_alloc_attempt)) {
1007 delete[]
reinterpret_cast<uint8_t *
>(_spritecache_ptr);
1009 last_alloc_attempt = target_size;
1010 _allocated_sprite_cache_size = target_size;
1014 _spritecache_ptr =
reinterpret_cast<MemBlock *
>(
new(std::nothrow) uint8_t[_allocated_sprite_cache_size + _allocated_sprite_cache_size / 2]);
1016 if (_spritecache_ptr !=
nullptr) {
1018 delete[]
reinterpret_cast<uint8_t *
>(_spritecache_ptr);
1019 _spritecache_ptr =
reinterpret_cast<MemBlock *
>(
new uint8_t[_allocated_sprite_cache_size]);
1020 }
else if (_allocated_sprite_cache_size < 2 * 1024 * 1024) {
1021 UserError(
"Cannot allocate spritecache");
1024 _allocated_sprite_cache_size >>= 1;
1026 }
while (_spritecache_ptr ==
nullptr);
1028 if (_allocated_sprite_cache_size != target_size) {
1029 Debug(misc, 0,
"Not enough memory to allocate {} MiB of spritecache. Spritecache was reduced to {} MiB.", target_size / 1024 / 1024, _allocated_sprite_cache_size / 1024 / 1024);
1031 ErrorMessageData msg(STR_CONFIG_ERROR_OUT_OF_MEMORY, STR_CONFIG_ERROR_SPRITECACHE_TOO_BIG);
1032 msg.SetDParam(0, target_size);
1033 msg.SetDParam(1, _allocated_sprite_cache_size);
1041 NextBlock(_spritecache_ptr)->size = 0;
1044void GfxInitSpriteMem()
1046 GfxInitSpriteCache();
1049 _spritecache.clear();
1050 _spritecache.shrink_to_fit();
1052 _compact_cache_counter = 0;
1053 _sprite_files.clear();
debug_inline constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
constexpr uint8_t FindFirstBit(T x)
Search the first set bit in a value.
static Blitter * GetCurrentBlitter()
Get the current active blitter (always set by calling SelectBlitter).
virtual uint8_t GetScreenDepth()=0
Get the screen depth this blitter works for.
SpriteAllocator that allocates memory from the sprite cache.
void * AllocatePtr(size_t size) override
Allocate memory for a sprite.
The data of the error message.
void ReadBlock(void *ptr, size_t size)
Read a block.
size_t GetPos() const
Get position in the file.
void SeekTo(size_t pos, int mode)
Seek in the current file.
uint8_t ReadByte()
Read a byte from the file.
uint32_t ReadDword()
Read a double word (32 bits) from the file (in low endian format).
void SkipBytes(size_t n)
Skip n bytes ahead in the file.
uint16_t ReadWord()
Read a word (16 bits) from the file (in low endian format).
A reusable buffer that can be used for places that temporary allocate a bit of memory and do that ver...
void * AllocatePtr(size_t size) override
Sprite allocator simply using malloc.
Interface for something that can allocate memory for a sprite.
T * Allocate(size_t size)
Allocate memory for a sprite.
Interface for something that can encode a sprite.
virtual Sprite * Encode(const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator)=0
Convert a sprite from the loader to our own format.
virtual bool Is32BppSupported()=0
Can the sprite encoder make use of RGBA sprites?
virtual uint GetSpriteAlignment()
Get the value which the height and width on a sprite have to be aligned by.
RandomAccessFile with some extra information specific for sprite files.
bool NeedsPaletteRemap() const
Whether a palette remap is needed when loading sprites from this file.
uint8_t GetContainerVersion() const
Get the version number of container type used by the file.
void SeekToBegin()
Seek to the begin of the content, i.e.
Sprite loader for graphics coming from a (New)GRF.
uint8_t LoadSprite(SpriteLoader::SpriteCollection &sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, bool load_32bpp, uint8_t control_flags, uint8_t &avail_8bpp, uint8_t &avail_32bpp) override
Load a sprite from the disk and return a sprite struct which is the same for all loaders.
Sprite loader for converting graphics coming from another source.
uint8_t LoadSprite(SpriteLoader::SpriteCollection &sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, bool load_32bpp, uint8_t control_flags, uint8_t &avail_8bpp, uint8_t &avail_32bpp) override
Load a sprite from the disk and return a sprite struct which is the same for all loaders.
std::array< Sprite, ZOOM_LVL_END > SpriteCollection
Type defining a collection of sprites, one for each zoom level.
void * AllocatePtr(size_t size) override
Allocate memory for a sprite.
virtual void ClearSystemSprites()
Clear all cached sprites.
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
Functions related to errors.
void ScheduleErrorMessage(ErrorList &datas)
Schedule a list of errors.
Error reporting related functions.
Factory to 'query' all available blitters.
Subdirectory
The different kinds of subdirectories OpenTTD uses.
ZoomLevel _font_zoom
Sprite font Zoom level (not clamped)
Functions related to the gfx engine.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
SpriteType
Types of sprites that might be loaded.
@ Recolour
Recolour sprite.
@ Font
A sprite used for fonts.
@ MapGen
Special sprite for the map generator.
@ Invalid
Pseudosprite or other unusable sprite, used only internally.
@ Normal
The most basic (normal) sprite.
Base for reading sprites from (New)GRFs.
Base for converting sprites from another source from 32bpp RGBA to indexed 8bpp.
constexpr T Align(const T x, uint n)
Return the smallest multiple of n equal or greater than x.
Functions related to memory operations.
void MemCpyT(T *destination, const T *source, size_t num=1)
Type-safe version of memcpy().
void MemSetT(T *ptr, uint8_t value, size_t num=1)
Type-safe version of memset().
Translation tables from one GRF to another GRF.
static const uint8_t _palmap_d2w[]
Converting from the DOS palette to the Windows palette.
Class related to random access to files.
A number of safeguards to prevent using unsafe methods.
ClientSettings _settings_client
The current settings for this game.
Types related to global configuration settings.
static std::map< uint32_t, GrfSpriteOffset > _grf_sprite_offsets
Map from sprite numbers to position in the GRF file.
SpriteType GetSpriteType(SpriteID sprite)
Get the sprite type of a given sprite.
void GfxClearSpriteCache()
Remove all encoded sprites from the sprite cache without discarding sprite location information.
static SpriteFile * GetCachedSpriteFileByName(const std::string &filename)
Get the cached SpriteFile given the name of the file.
uint GetSpriteCountForFile(const std::string &filename, SpriteID begin, SpriteID end)
Count the sprites which originate from a specific file in a range of SpriteIDs.
static void DeleteEntryFromSpriteCache(SpriteCache *item)
Delete a single entry from the sprite cache.
static void * ReadSprite(const SpriteCache *sc, SpriteID id, SpriteType sprite_type, SpriteAllocator &allocator, SpriteEncoder *encoder)
Read a sprite from disk.
void GfxClearFontSpriteCache()
Remove all encoded font sprites from the sprite cache without discarding sprite location information.
SpriteID GetMaxSpriteID()
Get a reasonable (upper bound) estimate of the maximum SpriteID used in OpenTTD; there will be no spr...
SpriteFile & OpenCachedSpriteFile(const std::string &filename, Subdirectory subdir, bool palette_remap)
Open/get the SpriteFile that is cached for use in the sprite cache.
static void * HandleInvalidSpriteRequest(SpriteID sprite, SpriteType requested, SpriteCache *sc, SpriteAllocator *allocator)
Handles the case when a sprite of different type is requested than is present in the SpriteCache.
void * GetRawSprite(SpriteID sprite, SpriteType type, SpriteAllocator *allocator, SpriteEncoder *encoder)
Reads a sprite (from disk or sprite cache).
std::span< const std::unique_ptr< SpriteFile > > GetCachedSpriteFiles()
Get the list of cached SpriteFiles.
bool LoadNextSprite(SpriteID load_index, SpriteFile &file, uint file_sprite_id)
Load a real or recolour sprite.
SpriteFile * GetOriginFile(SpriteID sprite)
Get the SpriteFile of a given sprite.
size_t GetGRFSpriteOffset(uint32_t id)
Get the file offset for a specific sprite in the sprite section of a GRF.
static void * ReadRecolourSprite(SpriteFile &file, size_t file_pos, uint num, SpriteAllocator &allocator)
Load a recolour sprite into memory.
bool SkipSpriteData(SpriteFile &file, uint8_t type, uint16_t num)
Skip the given amount of sprite graphics data.
uint32_t GetSpriteLocalID(SpriteID sprite)
Get the GRF-local sprite id of a given sprite.
static void CompactSpriteCache()
Called when holes in the sprite cache should be removed.
static const size_t S_FREE_MASK
S_FREE_MASK is used to mask-out lower bits of MemBlock::size If they are non-zero,...
void ReadGRFSpriteOffsets(SpriteFile &file)
Parse the sprite section of GRFs.
Functions to cache sprites in memory.
@ SCCF_ALLOW_ZOOM_MIN_2X_32BPP
Allow use of sprite min zoom setting at 2x in 32bpp mode.
@ SCCF_ALLOW_ZOOM_MIN_1X_32BPP
Allow use of sprite min zoom setting at 1x in 32bpp mode.
@ SCCF_ALLOW_ZOOM_MIN_1X_PAL
Allow use of sprite min zoom setting at 1x in palette mode.
@ SCCF_ALLOW_ZOOM_MIN_2X_PAL
Allow use of sprite min zoom setting at 2x in palette mode.
Internal functions to cache sprites in memory.
@ SCC_MASK
Mask of valid colour bits.
@ SCC_PAL
Sprite has palette data.
This file contains all sprite-related enums and defines.
static constexpr uint32_t MAX_SPRITES
Masks needed for sprite operations.
Definition of base types and functions in a cross-platform compatible way.
GUISettings gui
settings related to the GUI
ZoomLevel sprite_zoom_min
maximum zoom level at which higher-resolution alternative sprites will be used (if available) instead...
uint8_t control_flags
Control flags, see SpriteCacheCtrlFlags.
uint32_t length
Length of sprite data.
bool warned
True iff the user has been warned about incorrect use of this sprite.
SpriteType type
In some cases a single sprite is misused by two NewGRFs. Once as real sprite and once as recolour spr...
SpriteFile * file
The file the sprite in this entry can be found in.
Definition of a common pixel in OpenTTD's realm.
Structure for passing information from the sprite loader to the blitter.
static ReusableBuffer< SpriteLoader::CommonPixel > buffer[ZOOM_LVL_END]
Allocated memory to pass sprite data around.
void AllocateData(ZoomLevel zoom, size_t size)
Allocate the sprite data of this sprite.
uint16_t width
Width of the sprite.
int16_t x_offs
The x-offset of where the sprite will be drawn.
SpriteLoader::CommonPixel * data
The sprite itself.
uint16_t height
Height of the sprite.
int16_t y_offs
The y-offset of where the sprite will be drawn.
Data structure describing a sprite.
uint16_t width
Width of the sprite.
uint16_t height
Height of the sprite.
int16_t y_offs
Number of pixels to shift the sprite downwards.
uint8_t data[]
Sprite data.
int16_t x_offs
Number of pixels to shift the sprite to the right.
Base of all video drivers.
Functions related to zooming.
int ScaleByZoom(int value, ZoomLevel zoom)
Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_MIN) When shifting right,...
int UnScaleByZoom(int value, ZoomLevel zoom)
Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_MIN) When shifting right,...
ZoomLevel
All zoom levels we know.
@ ZOOM_LVL_NORMAL
The normal zoom level.
@ ZOOM_LVL_BEGIN
Begin for iteration.
@ ZOOM_LVL_IN_2X
Zoomed 2 times in.
@ ZOOM_LVL_END
End for iteration.
@ ZOOM_LVL_MIN
Minimum zoom level.
@ ZOOM_LVL_IN_4X
Zoomed 4 times in.