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 | GraphicsSheets = std::array<gfx::Bitmap, 223> |
| Get reference to all graphics sheets. | |
| using | PaletteChangeCallback |
Public Member Functions | |
| void | Initialize (IRenderer *renderer) |
| ~Arena () | |
| void | QueueTextureCommand (TextureCommandType type, Bitmap *bitmap) |
| bool | HasPendingTextureCommand (TextureCommandType type, const Bitmap *bitmap) const |
| void | ProcessTextureQueue (IRenderer *renderer) |
| void | ClearTextureQueue () |
| void | RetireBitmap (Bitmap &bitmap) |
| Explicitly retire resources owned by a bitmap that is being erased. | |
| size_t | DrainRetiredBitmaps (IRenderer *renderer) |
| Destroy texture handles retired earlier in the frame. | |
| 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 |
| size_t | retired_texture_handle_count () const |
| GraphicsSheets & | gfx_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 | BindGraphicsSheets (GraphicsSheets *sheets, const void *owner) |
| void | set_gfx_sheets_owner (const void *owner) |
| const void * | gfx_sheets_owner () const |
| 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 () | |
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:
| using yaze::gfx::Arena::GraphicsSheets = std::array<gfx::Bitmap, 223> |
|
strong |
| yaze::gfx::Arena::~Arena | ( | ) |
Definition at line 34 of file arena.cc.
References Shutdown().

|
private |
Definition at line 29 of file arena.cc.
References layer1_buffer_, and layer2_buffer_.
|
static |
Definition at line 24 of file arena.cc.
Referenced by yaze::editor::RomSession::ActivateGraphicsDisplay(), yaze::editor::ActiveSheetStore(), yaze::editor::Tile16EditSession::ApplyDefinitions(), yaze::editor::PixelEditorPanel::ApplyEyedropper(), yaze::editor::MessageEditor::ApplyFontPalette(), yaze::gui::CanvasUtils::ApplyPaletteGroup(), yaze::editor::Tile16EditSession::ApplyPaletteToCurrentTile16Bitmap(), 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::anonymous_namespace{palette_controls_panel.cc}::CanPreview(), yaze::editor::CanvasNavigationManager::CheckForCurrentMap(), yaze::editor::PixelEditorPanel::ClampFloatingPaste(), yaze::editor::OverworldEditor::Clear(), yaze::editor::RoomGraphicsContent::ClearPickerPreviews(), yaze::editor::ObjectTileEditorPanel::ClearRenderedBitmaps(), yaze::editor::OverworldEditor::ClearScratchSpace(), yaze::test::TestManager::CollectResourceStats(), yaze::editor::Tile16EditSession::CommitChangesToBlockset(), yaze::editor::Tile16EditSession::CopyTile16ToAtlas(), yaze::editor::Tile16EditSession::CopyTile16ToClipboard(), yaze::editor::PixelEditorPanel::CopyToSystemClipboard(), 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::editor::PixelEditorPanel::DisplayPalette(), yaze::editor::PixelEditorPanel::DisplaySheet(), yaze::Controller::DoRender(), yaze::editor::DungeonMapPanel::Draw(), yaze::editor::RoomGraphicsContent::Draw(), yaze::editor::RoomMatrixContent::Draw(), yaze::editor::OverworldCanvasRenderer::DrawAreaGraphics(), yaze::gui::DrawBitmap(), yaze::gui::DrawBitmapPreview(), yaze::editor::PixelEditorPanel::DrawCanvas(), yaze::editor::GraphicsEditor::DrawCgxImport(), yaze::editor::DungeonCanvasViewer::DrawConnectedRoomMatrix(), yaze::editor::SpriteEditor::DrawCurrentSheets(), yaze::editor::ScreenEditor::DrawDungeonMapScreen(), yaze::editor::ScreenEditor::DrawDungeonMapsRoomGfx(), yaze::editor::DungeonRoomSelector::DrawGroupedRoomList(), yaze::editor::MessageEditor::DrawMessagePreview(), yaze::editor::MenuTilemapEditorUI::DrawOverlayControls(), yaze::editor::ScreenEditor::DrawOverworldMapEditor(), yaze::editor::SheetBrowserPanel::DrawPngTransfer(), yaze::editor::DungeonCanvasViewer::DrawProposalPreview(), yaze::editor::DungeonCanvasViewer::DrawRoomBackgroundLayers(), yaze::editor::DungeonRoomSelector::DrawRoomSelectorInternal(), yaze::editor::OverworldEditor::DrawScratchSpace(), yaze::editor::GraphicsEditor::DrawScrImport(), yaze::editor::SheetBrowserPanel::DrawSheetGrid(), yaze::editor::LinkSpritePanel::DrawSheetThumbnail(), yaze::editor::DungeonCanvasViewer::DrawTextureDebugWindow(), yaze::editor::Tile16Editor::DrawTile16EditorWorkbenchColumn(), yaze::editor::OverworldCanvasRenderer::DrawTile8Selector(), yaze::editor::ScreenEditor::DrawTitleScreenBG1Canvas(), yaze::editor::ScreenEditor::DrawTitleScreenBG2Canvas(), yaze::editor::ScreenEditor::DrawTitleScreenCompositeCanvas(), yaze::editor::ScreenEditor::DrawTitleScreenEditor(), yaze::editor::Tile16EditSession::DrawToCurrentTile16Impl(), yaze::editor::PixelEditorPanel::EndSelection(), yaze::gfx::EnsureCompositeBitmapTextureQueued(), yaze::editor::MessageEditor::EnsureFontTexturesReady(), yaze::editor::OverworldMapTextureCoordinator::EnsureMapTexture(), yaze::editor::OverworldCanvasRenderer::EnsureOverlayLayer(), yaze::editor::internal::EnsureSheetTextureQueued(), yaze::cli::agent::tools::VisualAnalysisBase::ExtractTileAtPosition(), getArenaStatus(), getGfxSheetInfo(), yaze::editor::DungeonObjectSelector::GetOrCreatePreview(), yaze::editor::PixelEditorPanel::HandleCanvasInput(), yaze::cli::HandleGfxExportLegacy(), yaze::cli::HandleGfxImportLegacy(), yaze::editor::EditorManager::HandleSessionSwitched(), yaze::editor::Tile16EditSession::InitializeBitmaps(), yaze::editor::GraphicsEditor::Load(), yaze::editor::ScreenEditor::Load(), yaze::editor::OverworldEditor::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::Tile16EditSession::LoadTile16FromScratchSpaceImpl(), yaze::zelda3::TitleScreen::LoadTitleScreen(), yaze::gfx::PaletteManager::NotifyListeners(), yaze::Controller::OnEntry(), yaze::Controller::OnExit(), yaze::gfx::Bitmap::operator=(), yaze::gfx::Bitmap::operator=(), yaze::editor::TilePaintingManager::PaintPattern(), yaze::editor::PixelEditorPanel::PasteFromSystemClipboard(), yaze::editor::Tile16EditSession::PasteTile16FromClipboardImpl(), yaze::editor::GraphicsEditor::PlanGraphicsSave(), yaze::editor::GraphicsEditor::PrepareGraphicsSave(), yaze::editor::DungeonCanvasViewer::PrepareRoomStateForCanvas(), yaze::editor::Tile16EditSession::PreviewPaletteChange(), yaze::editor::DungeonEditorV2::ProcessDeferredTextures(), yaze::editor::OverworldMapTextureCoordinator::ProcessDeferredTextures(), yaze::editor::anonymous_namespace{usage_preview_view.cc}::QueueTexture(), yaze::editor::MenuTilemapEditorUI::RebuildRenderTextures(), yaze::editor::OverworldEditor::RebuildScratchBitmapFromTileData(), yaze::gfx::Bitmap::Reformat(), yaze::editor::Tile16EditSession::RefreshAllPalettes(), yaze::editor::RefreshArenaSheet(), yaze::editor::MapRefreshCoordinator::RefreshChildMapOnDemand(), yaze::editor::ScreenEditor::RefreshDungeonMapGraphicsFromSession(), yaze::editor::MessageEditor::RefreshFontAtlasBitmap(), yaze::editor::MapRefreshCoordinator::RefreshMultiAreaMapsSafely(), yaze::editor::MapRefreshCoordinator::RefreshPaletteUsers(), yaze::editor::RoomGraphicsContent::RefreshSheetPreviews(), yaze::editor::MapRefreshCoordinator::RefreshTile16Blockset(), yaze::editor::Tile16EditSession::RefreshTile16Blockset(), yaze::editor::ScreenEditor::RefreshTileCacheForReload(), yaze::editor::Tile16EditSession::RegenerateTile16BitmapFromROM(), yaze::editor::DungeonEditorV2::RegisterPaletteListener(), yaze::zelda3::TitleScreen::RenderBG1Layer(), yaze::zelda3::TitleScreen::RenderBG2Layer(), yaze::gui::CanvasContextMenu::RenderBitmapOperationsMenu(), yaze::zelda3::TitleScreen::RenderCompositeLayer(), yaze::editor::TileObjectHandler::RenderGhostPreviewBitmap(), yaze::editor::ObjectTileEditorPanel::RenderObjectPreview(), yaze::gui::RenderPreviewPanel(), yaze::zelda3::Room::RenderRoomGraphics(), yaze::editor::ObjectTileEditorPanel::RenderTile8Atlas(), yaze::gfx::RenderTilesBatch(), yaze::editor::TilePaintingManager::RenderUpdatedMapBitmap(), yaze::editor::RomSession::ResetGraphicsDisplay(), yaze::editor::GfxGroupEditor::ResetSheetPicker(), yaze::gfx::Bitmap::Resize(), yaze::editor::RoomCompositeOutput::Retire(), yaze::editor::DungeonObjectSelector::RetirePreviewCache(), 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::Tile16EditSession::SaveTile16ToScratchSpace(), yaze::editor::SetGraphicsPreviewPalette(), yaze::platform::NullWindowBackend::Shutdown(), yaze::platform::SDL2WindowBackend::Shutdown(), yaze::core::ShutdownWindow(), yaze::editor::usage_preview::SnapshotArenaSheets(), yaze::editor::anonymous_namespace{map_refresh_coordinator.cc}::SyncCurrentGraphicsBitmapForTile16Editor(), yaze::editor::Tile16EditSession::UpdateBlocksetBitmap(), yaze::editor::MapRefreshCoordinator::UpdateBlocksetWithPendingTileChanges(), yaze::editor::Tile16EditSession::UpdateLivePreview(), yaze::editor::OverworldEditor::UpdateScratchBitmapTile(), yaze::gfx::Bitmap::UpdateTexture(), yaze::gfx::UpdateTile16(), yaze::editor::Tile16EditSession::UpdateTile8Palette(), yaze::gfx::UpdateTilemap(), yaze::editor::EditorManager::WantsContinuousFrames(), yaze::editor::DungeonEditorV2::~DungeonEditorV2(), yaze::editor::GfxGroupEditor::~GfxGroupEditor(), yaze::editor::OverworldEditor::~OverworldEditor(), yaze::editor::RoomCompositeOutput::~RoomCompositeOutput(), and yaze::editor::RoomGraphicsContent::~RoomGraphicsContent().
| void yaze::gfx::Arena::Initialize | ( | IRenderer * | renderer | ) |
Definition at line 17 of file arena.cc.
References is_shutdown_, and renderer_.
Referenced by yaze::Controller::OnEntry(), and yaze::Controller::OnExit().
| void yaze::gfx::Arena::QueueTextureCommand | ( | TextureCommandType | type, |
| Bitmap * | bitmap ) |
Definition at line 39 of file arena.cc.
References yaze::gfx::Bitmap::generation(), and texture_command_queue_.
Referenced by yaze::editor::Tile16EditSession::ApplyDefinitions(), yaze::editor::MessageEditor::ApplyFontPalette(), yaze::gui::CanvasUtils::ApplyPaletteGroup(), yaze::editor::Tile16EditSession::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::Tile16EditSession::CommitChangesToBlockset(), yaze::editor::Tile16EditSession::CopyTile16ToAtlas(), yaze::editor::Tile16EditSession::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::PixelEditorPanel::DisplaySheet(), 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::MenuTilemapEditorUI::DrawOverlayControls(), yaze::editor::ScreenEditor::DrawOverworldMapEditor(), yaze::editor::OverworldEditor::DrawScratchSpace(), yaze::editor::GraphicsEditor::DrawScrImport(), yaze::editor::LinkSpritePanel::DrawSheetThumbnail(), yaze::editor::DungeonCanvasViewer::DrawTextureDebugWindow(), yaze::editor::Tile16Editor::DrawTile16EditorWorkbenchColumn(), yaze::editor::ScreenEditor::DrawTitleScreenBG1Canvas(), yaze::editor::ScreenEditor::DrawTitleScreenBG2Canvas(), yaze::editor::ScreenEditor::DrawTitleScreenCompositeCanvas(), yaze::editor::ScreenEditor::DrawTitleScreenEditor(), yaze::editor::Tile16EditSession::DrawToCurrentTile16Impl(), yaze::gfx::EnsureCompositeBitmapTextureQueued(), yaze::editor::MessageEditor::EnsureFontTexturesReady(), yaze::editor::OverworldMapTextureCoordinator::EnsureMapTexture(), yaze::editor::OverworldCanvasRenderer::EnsureOverlayLayer(), yaze::editor::internal::EnsureSheetTextureQueued(), EvictLRUSheets(), yaze::editor::DungeonObjectSelector::GetOrCreatePreview(), GetSheetWithCache(), yaze::editor::Tile16EditSession::InitializeBitmaps(), 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::Tile16EditSession::LoadTile16FromScratchSpaceImpl(), yaze::zelda3::TitleScreen::LoadTitleScreen(), NotifySheetModified(), yaze::gfx::Bitmap::operator=(), yaze::editor::TilePaintingManager::PaintPattern(), yaze::editor::Tile16EditSession::PasteTile16FromClipboardImpl(), yaze::editor::Tile16EditSession::PreviewPaletteChange(), yaze::editor::anonymous_namespace{usage_preview_view.cc}::QueueTexture(), yaze::editor::MenuTilemapEditorUI::RebuildRenderTextures(), yaze::editor::OverworldEditor::RebuildScratchBitmapFromTileData(), yaze::editor::Tile16EditSession::RefreshAllPalettes(), yaze::editor::MapRefreshCoordinator::RefreshChildMapOnDemand(), yaze::editor::ScreenEditor::RefreshDungeonMapGraphicsFromSession(), yaze::editor::MessageEditor::RefreshFontAtlasBitmap(), yaze::editor::MapRefreshCoordinator::RefreshMultiAreaMapsSafely(), yaze::editor::MapRefreshCoordinator::RefreshPaletteUsers(), yaze::editor::MapRefreshCoordinator::RefreshTile16Blockset(), yaze::editor::Tile16EditSession::RefreshTile16Blockset(), yaze::editor::ScreenEditor::RefreshTileCacheForReload(), yaze::editor::Tile16EditSession::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::OverworldEditor::SaveCurrentSelectionToScratch(), yaze::editor::Tile16EditSession::SaveTile16ToScratchSpace(), yaze::editor::anonymous_namespace{map_refresh_coordinator.cc}::SyncCurrentGraphicsBitmapForTile16Editor(), yaze::editor::Tile16EditSession::UpdateBlocksetBitmap(), yaze::editor::MapRefreshCoordinator::UpdateBlocksetWithPendingTileChanges(), yaze::editor::Tile16EditSession::UpdateLivePreview(), yaze::editor::OverworldEditor::UpdateScratchBitmapTile(), yaze::gfx::Bitmap::UpdateTexture(), yaze::gfx::UpdateTile16(), yaze::editor::Tile16EditSession::UpdateTile8Palette(), and yaze::gfx::UpdateTilemap().

| bool yaze::gfx::Arena::HasPendingTextureCommand | ( | TextureCommandType | type, |
| const Bitmap * | bitmap ) const |
Definition at line 45 of file arena.cc.
References yaze::gfx::Bitmap::generation(), and texture_command_queue_.
Referenced by yaze::gfx::EnsureCompositeBitmapTextureQueued().

| void yaze::gfx::Arena::ProcessTextureQueue | ( | IRenderer * | renderer | ) |
Definition at line 211 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::DungeonMapPanel::Draw(), yaze::editor::RoomGraphicsContent::Draw(), yaze::editor::RoomMatrixContent::Draw(), yaze::editor::DungeonCanvasViewer::DrawConnectedRoomMatrix(), yaze::editor::DungeonRoomSelector::DrawGroupedRoomList(), yaze::editor::DungeonCanvasViewer::DrawProposalPreview(), yaze::editor::DungeonCanvasViewer::DrawRoomBackgroundLayers(), yaze::editor::DungeonRoomSelector::DrawRoomSelectorInternal(), yaze::editor::DungeonCanvasViewer::DrawTextureDebugWindow(), yaze::editor::DungeonObjectSelector::GetOrCreatePreview(), yaze::editor::DungeonCanvasViewer::PrepareRoomStateForCanvas(), yaze::editor::DungeonEditorV2::ProcessDeferredTextures(), yaze::editor::OverworldMapTextureCoordinator::ProcessDeferredTextures(), yaze::editor::TileObjectHandler::RenderGhostPreviewBitmap(), and Shutdown().
| void yaze::gfx::Arena::ClearTextureQueue | ( | ) |
Definition at line 59 of file arena.cc.
References texture_command_queue_.
| void yaze::gfx::Arena::RetireBitmap | ( | Bitmap & | bitmap | ) |
Explicitly retire resources owned by a bitmap that is being erased.
Cancels every deferred command that still references the Bitmap address, returns its SDL surface to the Arena, and moves its opaque texture handle to a pointer-free queue. The handle is intentionally not destroyed here: ImGui draw data for the current frame may still reference it.
Definition at line 63 of file arena.cc.
References yaze::gfx::Arena::TextureCommand::bitmap, yaze::gfx::Bitmap::DetachSurfaceForArena(), yaze::gfx::Bitmap::DetachTextureForArena(), FreeSurface(), is_shutdown_, yaze::gfx::Bitmap::MarkRetiredByArena(), retired_texture_handles_, surfaces_, yaze::gfx::Bitmap::texture(), and texture_command_queue_.
Referenced by yaze::editor::RoomGraphicsContent::ClearPickerPreviews(), yaze::editor::ObjectTileEditorPanel::ClearRenderedBitmaps(), yaze::editor::DungeonObjectSelector::GetOrCreatePreview(), yaze::editor::RoomGraphicsContent::RefreshSheetPreviews(), yaze::editor::ObjectTileEditorPanel::RenderObjectPreview(), yaze::editor::ObjectTileEditorPanel::RenderTile8Atlas(), yaze::editor::GfxGroupEditor::ResetSheetPicker(), yaze::editor::RoomCompositeOutput::Retire(), yaze::editor::GfxGroupEditor::~GfxGroupEditor(), yaze::editor::RoomCompositeOutput::~RoomCompositeOutput(), and yaze::editor::RoomGraphicsContent::~RoomGraphicsContent().
| size_t yaze::gfx::Arena::DrainRetiredBitmaps | ( | IRenderer * | renderer | ) |
Destroy texture handles retired earlier in the frame.
Call only after ImGui rendering/Present has completed, or immediately before renderer shutdown. Failed destroys remain queued for a later call.
Definition at line 91 of file arena.cc.
References yaze::gfx::IRenderer::DestroyTexture(), LOG_ERROR, renderer_, and retired_texture_handles_.
Referenced by yaze::Controller::DoRender(), yaze::Controller::OnExit(), and Shutdown().

|
inline |
Check if there are pending textures to process.
Definition at line 92 of file arena.h.
References texture_command_queue_.
Referenced by yaze::editor::EditorManager::WantsContinuousFrames().
| 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 112 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 372 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 141 of file arena.h.
References texture_queue_stats_.
|
inline |
Reset texture queue statistics.
Definition at line 148 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 443 of file arena.cc.
References yaze::gfx::Arena::SurfacePool::available_surfaces_, yaze::platform::CreateSurface(), 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 475 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::Create(), yaze::gfx::Bitmap::operator=(), yaze::gfx::Bitmap::operator=(), and RetireBitmap().
| void yaze::gfx::Arena::Shutdown | ( | ) |
Definition at line 489 of file arena.cc.
References yaze::gfx::Arena::SurfacePool::available_surfaces_, yaze::gfx::Arena::TexturePool::available_textures_, ClearSheetCache(), DrainRetiredBitmaps(), is_shutdown_, ProcessTextureQueue(), renderer_, retired_texture_handles_, 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 159 of file arena.h.
References yaze::gfx::Arena::TexturePool::available_textures_, and texture_pool_.
|
inline |
Definition at line 162 of file arena.h.
References yaze::gfx::Arena::SurfacePool::available_surfaces_, and surface_pool_.
|
inline |
Definition at line 165 of file arena.h.
References texture_command_queue_.
|
inline |
Definition at line 168 of file arena.h.
References retired_texture_handles_.
|
inline |
Definition at line 178 of file arena.h.
References active_gfx_sheets_.
Referenced by yaze::editor::PixelEditorPanel::ApplyEyedropper(), yaze::editor::PixelEditorPanel::ClampFloatingPaste(), yaze::editor::PixelEditorPanel::CopyToSystemClipboard(), yaze::editor::PixelEditorPanel::DisplayPalette(), yaze::editor::PixelEditorPanel::DrawCanvas(), yaze::editor::SpriteEditor::DrawCurrentSheets(), yaze::editor::SheetBrowserPanel::DrawPngTransfer(), yaze::editor::SheetBrowserPanel::DrawSheetGrid(), yaze::editor::OverworldCanvasRenderer::DrawTile8Selector(), yaze::editor::PixelEditorPanel::EndSelection(), EvictLRUSheets(), yaze::cli::agent::tools::VisualAnalysisBase::ExtractTileAtPosition(), GetSheetWithCache(), gfx_sheet(), yaze::editor::GraphicsEditor::Load(), mutable_gfx_sheet(), NotifySheetModified(), yaze::editor::PixelEditorPanel::PasteFromSystemClipboard(), yaze::editor::GraphicsEditor::PlanGraphicsSave(), yaze::editor::GraphicsEditor::PrepareGraphicsSave(), and yaze::editor::GraphicsEditor::Save().
|
inline |
Get a specific graphics sheet by index.
| i | Sheet index (0-222) |
Definition at line 185 of file arena.h.
References gfx_sheets().

|
inline |
Get mutable reference to a specific graphics sheet.
| i | Sheet index (0-222) |
Definition at line 196 of file arena.h.
References gfx_sheets().

|
inline |
Get mutable reference to all graphics sheets.
Definition at line 206 of file arena.h.
References active_gfx_sheets_.
Referenced by yaze::editor::PixelEditorPanel::DisplaySheet(), yaze::editor::PixelEditorPanel::HandleCanvasInput(), and yaze::editor::RefreshArenaSheet().
| void yaze::gfx::Arena::BindGraphicsSheets | ( | GraphicsSheets * | sheets, |
| const void * | owner ) |
Definition at line 522 of file arena.cc.
References active_gfx_sheets_, ClearSheetCache(), gfx_sheets_, and gfx_sheets_owner_.
Referenced by yaze::editor::RomSession::ActivateGraphicsDisplay(), and yaze::editor::EditorManager::HandleSessionSwitched().

|
inline |
Definition at line 215 of file arena.h.
References gfx_sheets_owner_.
|
inline |
Definition at line 216 of file arena.h.
References gfx_sheets_owner_.
Referenced by yaze::editor::ActiveSheetStore(), yaze::editor::anonymous_namespace{palette_controls_panel.cc}::CanPreview(), and yaze::editor::SheetBrowserPanel::DrawPngTransfer().
| 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 532 of file arena.cc.
References CREATE, gfx_sheets(), LOG_DEBUG, LOG_WARN, QueueTextureCommand(), and UPDATE.
Referenced by yaze::editor::RefreshArenaSheet().

| 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 562 of file arena.cc.
References LOG_DEBUG, LOG_ERROR, and palette_listeners_.
Referenced by yaze::gfx::PaletteManager::ApplyPreviewChanges(), yaze::gfx::PaletteManager::NotifyListeners(), 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 580 of file arena.cc.
References LOG_DEBUG, next_palette_listener_id_, and palette_listeners_.
Referenced by yaze::editor::OverworldEditor::Load(), and yaze::editor::DungeonEditorV2::RegisterPaletteListener().
| void yaze::gfx::Arena::UnregisterPaletteListener | ( | int | listener_id | ) |
Unregister a palette change listener.
| listener_id | The ID returned from RegisterPaletteListener |
Definition at line 587 of file arena.cc.
References LOG_DEBUG, and palette_listeners_.
Referenced by yaze::editor::OverworldEditor::Clear(), yaze::editor::DungeonEditorV2::~DungeonEditorV2(), and yaze::editor::OverworldEditor::~OverworldEditor().
|
inline |
Get reference to background layer 1 buffer.
Definition at line 260 of file arena.h.
References bg1_.
|
inline |
Get reference to background layer 2 buffer.
Definition at line 266 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 597 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 615 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 648 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 305 of file arena.h.
References sheet_cache_max_size_.
|
inline |
Get number of sheets currently with textures.
Definition at line 311 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 660 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 697 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 BindGraphicsSheets(), and Shutdown().
|
inline |
Get sheet cache statistics.
Definition at line 356 of file arena.h.
References sheet_cache_stats_.
|
inline |
Reset sheet cache statistics.
Definition at line 363 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 378 of file arena.h.
Referenced by BindGraphicsSheets().
|
private |
Definition at line 379 of file arena.h.
Referenced by BindGraphicsSheets(), gfx_sheets(), and mutable_gfx_sheets().
|
private |
Definition at line 380 of file arena.h.
Referenced by BindGraphicsSheets(), gfx_sheets_owner(), and set_gfx_sheets_owner().
|
private |
Definition at line 384 of file arena.h.
Referenced by GetTextureCount(), and Shutdown().
|
private |
Definition at line 388 of file arena.h.
Referenced by AllocateSurface(), FreeSurface(), GetSurfaceCount(), RetireBitmap(), and Shutdown().
|
private |
Referenced by GetPooledTextureCount(), and Shutdown().
|
private |
Referenced by AllocateSurface(), FreeSurface(), GetPooledSurfaceCount(), and Shutdown().
|
private |
Definition at line 404 of file arena.h.
Referenced by ClearTextureQueue(), HasPendingTextureCommand(), HasPendingTextures(), ProcessSingleTexture(), ProcessTextureQueue(), ProcessTextureQueueWithBudget(), QueueTextureCommand(), RetireBitmap(), Shutdown(), and texture_command_queue_size().
|
private |
Definition at line 405 of file arena.h.
Referenced by DrainRetiredBitmaps(), RetireBitmap(), retired_texture_handle_count(), and Shutdown().
|
private |
Definition at line 406 of file arena.h.
Referenced by DrainRetiredBitmaps(), Initialize(), ProcessSingleTexture(), ProcessTextureQueue(), ProcessTextureQueueWithBudget(), and Shutdown().
|
private |
Definition at line 407 of file arena.h.
Referenced by Initialize(), RetireBitmap(), and Shutdown().
|
private |
Definition at line 408 of file arena.h.
Referenced by GetTextureQueueStats(), ProcessTextureQueueWithBudget(), and ResetTextureQueueStats().
|
private |
Definition at line 411 of file arena.h.
Referenced by NotifyPaletteModified(), RegisterPaletteListener(), and UnregisterPaletteListener().
|
private |
Definition at line 412 of file arena.h.
Referenced by RegisterPaletteListener().
|
private |
Definition at line 416 of file arena.h.
Referenced by ClearSheetCache(), EvictLRUSheets(), and TouchSheet().
|
private |
Definition at line 418 of file arena.h.
Referenced by ClearSheetCache(), EvictLRUSheets(), GetCachedSheetCount(), GetSheetWithCache(), SetSheetCacheSize(), and TouchSheet().
|
private |
Definition at line 419 of file arena.h.
Referenced by EvictLRUSheets(), GetSheetCacheSize(), GetSheetWithCache(), and SetSheetCacheSize().
|
private |
Definition at line 420 of file arena.h.
Referenced by ClearSheetCache(), EvictLRUSheets(), GetSheetCacheStats(), GetSheetWithCache(), and ResetSheetCacheStats().