yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::gfx::TileCache Struct Reference

Smart tile cache with LRU eviction for efficient memory management. More...

#include <tilemap.h>

Public Member Functions

BitmapGetTile (int tile_id)
 Get a cached tile by ID.
 
void CacheTile (int tile_id, Bitmap &&bitmap)
 Cache a tile bitmap.
 
void Clear ()
 Clear the cache.
 
size_t Size () const
 Get cache statistics.
 

Public Attributes

std::unordered_map< int, Bitmapcache_
 
std::list< int > access_order_
 

Static Public Attributes

static constexpr size_t MAX_CACHE_SIZE = 1024
 

Detailed Description

Smart tile cache with LRU eviction for efficient memory management.

Performance Optimizations:

  • LRU eviction policy to keep frequently used tiles in memory
  • Configurable cache size to balance memory usage and performance
  • O(1) tile access and insertion
  • Automatic cache management with minimal overhead

Definition at line 32 of file tilemap.h.

Member Function Documentation

◆ GetTile()

Bitmap * yaze::gfx::TileCache::GetTile ( int  tile_id)
inline

Get a cached tile by ID.

Parameters
tile_idTile identifier
Returns
Pointer to cached tile bitmap or nullptr if not cached

Definition at line 42 of file tilemap.h.

References access_order_, and cache_.

Referenced by yaze::editor::ScreenEditor::DrawDungeonMapScreen(), yaze::editor::ScreenEditor::DrawDungeonMapsRoomGfx(), yaze::gfx::RenderTilesBatch(), and yaze::gfx::UpdateTile16().

◆ CacheTile()

void yaze::gfx::TileCache::CacheTile ( int  tile_id,
Bitmap &&  bitmap 
)
inline

Cache a tile bitmap.

Parameters
tile_idTile identifier
bitmapTile bitmap to cache

Definition at line 58 of file tilemap.h.

References access_order_, cache_, and MAX_CACHE_SIZE.

Referenced by yaze::gfx::RenderTilesBatch().

◆ Clear()

void yaze::gfx::TileCache::Clear ( )
inline

Clear the cache.

Definition at line 73 of file tilemap.h.

References access_order_, and cache_.

◆ Size()

size_t yaze::gfx::TileCache::Size ( ) const
inline

Get cache statistics.

Returns
Number of cached tiles

Definition at line 82 of file tilemap.h.

References cache_.

Member Data Documentation

◆ MAX_CACHE_SIZE

constexpr size_t yaze::gfx::TileCache::MAX_CACHE_SIZE = 1024
staticconstexpr

Definition at line 33 of file tilemap.h.

Referenced by CacheTile().

◆ cache_

std::unordered_map<int, Bitmap> yaze::gfx::TileCache::cache_

Definition at line 34 of file tilemap.h.

Referenced by CacheTile(), Clear(), GetTile(), and Size().

◆ access_order_

std::list<int> yaze::gfx::TileCache::access_order_

Definition at line 35 of file tilemap.h.

Referenced by CacheTile(), Clear(), and GetTile().


The documentation for this struct was generated from the following file: