Resource management arena for efficient graphics memory handling. More...
#include <arena.h>
Classes | |
| struct | SheetCacheStats |
| Statistics for sheet cache performance. More... | |
| struct | SurfacePool |
| struct | TextureCommand |
| struct | TexturePool |
| struct | TextureQueueStats |
| Statistics for texture queue processing. More... | |
Public Types | |
| enum class | TextureCommandType { CREATE , UPDATE , DESTROY } |
| using | PaletteChangeCallback |
Public Member Functions | |
| void | Initialize (IRenderer *renderer) |
| ~Arena () | |
| void | QueueTextureCommand (TextureCommandType type, Bitmap *bitmap) |
| void | ProcessTextureQueue (IRenderer *renderer) |
| void | ClearTextureQueue () |
| bool | HasPendingTextures () const |
| Check if there are pending textures to process. | |
| bool | ProcessSingleTexture (IRenderer *renderer) |
| Process a single texture command for frame-budget-aware loading. | |
| bool | ProcessTextureQueueWithBudget (IRenderer *renderer, float budget_ms) |
| Process texture queue with a time budget. | |
| const TextureQueueStats & | GetTextureQueueStats () const |
| Get texture queue processing statistics. | |
| void | ResetTextureQueueStats () |
| Reset texture queue statistics. | |
| SDL_Surface * | AllocateSurface (int width, int height, int depth, int format) |
| void | FreeSurface (SDL_Surface *surface) |
| void | Shutdown () |
| size_t | GetTextureCount () const |
| size_t | GetSurfaceCount () const |
| size_t | GetPooledTextureCount () const |
| size_t | GetPooledSurfaceCount () const |
| size_t | texture_command_queue_size () const |
| std::array< gfx::Bitmap, 223 > & | gfx_sheets () |
| Get reference to all graphics sheets. | |
| auto | gfx_sheet (int i) |
| Get a specific graphics sheet by index. | |
| auto | mutable_gfx_sheet (int i) |
| Get mutable reference to a specific graphics sheet. | |
| auto | mutable_gfx_sheets () |
| Get mutable reference to all graphics sheets. | |
| void | NotifySheetModified (int sheet_index) |
| Notify Arena that a graphics sheet has been modified. | |
| void | NotifyPaletteModified (const std::string &group_name, int palette_index=-1) |
| Notify all listeners that a palette has been modified. | |
| int | RegisterPaletteListener (PaletteChangeCallback callback) |
| Register a callback for palette change notifications. | |
| void | UnregisterPaletteListener (int listener_id) |
| Unregister a palette change listener. | |
| auto & | bg1 () |
| Get reference to background layer 1 buffer. | |
| auto & | bg2 () |
| Get reference to background layer 2 buffer. | |
| void | TouchSheet (int sheet_index) |
| Mark a graphics sheet as recently accessed. | |
| Bitmap * | GetSheetWithCache (int sheet_index) |
| Get a sheet with automatic LRU tracking and texture creation. | |
| void | SetSheetCacheSize (size_t max_size) |
| Set the maximum number of sheet textures to keep cached. | |
| size_t | GetSheetCacheSize () const |
| Get current sheet cache size limit. | |
| size_t | GetCachedSheetCount () const |
| Get number of sheets currently with textures. | |
| size_t | EvictLRUSheets (size_t count=0) |
| Evict least recently used sheet textures. | |
| void | ClearSheetCache () |
| Clear all sheet texture cache tracking. | |
| const SheetCacheStats & | GetSheetCacheStats () const |
| Get sheet cache statistics. | |
| void | ResetSheetCacheStats () |
| Reset sheet cache statistics. | |
Static Public Member Functions | |
| static Arena & | Get () |
Private Member Functions | |
| Arena () | |
Private Attributes | |
| BackgroundBuffer | bg1_ |
| BackgroundBuffer | bg2_ |
| std::array< uint16_t, kTotalTiles > | layer1_buffer_ |
| std::array< uint16_t, kTotalTiles > | layer2_buffer_ |
| std::array< gfx::Bitmap, 223 > | gfx_sheets_ |
| std::unordered_map< TextureHandle, std::unique_ptr< SDL_Texture, util::SDL_Texture_Deleter > > | textures_ |
| std::unordered_map< SDL_Surface *, std::unique_ptr< SDL_Surface, util::SDL_Surface_Deleter > > | surfaces_ |
| struct yaze::gfx::Arena::TexturePool | texture_pool_ |
| struct yaze::gfx::Arena::SurfacePool | surface_pool_ |
| std::vector< TextureCommand > | texture_command_queue_ |
| IRenderer * | renderer_ = nullptr |
| TextureQueueStats | texture_queue_stats_ |
| std::unordered_map< int, PaletteChangeCallback > | palette_listeners_ |
| int | next_palette_listener_id_ = 1 |
| std::list< int > | sheet_lru_list_ |
| std::unordered_map< int, std::list< int >::iterator > | sheet_lru_map_ |
| size_t | sheet_cache_max_size_ = 64 |
| SheetCacheStats | sheet_cache_stats_ |
Static Private Attributes | |
| static constexpr int | kTilesPerRow = 64 |
| static constexpr int | kTilesPerColumn = 64 |
| static constexpr int | kTotalTiles = kTilesPerRow * kTilesPerColumn |
Resource management arena for efficient graphics memory handling.
The Arena class provides centralized management of SDL textures and surfaces for the YAZE ROM hacking editor. It implements several key optimizations:
Key Features:
Performance Optimizations:
ROM Hacking Specific:
|
strong |
| yaze::gfx::Arena::~Arena | ( | ) |
Definition at line 31 of file arena.cc.
References Shutdown().

|
private |
Definition at line 26 of file arena.cc.
References layer1_buffer_, and layer2_buffer_.
|
static |
Definition at line 21 of file arena.cc.
Referenced by yaze::editor::PixelEditorPanel::ApplyBrush(), yaze::editor::PixelEditorPanel::ApplyEraser(), yaze::editor::PixelEditorPanel::ApplyEyedropper(), yaze::editor::PixelEditorPanel::ApplyFill(), yaze::editor::MessageEditor::ApplyFontPalette(), yaze::gui::CanvasUtils::ApplyPaletteGroup(), yaze::editor::PaletteControlsPanel::ApplyPaletteToAllSheets(), yaze::editor::Tile16Editor::ApplyPaletteToCurrentTile16Bitmap(), yaze::editor::PaletteControlsPanel::ApplyPaletteToSheet(), yaze::editor::PixelEditorPanel::ApplyPencil(), yaze::gui::CanvasUtils::ApplyPendingPaletteUpdates(), yaze::gfx::PaletteManager::ApplyPreviewChanges(), yaze::gui::PaletteEditorWidget::ApplyROMPalette(), yaze::editor::LinkSpritePanel::ApplySelectedPalette(), yaze::gfx::Bitmap::Bitmap(), yaze::zelda3::Inventory::BuildTileset(), yaze::zelda3::TitleScreen::BuildTileset(), yaze::editor::CanvasNavigationManager::CheckForCurrentMap(), yaze::editor::OverworldEditor::Clear(), yaze::editor::OverworldEditor::ClearScratchSpace(), yaze::test::TestManager::CollectResourceStats(), yaze::editor::Tile16Editor::CommitChangesToBlockset(), yaze::editor::Tile16Editor::CopyTile16ToAtlas(), yaze::editor::Tile16Editor::CopyTile16ToClipboard(), yaze::gfx::Bitmap::Create(), yaze::zelda3::OverworldMapScreen::Create(), yaze::zelda3::Inventory::Create(), yaze::gfx::Bitmap::CreateTexture(), yaze::gfx::CreateTilemap(), yaze::editor::GraphicsEditor::DecompressImportData(), yaze::editor::GraphicsEditor::DecompressSuperDonkey(), yaze::Controller::DoRender(), yaze::editor::DungeonRoomGraphicsPanel::Draw(), yaze::editor::OverworldCanvasRenderer::DrawAreaGraphics(), yaze::gui::DrawBitmap(), yaze::gui::DrawBitmapPreview(), yaze::editor::GfxGroupEditor::DrawBlocksetViewer(), yaze::editor::PixelEditorPanel::DrawCanvas(), yaze::editor::GraphicsEditor::DrawCgxImport(), yaze::editor::PixelEditorPanel::DrawColorPicker(), yaze::editor::SpriteEditor::DrawCurrentSheets(), yaze::editor::ScreenEditor::DrawDungeonMapScreen(), yaze::editor::ScreenEditor::DrawDungeonMapsRoomGfx(), yaze::editor::PixelEditorPanel::DrawLine(), yaze::editor::MessageEditor::DrawMessagePreview(), yaze::editor::PixelEditorPanel::DrawMiniMap(), yaze::editor::ScreenEditor::DrawOverworldMapEditor(), yaze::editor::PixelEditorPanel::DrawRectangle(), yaze::editor::DungeonCanvasViewer::DrawRoomBackgroundLayers(), yaze::editor::DungeonObjectSelector::DrawRoomGraphics(), yaze::editor::GfxGroupEditor::DrawRoomsetViewer(), yaze::editor::OverworldEditor::DrawScratchSpace(), yaze::editor::GraphicsEditor::DrawScrImport(), yaze::editor::SheetBrowserPanel::DrawSheetGrid(), yaze::editor::LinkSpritePanel::DrawSheetThumbnail(), yaze::editor::GfxGroupEditor::DrawSpritesetViewer(), yaze::editor::OverworldCanvasRenderer::DrawTile8Selector(), yaze::editor::ScreenEditor::DrawTitleScreenBG1Canvas(), yaze::editor::ScreenEditor::DrawTitleScreenBG2Canvas(), yaze::editor::ScreenEditor::DrawTitleScreenCompositeCanvas(), yaze::editor::ScreenEditor::DrawTitleScreenEditor(), yaze::editor::Tile16Editor::DrawToCurrentTile16(), yaze::editor::PixelEditorPanel::EndSelection(), yaze::editor::MessageEditor::EnsureFontTexturesReady(), yaze::editor::EditorManager::EnsureGameDataLoaded(), yaze::editor::OverworldEditor::EnsureMapTexture(), yaze::cli::agent::tools::VisualAnalysisBase::ExtractTileAtPosition(), yaze::editor::PixelEditorPanel::FinalizeUndoAction(), getArenaStatus(), getGfxSheetInfo(), yaze::editor::DungeonObjectSelector::GetOrCreatePreview(), yaze::editor::PixelEditorPanel::HandleCanvasInput(), yaze::cli::HandleGfxExportLegacy(), yaze::cli::HandleGfxImportLegacy(), yaze::editor::Tile16Editor::Initialize(), yaze::editor::GraphicsEditor::Load(), yaze::editor::ScreenEditor::Load(), yaze::editor::OverworldEditor::Load(), yaze::editor::EditorManager::LoadAssets(), yaze::editor::ScreenEditor::LoadBinaryGfx(), yaze::zelda3::OverworldMapScreen::LoadCustomMap(), yaze::zelda3::LoadDungeonMapGfxFromBinary(), yaze::zelda3::LoadDungeonMapTile16(), yaze::editor::OverworldEditor::LoadGraphics(), yaze::editor::OverworldEditor::LoadSpriteGraphics(), yaze::editor::SpriteEditor::LoadSpriteGraphicsBuffer(), yaze::editor::Tile16Editor::LoadTile16FromScratchSpace(), yaze::editor::Tile16Editor::LoadTile8(), yaze::zelda3::TitleScreen::LoadTitleScreen(), yaze::Controller::OnEntry(), yaze::editor::ObjectEditorPanel::OpenStaticObjectEditor(), yaze::gfx::Bitmap::operator=(), yaze::gfx::Bitmap::operator=(), yaze::editor::PixelEditorPanel::PasteSelection(), yaze::editor::Tile16Editor::PasteTile16FromClipboard(), yaze::editor::Tile16Editor::PreviewPaletteChange(), yaze::editor::DungeonEditorV2::ProcessDeferredTextures(), yaze::editor::OverworldEditor::ProcessDeferredTextures(), yaze::editor::GraphicsPixelEditAction::Redo(), yaze::gfx::Bitmap::Reformat(), yaze::editor::Tile16Editor::RefreshAllPalettes(), yaze::editor::MapRefreshCoordinator::RefreshChildMapOnDemand(), yaze::editor::MessageEditor::RefreshFontAtlasBitmap(), yaze::editor::MapRefreshCoordinator::RefreshMapPalette(), yaze::editor::MapRefreshCoordinator::RefreshMultiAreaMapsSafely(), yaze::editor::MapRefreshCoordinator::RefreshTile16Blockset(), yaze::editor::Tile16Editor::RefreshTile16Blockset(), yaze::editor::Tile16Editor::RegenerateTile16BitmapFromROM(), yaze::zelda3::TitleScreen::RenderBG1Layer(), yaze::zelda3::TitleScreen::RenderBG2Layer(), yaze::gui::CanvasContextMenu::RenderBitmapOperationsMenu(), yaze::zelda3::TitleScreen::RenderCompositeLayer(), yaze::editor::TileObjectHandler::RenderGhostPreviewBitmap(), yaze::gui::RenderPreviewPanel(), yaze::zelda3::Room::RenderRoomGraphics(), yaze::gfx::RenderTilesBatch(), yaze::editor::TilePaintingManager::RenderUpdatedMapBitmap(), yaze::gfx::Bitmap::Resize(), yaze::editor::Tile16Editor::RestoreFromSnapshot(), yaze::test::ArenaTestSuite::RunArenaAllocationTest(), yaze::test::ArenaTestSuite::RunArenaCleanupTest(), yaze::test::IntegratedTestSuite::RunArenaIntegrityTest(), yaze::test::IntegratedTestSuite::RunArenaResourceManagementTest(), yaze::test::ArenaTestSuite::RunArenaResourceTrackingTest(), yaze::test::IntegratedTestSuite::RunGraphicsValidationTest(), yaze::test::PerformanceTestSuite::RunMemoryUsageTest(), yaze::test::PerformanceTestSuite::RunResourceLeakTest(), yaze::editor::GraphicsEditor::Save(), yaze::editor::OverworldEditor::SaveCurrentSelectionToScratch(), yaze::gfx::PaletteManager::SaveGroup(), yaze::editor::EditorManager::SaveRom(), yaze::editor::Tile16Editor::SaveTile16ToScratchSpace(), yaze::editor::PixelEditorPanel::SaveUndoState(), yaze::editor::Tile16Editor::SetCurrentTile(), yaze::platform::NullWindowBackend::Shutdown(), yaze::platform::SDL2WindowBackend::Shutdown(), yaze::core::ShutdownWindow(), yaze::editor::GraphicsPixelEditAction::Undo(), yaze::editor::Tile16Editor::UpdateBlocksetBitmap(), yaze::editor::MapRefreshCoordinator::UpdateBlocksetWithPendingTileChanges(), yaze::editor::Tile16Editor::UpdateLivePreview(), yaze::editor::OverworldEditor::UpdateScratchBitmapTile(), yaze::gfx::Bitmap::UpdateTexture(), yaze::gfx::UpdateTile16(), yaze::editor::Tile16Editor::UpdateTile16Edit(), yaze::editor::Tile16Editor::UpdateTile8Palette(), and yaze::gfx::UpdateTilemap().
| void yaze::gfx::Arena::Initialize | ( | IRenderer * | renderer | ) |
Definition at line 17 of file arena.cc.
References renderer_.
Referenced by yaze::Controller::OnEntry().
| void yaze::gfx::Arena::QueueTextureCommand | ( | TextureCommandType | type, |
| Bitmap * | bitmap ) |
Definition at line 36 of file arena.cc.
References yaze::gfx::Bitmap::generation(), and texture_command_queue_.
Referenced by yaze::editor::MessageEditor::ApplyFontPalette(), yaze::gui::CanvasUtils::ApplyPaletteGroup(), yaze::editor::Tile16Editor::ApplyPaletteToCurrentTile16Bitmap(), yaze::gui::CanvasUtils::ApplyPendingPaletteUpdates(), yaze::gui::PaletteEditorWidget::ApplyROMPalette(), yaze::editor::LinkSpritePanel::ApplySelectedPalette(), yaze::zelda3::Inventory::BuildTileset(), yaze::zelda3::TitleScreen::BuildTileset(), yaze::editor::CanvasNavigationManager::CheckForCurrentMap(), yaze::editor::OverworldEditor::ClearScratchSpace(), yaze::editor::Tile16Editor::CommitChangesToBlockset(), yaze::editor::Tile16Editor::CopyTile16ToAtlas(), yaze::editor::Tile16Editor::CopyTile16ToClipboard(), yaze::zelda3::OverworldMapScreen::Create(), yaze::zelda3::Inventory::Create(), yaze::gfx::Bitmap::CreateTexture(), yaze::gfx::CreateTilemap(), yaze::editor::GraphicsEditor::DecompressImportData(), yaze::editor::GraphicsEditor::DecompressSuperDonkey(), yaze::editor::OverworldCanvasRenderer::DrawAreaGraphics(), yaze::gui::DrawBitmap(), yaze::gui::DrawBitmapPreview(), yaze::editor::GraphicsEditor::DrawCgxImport(), yaze::editor::ScreenEditor::DrawDungeonMapScreen(), yaze::editor::ScreenEditor::DrawDungeonMapsRoomGfx(), yaze::editor::MessageEditor::DrawMessagePreview(), yaze::editor::ScreenEditor::DrawOverworldMapEditor(), yaze::editor::DungeonCanvasViewer::DrawRoomBackgroundLayers(), yaze::editor::OverworldEditor::DrawScratchSpace(), yaze::editor::GraphicsEditor::DrawScrImport(), yaze::editor::LinkSpritePanel::DrawSheetThumbnail(), yaze::editor::ScreenEditor::DrawTitleScreenBG1Canvas(), yaze::editor::ScreenEditor::DrawTitleScreenBG2Canvas(), yaze::editor::ScreenEditor::DrawTitleScreenCompositeCanvas(), yaze::editor::ScreenEditor::DrawTitleScreenEditor(), yaze::editor::Tile16Editor::DrawToCurrentTile16(), yaze::editor::MessageEditor::EnsureFontTexturesReady(), yaze::editor::OverworldEditor::EnsureMapTexture(), EvictLRUSheets(), yaze::editor::DungeonObjectSelector::GetOrCreatePreview(), GetSheetWithCache(), yaze::editor::Tile16Editor::Initialize(), yaze::editor::GraphicsEditor::Load(), yaze::editor::ScreenEditor::Load(), yaze::editor::ScreenEditor::LoadBinaryGfx(), yaze::zelda3::OverworldMapScreen::LoadCustomMap(), yaze::zelda3::LoadDungeonMapGfxFromBinary(), yaze::zelda3::LoadDungeonMapTile16(), yaze::editor::OverworldEditor::LoadGraphics(), yaze::editor::OverworldEditor::LoadSpriteGraphics(), yaze::editor::Tile16Editor::LoadTile16FromScratchSpace(), yaze::editor::Tile16Editor::LoadTile8(), yaze::zelda3::TitleScreen::LoadTitleScreen(), NotifySheetModified(), yaze::editor::ObjectEditorPanel::OpenStaticObjectEditor(), yaze::gfx::Bitmap::operator=(), yaze::editor::Tile16Editor::PasteTile16FromClipboard(), yaze::editor::Tile16Editor::PreviewPaletteChange(), yaze::editor::Tile16Editor::RefreshAllPalettes(), yaze::editor::MapRefreshCoordinator::RefreshChildMapOnDemand(), yaze::editor::MessageEditor::RefreshFontAtlasBitmap(), yaze::editor::MapRefreshCoordinator::RefreshMapPalette(), yaze::editor::MapRefreshCoordinator::RefreshMultiAreaMapsSafely(), yaze::editor::MapRefreshCoordinator::RefreshTile16Blockset(), yaze::editor::Tile16Editor::RefreshTile16Blockset(), yaze::editor::Tile16Editor::RegenerateTile16BitmapFromROM(), yaze::zelda3::TitleScreen::RenderBG1Layer(), yaze::zelda3::TitleScreen::RenderBG2Layer(), yaze::gui::CanvasContextMenu::RenderBitmapOperationsMenu(), yaze::zelda3::TitleScreen::RenderCompositeLayer(), yaze::editor::TileObjectHandler::RenderGhostPreviewBitmap(), yaze::gui::RenderPreviewPanel(), yaze::zelda3::Room::RenderRoomGraphics(), yaze::gfx::RenderTilesBatch(), yaze::editor::TilePaintingManager::RenderUpdatedMapBitmap(), yaze::editor::Tile16Editor::RestoreFromSnapshot(), yaze::editor::OverworldEditor::SaveCurrentSelectionToScratch(), yaze::editor::Tile16Editor::SaveTile16ToScratchSpace(), yaze::editor::Tile16Editor::SetCurrentTile(), yaze::editor::Tile16Editor::UpdateBlocksetBitmap(), yaze::editor::MapRefreshCoordinator::UpdateBlocksetWithPendingTileChanges(), yaze::editor::Tile16Editor::UpdateLivePreview(), yaze::editor::OverworldEditor::UpdateScratchBitmapTile(), yaze::gfx::Bitmap::UpdateTexture(), yaze::gfx::UpdateTile16(), yaze::editor::Tile16Editor::UpdateTile16Edit(), yaze::editor::Tile16Editor::UpdateTile8Palette(), and yaze::gfx::UpdateTilemap().

| void yaze::gfx::Arena::ProcessTextureQueue | ( | IRenderer * | renderer | ) |
Definition at line 116 of file arena.cc.
References CREATE, yaze::gfx::IRenderer::CreateTexture(), DESTROY, yaze::gfx::IRenderer::DestroyTexture(), yaze::zelda3::PaletteDebugger::Get(), yaze::platform::GetSurfacePalette(), LOG_DEBUG, LOG_ERROR, LOG_WARN, yaze::zelda3::PaletteDebugger::LogPaletteApplication(), yaze::zelda3::PaletteDebugger::LogSurfaceState(), yaze::zelda3::PaletteDebugger::LogTextureCreation(), renderer_, texture_command_queue_, UPDATE, and yaze::gfx::IRenderer::UpdateTexture().
Referenced by yaze::Controller::DoRender(), yaze::editor::DungeonRoomGraphicsPanel::Draw(), yaze::editor::DungeonObjectSelector::GetOrCreatePreview(), yaze::editor::ObjectEditorPanel::OpenStaticObjectEditor(), yaze::editor::DungeonEditorV2::ProcessDeferredTextures(), yaze::editor::OverworldEditor::ProcessDeferredTextures(), yaze::editor::TileObjectHandler::RenderGhostPreviewBitmap(), and Shutdown().
| void yaze::gfx::Arena::ClearTextureQueue | ( | ) |
Definition at line 42 of file arena.cc.
References texture_command_queue_.
|
inline |
Check if there are pending textures to process.
Definition at line 70 of file arena.h.
References texture_command_queue_.
| bool yaze::gfx::Arena::ProcessSingleTexture | ( | IRenderer * | renderer | ) |
Process a single texture command for frame-budget-aware loading.
| renderer | The renderer to use for texture operations |
Definition at line 46 of file arena.cc.
References CREATE, yaze::gfx::IRenderer::CreateTexture(), DESTROY, yaze::gfx::IRenderer::DestroyTexture(), LOG_DEBUG, LOG_ERROR, renderer_, texture_command_queue_, UPDATE, and yaze::gfx::IRenderer::UpdateTexture().
Referenced by ProcessTextureQueueWithBudget().

| bool yaze::gfx::Arena::ProcessTextureQueueWithBudget | ( | IRenderer * | renderer, |
| float | budget_ms ) |
Process texture queue with a time budget.
Processes texture commands until either the queue is empty or the time budget is exceeded. Uses microsecond precision timing to avoid overshooting frame budgets.
| renderer | The renderer to use for texture operations |
| budget_ms | Maximum time in milliseconds to spend processing |
Example usage for 60 FPS (16.67ms frame time): // Allow up to 4ms for texture loading per frame arena.ProcessTextureQueueWithBudget(renderer, 4.0f);
Definition at line 261 of file arena.cc.
References yaze::gfx::Arena::TextureQueueStats::avg_texture_time_ms, yaze::gfx::Arena::TextureQueueStats::frames_with_work, LOG_DEBUG, yaze::gfx::Arena::TextureQueueStats::max_frame_time_ms, ProcessSingleTexture(), renderer_, texture_command_queue_, texture_queue_stats_, yaze::gfx::Arena::TextureQueueStats::textures_processed, and yaze::gfx::Arena::TextureQueueStats::total_time_ms.
Referenced by yaze::Controller::DoRender().

|
inline |
Get texture queue processing statistics.
Definition at line 119 of file arena.h.
References texture_queue_stats_.
|
inline |
Reset texture queue statistics.
Definition at line 126 of file arena.h.
References yaze::gfx::Arena::TextureQueueStats::Reset(), and texture_queue_stats_.

| SDL_Surface * yaze::gfx::Arena::AllocateSurface | ( | int | width, |
| int | height, | ||
| int | depth, | ||
| int | format ) |
Definition at line 327 of file arena.cc.
References yaze::gfx::Arena::SurfacePool::available_surfaces_, yaze::platform::CreateSurface(), yaze::gfx::GetSnesPixelFormat(), yaze::gfx::Arena::SurfacePool::surface_info_, surface_pool_, and surfaces_.
Referenced by yaze::gfx::Bitmap::Bitmap(), yaze::gfx::Bitmap::Create(), yaze::gfx::Bitmap::operator=(), yaze::gfx::Bitmap::Reformat(), and yaze::gfx::Bitmap::Resize().

| void yaze::gfx::Arena::FreeSurface | ( | SDL_Surface * | surface | ) |
Definition at line 357 of file arena.cc.
References yaze::gfx::Arena::SurfacePool::available_surfaces_, yaze::gfx::Arena::SurfacePool::MAX_POOL_SIZE, yaze::gfx::Arena::SurfacePool::surface_info_, surface_pool_, and surfaces_.
Referenced by yaze::gfx::Bitmap::operator=(), and yaze::gfx::Bitmap::operator=().
| void yaze::gfx::Arena::Shutdown | ( | ) |
Definition at line 371 of file arena.cc.
References yaze::gfx::Arena::SurfacePool::available_surfaces_, yaze::gfx::Arena::TexturePool::available_textures_, ClearSheetCache(), ProcessTextureQueue(), renderer_, yaze::gfx::Arena::SurfacePool::surface_info_, surface_pool_, surfaces_, texture_command_queue_, texture_pool_, yaze::gfx::Arena::TexturePool::texture_sizes_, and textures_.
Referenced by yaze::platform::NullWindowBackend::Shutdown(), yaze::platform::SDL2WindowBackend::Shutdown(), yaze::core::ShutdownWindow(), and ~Arena().

|
inline |
|
inline |
|
inline |
Definition at line 137 of file arena.h.
References yaze::gfx::Arena::TexturePool::available_textures_, and texture_pool_.
|
inline |
Definition at line 140 of file arena.h.
References yaze::gfx::Arena::SurfacePool::available_surfaces_, and surface_pool_.
|
inline |
Definition at line 143 of file arena.h.
References texture_command_queue_.
|
inline |
Get reference to all graphics sheets.
Definition at line 152 of file arena.h.
References gfx_sheets_.
Referenced by yaze::editor::PixelEditorPanel::ApplyEyedropper(), yaze::editor::DungeonRoomGraphicsPanel::Draw(), yaze::editor::DungeonObjectSelector::DrawRoomGraphics(), yaze::editor::SheetBrowserPanel::DrawSheetGrid(), yaze::editor::OverworldCanvasRenderer::DrawTile8Selector(), yaze::editor::PixelEditorPanel::EndSelection(), yaze::cli::agent::tools::VisualAnalysisBase::ExtractTileAtPosition(), yaze::editor::PixelEditorPanel::FinalizeUndoAction(), yaze::editor::GraphicsEditor::Load(), yaze::editor::SpriteEditor::LoadSpriteGraphicsBuffer(), yaze::editor::GraphicsEditor::Save(), and yaze::editor::PixelEditorPanel::SaveUndoState().
|
inline |
Get a specific graphics sheet by index.
| i | Sheet index (0-222) |
Definition at line 159 of file arena.h.
References gfx_sheets_.
|
inline |
Get mutable reference to a specific graphics sheet.
| i | Sheet index (0-222) |
Definition at line 169 of file arena.h.
References gfx_sheets_.
|
inline |
Get mutable reference to all graphics sheets.
Definition at line 178 of file arena.h.
References gfx_sheets_.
Referenced by yaze::editor::PixelEditorPanel::ApplyBrush(), yaze::editor::PixelEditorPanel::ApplyEraser(), yaze::editor::PixelEditorPanel::ApplyFill(), yaze::editor::PaletteControlsPanel::ApplyPaletteToAllSheets(), yaze::editor::PaletteControlsPanel::ApplyPaletteToSheet(), yaze::editor::PixelEditorPanel::ApplyPencil(), yaze::editor::GfxGroupEditor::DrawBlocksetViewer(), yaze::editor::PixelEditorPanel::DrawCanvas(), yaze::editor::PixelEditorPanel::DrawColorPicker(), yaze::editor::PixelEditorPanel::DrawLine(), yaze::editor::PixelEditorPanel::DrawMiniMap(), yaze::editor::PixelEditorPanel::DrawRectangle(), yaze::editor::GfxGroupEditor::DrawRoomsetViewer(), yaze::editor::GfxGroupEditor::DrawSpritesetViewer(), yaze::editor::EditorManager::EnsureGameDataLoaded(), yaze::editor::PixelEditorPanel::HandleCanvasInput(), yaze::editor::EditorManager::LoadAssets(), yaze::editor::PixelEditorPanel::PasteSelection(), yaze::editor::GraphicsPixelEditAction::Redo(), and yaze::editor::GraphicsPixelEditAction::Undo().
| void yaze::gfx::Arena::NotifySheetModified | ( | int | sheet_index | ) |
Notify Arena that a graphics sheet has been modified.
| sheet_index | Index of the modified sheet (0-222) |
This ensures textures are updated across all editors
Definition at line 393 of file arena.cc.
References CREATE, gfx_sheets_, LOG_DEBUG, LOG_WARN, QueueTextureCommand(), and UPDATE.
Referenced by yaze::editor::PixelEditorPanel::ApplyBrush(), yaze::editor::PixelEditorPanel::ApplyEraser(), yaze::editor::PixelEditorPanel::ApplyFill(), yaze::editor::PaletteControlsPanel::ApplyPaletteToAllSheets(), yaze::editor::PaletteControlsPanel::ApplyPaletteToSheet(), yaze::editor::PixelEditorPanel::ApplyPencil(), yaze::editor::GfxGroupEditor::DrawBlocksetViewer(), yaze::editor::PixelEditorPanel::DrawLine(), yaze::editor::PixelEditorPanel::DrawRectangle(), yaze::editor::GfxGroupEditor::DrawRoomsetViewer(), yaze::editor::GfxGroupEditor::DrawSpritesetViewer(), yaze::editor::PixelEditorPanel::PasteSelection(), yaze::editor::GraphicsPixelEditAction::Redo(), and yaze::editor::GraphicsPixelEditAction::Undo().

| void yaze::gfx::Arena::NotifyPaletteModified | ( | const std::string & | group_name, |
| int | palette_index = -1 ) |
Notify all listeners that a palette has been modified.
| group_name | The palette group name (e.g., "ow_main", "dungeon_main") |
| palette_index | Specific palette index, or -1 for entire group |
This triggers bitmap refresh in editors using these palettes
Definition at line 423 of file arena.cc.
References LOG_DEBUG, LOG_ERROR, and palette_listeners_.
Referenced by yaze::gfx::PaletteManager::ApplyPreviewChanges(), and yaze::gfx::PaletteManager::SaveGroup().
| int yaze::gfx::Arena::RegisterPaletteListener | ( | PaletteChangeCallback | callback | ) |
Register a callback for palette change notifications.
| callback | Function to call when palettes change |
Definition at line 441 of file arena.cc.
References LOG_DEBUG, next_palette_listener_id_, and palette_listeners_.
Referenced by yaze::editor::OverworldEditor::Load().
| void yaze::gfx::Arena::UnregisterPaletteListener | ( | int | listener_id | ) |
Unregister a palette change listener.
| listener_id | The ID returned from RegisterPaletteListener |
Definition at line 448 of file arena.cc.
References LOG_DEBUG, and palette_listeners_.
Referenced by yaze::editor::OverworldEditor::Clear().
|
inline |
Get reference to background layer 1 buffer.
Definition at line 222 of file arena.h.
References bg1_.
|
inline |
Get reference to background layer 2 buffer.
Definition at line 228 of file arena.h.
References bg2_.
| void yaze::gfx::Arena::TouchSheet | ( | int | sheet_index | ) |
Mark a graphics sheet as recently accessed.
| sheet_index | Index of the sheet being accessed (0-222) |
Call this when a sheet is displayed or its texture is used. This moves the sheet to the front of the LRU list.
Definition at line 458 of file arena.cc.
References sheet_lru_list_, and sheet_lru_map_.
Referenced by GetSheetWithCache().
| Bitmap * yaze::gfx::Arena::GetSheetWithCache | ( | int | sheet_index | ) |
Get a sheet with automatic LRU tracking and texture creation.
| sheet_index | Index of the sheet (0-222) |
This is the preferred way to access sheets when you need their textures. It automatically:
Definition at line 476 of file arena.cc.
References CREATE, yaze::gfx::Arena::SheetCacheStats::current_size, EvictLRUSheets(), gfx_sheets_, yaze::gfx::Arena::SheetCacheStats::hits, yaze::gfx::Arena::SheetCacheStats::misses, QueueTextureCommand(), sheet_cache_max_size_, sheet_cache_stats_, sheet_lru_map_, yaze::gfx::Bitmap::texture(), and TouchSheet().

| void yaze::gfx::Arena::SetSheetCacheSize | ( | size_t | max_size | ) |
Set the maximum number of sheet textures to keep cached.
| max_size | Maximum cache size (default 64, min 16, max 223) |
When more sheets than this have textures, the least recently used textures will be destroyed to free GPU memory.
Definition at line 509 of file arena.cc.
References EvictLRUSheets(), LOG_INFO, sheet_cache_max_size_, and sheet_lru_map_.

|
inline |
Get current sheet cache size limit.
Definition at line 267 of file arena.h.
References sheet_cache_max_size_.
|
inline |
Get number of sheets currently with textures.
Definition at line 273 of file arena.h.
References sheet_lru_map_.
| size_t yaze::gfx::Arena::EvictLRUSheets | ( | size_t | count = 0 | ) |
Evict least recently used sheet textures.
| count | Number of textures to evict (0 = evict until under max) |
Useful for proactive memory management before loading new content.
Definition at line 521 of file arena.cc.
References yaze::gfx::Arena::SheetCacheStats::current_size, DESTROY, yaze::gfx::Arena::SheetCacheStats::evictions, gfx_sheets_, LOG_DEBUG, QueueTextureCommand(), sheet_cache_max_size_, sheet_cache_stats_, sheet_lru_list_, and sheet_lru_map_.
Referenced by GetSheetWithCache(), and SetSheetCacheSize().

| void yaze::gfx::Arena::ClearSheetCache | ( | ) |
Clear all sheet texture cache tracking.
Does NOT destroy textures - use this when manually managing textures or during shutdown.
Definition at line 558 of file arena.cc.
References yaze::gfx::Arena::SheetCacheStats::current_size, LOG_DEBUG, sheet_cache_stats_, sheet_lru_list_, and sheet_lru_map_.
Referenced by Shutdown().
|
inline |
Get sheet cache statistics.
Definition at line 318 of file arena.h.
References sheet_cache_stats_.
|
inline |
Reset sheet cache statistics.
Definition at line 325 of file arena.h.
References yaze::gfx::Arena::SheetCacheStats::Reset(), and sheet_cache_stats_.

|
private |
|
private |
|
staticconstexprprivate |
|
staticconstexprprivate |
|
staticconstexprprivate |
|
private |
|
private |
|
private |
Definition at line 340 of file arena.h.
Referenced by EvictLRUSheets(), GetSheetWithCache(), gfx_sheet(), gfx_sheets(), mutable_gfx_sheet(), mutable_gfx_sheets(), and NotifySheetModified().
|
private |
Definition at line 344 of file arena.h.
Referenced by GetTextureCount(), and Shutdown().
|
private |
Definition at line 348 of file arena.h.
Referenced by AllocateSurface(), FreeSurface(), GetSurfaceCount(), and Shutdown().
|
private |
Referenced by GetPooledTextureCount(), and Shutdown().
|
private |
Referenced by AllocateSurface(), FreeSurface(), GetPooledSurfaceCount(), and Shutdown().
|
private |
Definition at line 364 of file arena.h.
Referenced by ClearTextureQueue(), HasPendingTextures(), ProcessSingleTexture(), ProcessTextureQueue(), ProcessTextureQueueWithBudget(), QueueTextureCommand(), Shutdown(), and texture_command_queue_size().
|
private |
Definition at line 365 of file arena.h.
Referenced by Initialize(), ProcessSingleTexture(), ProcessTextureQueue(), ProcessTextureQueueWithBudget(), and Shutdown().
|
private |
Definition at line 366 of file arena.h.
Referenced by GetTextureQueueStats(), ProcessTextureQueueWithBudget(), and ResetTextureQueueStats().
|
private |
Definition at line 369 of file arena.h.
Referenced by NotifyPaletteModified(), RegisterPaletteListener(), and UnregisterPaletteListener().
|
private |
Definition at line 370 of file arena.h.
Referenced by RegisterPaletteListener().
|
private |
Definition at line 374 of file arena.h.
Referenced by ClearSheetCache(), EvictLRUSheets(), and TouchSheet().
|
private |
Definition at line 376 of file arena.h.
Referenced by ClearSheetCache(), EvictLRUSheets(), GetCachedSheetCount(), GetSheetWithCache(), SetSheetCacheSize(), and TouchSheet().
|
private |
Definition at line 377 of file arena.h.
Referenced by EvictLRUSheets(), GetSheetCacheSize(), GetSheetWithCache(), and SetSheetCacheSize().
|
private |
Definition at line 378 of file arena.h.
Referenced by ClearSheetCache(), EvictLRUSheets(), GetSheetCacheStats(), GetSheetWithCache(), and ResetSheetCacheStats().