Smart tile cache with LRU eviction for efficient memory management. More...
#include <tilemap.h>
Public Member Functions | |
| Bitmap * | GetTile (int tile_id) |
| Get a cached tile by ID. | |
| void | CacheTile (int tile_id, const Bitmap &bitmap) |
| Cache a tile bitmap by copying it. | |
| void | Clear () |
| Clear the cache. | |
| size_t | Size () const |
| Get cache statistics. | |
Public Attributes | |
| std::unordered_map< int, std::unique_ptr< Bitmap > > | cache_ |
| std::list< int > | access_order_ |
Static Public Attributes | |
| static constexpr size_t | MAX_CACHE_SIZE = 1024 |
Smart tile cache with LRU eviction for efficient memory management.
Performance Optimizations:
Memory Safety:
|
inline |
Get a cached tile by ID.
| tile_id | Tile identifier |
Definition at line 50 of file tilemap.h.
References access_order_, and cache_.
Referenced by yaze::editor::ScreenEditor::DrawDungeonMapScreen(), yaze::editor::ScreenEditor::DrawDungeonMapsRoomGfx(), yaze::gfx::RenderTile(), yaze::gfx::RenderTile16(), yaze::gfx::RenderTilesBatch(), and yaze::gfx::UpdateTile16().
|
inline |
Cache a tile bitmap by copying it.
| tile_id | Tile identifier |
| bitmap | Tile bitmap to cache (copied, not moved) |
Definition at line 67 of file tilemap.h.
References access_order_, cache_, and MAX_CACHE_SIZE.
Referenced by yaze::editor::ScreenEditor::DrawDungeonMapScreen(), yaze::editor::ScreenEditor::DrawDungeonMapsRoomGfx(), yaze::gfx::RenderTile(), yaze::gfx::RenderTile16(), and yaze::gfx::RenderTilesBatch().
|
inline |
|
inline |
|
staticconstexpr |
Definition at line 38 of file tilemap.h.
Referenced by CacheTile().
| std::unordered_map<int, std::unique_ptr<Bitmap> > yaze::gfx::TileCache::cache_ |
| std::list<int> yaze::gfx::TileCache::access_order_ |
Definition at line 41 of file tilemap.h.
Referenced by CacheTile(), Clear(), and GetTile().