1#ifndef YAZE_APP_GFX_ARENA_H
2#define YAZE_APP_GFX_ARENA_H
12#include <unordered_map>
129 SDL_Surface*
AllocateSurface(
int width,
int height,
int depth,
int format);
170 if (i < 0 || i >= 223)
return static_cast<gfx::Bitmap*
>(
nullptr);
193 std::function<void(
const std::string& group_name,
int palette_index)>;
202 int palette_index = -1);
310 return total > 0 ?
static_cast<float>(
hits) / total : 0.0f;
343 std::unique_ptr<SDL_Texture, util::SDL_Texture_Deleter>>
346 std::unordered_map<SDL_Surface*,
347 std::unique_ptr<SDL_Surface, util::SDL_Surface_Deleter>>
359 std::unordered_map<SDL_Surface*, std::tuple<int, int, int, int>>
Resource management arena for efficient graphics memory handling.
size_t sheet_cache_max_size_
size_t GetSurfaceCount() const
std::unordered_map< SDL_Surface *, std::unique_ptr< SDL_Surface, util::SDL_Surface_Deleter > > surfaces_
void Initialize(IRenderer *renderer)
struct yaze::gfx::Arena::TexturePool texture_pool_
bool ProcessTextureQueueWithBudget(IRenderer *renderer, float budget_ms)
Process texture queue with a time budget.
SDL_Surface * AllocateSurface(int width, int height, int depth, int format)
std::unordered_map< TextureHandle, std::unique_ptr< SDL_Texture, util::SDL_Texture_Deleter > > textures_
size_t GetPooledSurfaceCount() const
bool HasPendingTextures() const
Check if there are pending textures to process.
auto gfx_sheet(int i)
Get a specific graphics sheet by index.
static constexpr int kTotalTiles
Bitmap * GetSheetWithCache(int sheet_index)
Get a sheet with automatic LRU tracking and texture creation.
size_t GetTextureCount() const
void QueueTextureCommand(TextureCommandType type, Bitmap *bitmap)
int RegisterPaletteListener(PaletteChangeCallback callback)
Register a callback for palette change notifications.
std::array< uint16_t, kTotalTiles > layer2_buffer_
static constexpr int kTilesPerColumn
size_t GetPooledTextureCount() const
static constexpr int kTilesPerRow
auto mutable_gfx_sheets()
Get mutable reference to all graphics sheets.
const SheetCacheStats & GetSheetCacheStats() const
Get sheet cache statistics.
void ResetTextureQueueStats()
Reset texture queue statistics.
SheetCacheStats sheet_cache_stats_
std::function< void(const std::string &group_name, int palette_index)> PaletteChangeCallback
void FreeSurface(SDL_Surface *surface)
auto mutable_gfx_sheet(int i)
Get mutable reference to a specific graphics sheet.
void ProcessTextureQueue(IRenderer *renderer)
std::array< gfx::Bitmap, 223 > gfx_sheets_
bool ProcessSingleTexture(IRenderer *renderer)
Process a single texture command for frame-budget-aware loading.
auto & bg2()
Get reference to background layer 2 buffer.
std::unordered_map< int, std::list< int >::iterator > sheet_lru_map_
std::array< gfx::Bitmap, 223 > & gfx_sheets()
Get reference to all graphics sheets.
std::unordered_map< int, PaletteChangeCallback > palette_listeners_
std::vector< TextureCommand > texture_command_queue_
std::array< uint16_t, kTotalTiles > layer1_buffer_
void NotifySheetModified(int sheet_index)
Notify Arena that a graphics sheet has been modified.
auto & bg1()
Get reference to background layer 1 buffer.
struct yaze::gfx::Arena::SurfacePool surface_pool_
void ResetSheetCacheStats()
Reset sheet cache statistics.
void UnregisterPaletteListener(int listener_id)
Unregister a palette change listener.
TextureQueueStats texture_queue_stats_
size_t texture_command_queue_size() const
void SetSheetCacheSize(size_t max_size)
Set the maximum number of sheet textures to keep cached.
size_t EvictLRUSheets(size_t count=0)
Evict least recently used sheet textures.
size_t GetSheetCacheSize() const
Get current sheet cache size limit.
std::list< int > sheet_lru_list_
size_t GetCachedSheetCount() const
Get number of sheets currently with textures.
int next_palette_listener_id_
void NotifyPaletteModified(const std::string &group_name, int palette_index=-1)
Notify all listeners that a palette has been modified.
const TextureQueueStats & GetTextureQueueStats() const
Get texture queue processing statistics.
void ClearSheetCache()
Clear all sheet texture cache tracking.
void TouchSheet(int sheet_index)
Mark a graphics sheet as recently accessed.
Represents a bitmap image optimized for SNES ROM hacking.
Defines an abstract interface for all rendering operations.
void * TextureHandle
An abstract handle representing a texture.
Statistics for sheet cache performance.
static constexpr size_t MAX_POOL_SIZE
std::vector< SDL_Surface * > available_surfaces_
std::unordered_map< SDL_Surface *, std::tuple< int, int, int, int > > surface_info_
static constexpr size_t MAX_POOL_SIZE
std::vector< TextureHandle > available_textures_
std::unordered_map< TextureHandle, std::pair< int, int > > texture_sizes_
Statistics for texture queue processing.
float avg_texture_time_ms
size_t textures_processed