Atlas-based rendering system for efficient graphics operations. More...
#include <atlas_renderer.h>

Classes | |
| struct | Atlas |
| struct | AtlasEntry |
Public Member Functions | |
| void | Initialize (IRenderer *renderer, int initial_size=1024) |
| Initialize the atlas renderer. | |
| int | AddBitmap (const Bitmap &bitmap) |
| Add a bitmap to the atlas. | |
| int | AddBitmapWithBppOptimization (const Bitmap &bitmap, BppFormat target_bpp) |
| Add a bitmap to the atlas with BPP format optimization. | |
| void | RemoveBitmap (int atlas_id) |
| Remove a bitmap from the atlas. | |
| void | UpdateBitmap (int atlas_id, const Bitmap &bitmap) |
| Update a bitmap in the atlas. | |
| void | RenderBatch (const std::vector< RenderCommand > &render_commands) |
| Render multiple bitmaps in a single draw call. | |
| void | RenderBatchWithBppOptimization (const std::vector< RenderCommand > &render_commands, const std::unordered_map< BppFormat, std::vector< int > > &bpp_groups) |
| Render multiple bitmaps with BPP-aware batching. | |
| AtlasStats | GetStats () const |
| Get atlas statistics. | |
| void | Defragment () |
| Defragment the atlas to reclaim space. | |
| void | Clear () |
| Clear all atlases. | |
| void | RenderBitmap (int atlas_id, float x, float y, float scale_x=1.0f, float scale_y=1.0f) |
| Render a single bitmap using atlas (convenience method) | |
| SDL_Rect | GetUVCoordinates (int atlas_id) const |
| Get UV coordinates for a bitmap in the atlas. | |
Static Public Member Functions | |
| static AtlasRenderer & | Get () |
Private Member Functions | |
| AtlasRenderer ()=default | |
| ~AtlasRenderer () | |
| bool | PackBitmap (Atlas &atlas, const Bitmap &bitmap, SDL_Rect &uv_rect) |
| void | CreateNewAtlas () |
| void | RebuildAtlas (Atlas &atlas) |
| SDL_Rect | FindFreeRegion (Atlas &atlas, int width, int height) |
| void | MarkRegionUsed (Atlas &atlas, const SDL_Rect &rect, bool used) |
Private Attributes | |
| IRenderer * | renderer_ |
| std::vector< std::unique_ptr< Atlas > > | atlases_ |
| std::unordered_map< int, AtlasEntry * > | atlas_lookup_ |
| int | next_atlas_id_ |
| int | current_atlas_ |
Atlas-based rendering system for efficient graphics operations.
The AtlasRenderer class provides efficient rendering by combining multiple graphics elements into a single texture atlas, reducing draw calls and improving performance for ROM hacking workflows.
Key Features:
Performance Optimizations:
ROM Hacking Specific:
Definition at line 74 of file atlas_renderer.h.
|
privatedefault |
|
private |
Definition at line 314 of file atlas_renderer.cc.
References Clear().

|
static |
Definition at line 10 of file atlas_renderer.cc.
Referenced by yaze::gfx::PerformanceDashboard::RenderMemoryUsage(), yaze::gfx::RenderTilesBatch(), yaze::gfx::TEST_F(), and yaze::gfx::TEST_F().
| void yaze::gfx::AtlasRenderer::Initialize | ( | IRenderer * | renderer, |
| int | initial_size = 1024 |
||
| ) |
Initialize the atlas renderer.
| renderer | The renderer to use for texture operations |
| initial_size | Initial atlas size (power of 2 recommended) |
Definition at line 15 of file atlas_renderer.cc.
References Clear(), CreateNewAtlas(), current_atlas_, next_atlas_id_, and renderer_.

| int yaze::gfx::AtlasRenderer::AddBitmap | ( | const Bitmap & | bitmap | ) |
Add a bitmap to the atlas.
| bitmap | Bitmap to add to atlas |
Definition at line 27 of file atlas_renderer.cc.
References atlas_lookup_, atlases_, CreateNewAtlas(), current_atlas_, yaze::gfx::BppFormatManager::DetectFormat(), yaze::gfx::BppFormatManager::Get(), yaze::gfx::Bitmap::height(), yaze::gfx::Bitmap::is_active(), next_atlas_id_, PackBitmap(), yaze::gfx::IRenderer::RenderCopy(), renderer_, yaze::gfx::IRenderer::SetRenderTarget(), yaze::gfx::Bitmap::texture(), yaze::gfx::Bitmap::vector(), and yaze::gfx::Bitmap::width().
Referenced by AddBitmapWithBppOptimization(), and UpdateBitmap().
| int yaze::gfx::AtlasRenderer::AddBitmapWithBppOptimization | ( | const Bitmap & | bitmap, |
| BppFormat | target_bpp | ||
| ) |
Add a bitmap to the atlas with BPP format optimization.
| bitmap | Bitmap to add to atlas |
| target_bpp | Target BPP format for optimization |
Definition at line 69 of file atlas_renderer.cc.
References AddBitmap(), yaze::gfx::BppFormatManager::ConvertFormat(), yaze::gfx::Bitmap::CreateTexture(), yaze::gfx::Bitmap::depth(), yaze::gfx::BppFormatManager::DetectFormat(), yaze::gfx::BppFormatManager::Get(), yaze::gfx::Bitmap::height(), yaze::gfx::Bitmap::is_active(), yaze::gfx::Bitmap::palette(), yaze::gfx::Bitmap::texture(), yaze::gfx::Bitmap::vector(), and yaze::gfx::Bitmap::width().
| void yaze::gfx::AtlasRenderer::RemoveBitmap | ( | int | atlas_id | ) |
Remove a bitmap from the atlas.
| atlas_id | Atlas ID of bitmap to remove |
Definition at line 96 of file atlas_renderer.cc.
References atlas_lookup_, atlases_, yaze::gfx::AtlasRenderer::AtlasEntry::in_use, and MarkRegionUsed().
Referenced by UpdateBitmap().

| void yaze::gfx::AtlasRenderer::UpdateBitmap | ( | int | atlas_id, |
| const Bitmap & | bitmap | ||
| ) |
Update a bitmap in the atlas.
| atlas_id | Atlas ID of bitmap to update |
| bitmap | New bitmap data |
Definition at line 118 of file atlas_renderer.cc.
References AddBitmap(), atlas_lookup_, yaze::gfx::Bitmap::height(), RemoveBitmap(), yaze::gfx::Bitmap::texture(), yaze::gfx::AtlasRenderer::AtlasEntry::texture, yaze::gfx::AtlasRenderer::AtlasEntry::uv_rect, and yaze::gfx::Bitmap::width().
| void yaze::gfx::AtlasRenderer::RenderBatch | ( | const std::vector< RenderCommand > & | render_commands | ) |
Render multiple bitmaps in a single draw call.
| render_commands | Vector of render commands (atlas_id, x, y, scale) |
Definition at line 135 of file atlas_renderer.cc.
References atlas_lookup_, atlases_, yaze::gfx::IRenderer::RenderCopy(), renderer_, and yaze::gfx::AtlasRenderer::AtlasEntry::uv_rect.

| void yaze::gfx::AtlasRenderer::RenderBatchWithBppOptimization | ( | const std::vector< RenderCommand > & | render_commands, |
| const std::unordered_map< BppFormat, std::vector< int > > & | bpp_groups | ||
| ) |
Render multiple bitmaps with BPP-aware batching.
| render_commands | Vector of render commands |
| bpp_groups | Map of BPP format to command groups for optimization |
Definition at line 196 of file atlas_renderer.cc.
References atlas_lookup_, atlases_, yaze::gfx::IRenderer::RenderCopy(), renderer_, and yaze::gfx::AtlasRenderer::AtlasEntry::uv_rect.

| AtlasStats yaze::gfx::AtlasRenderer::GetStats | ( | ) | const |
Get atlas statistics.
Definition at line 264 of file atlas_renderer.cc.
References atlases_, yaze::gfx::AtlasStats::total_atlases, yaze::gfx::AtlasStats::total_entries, yaze::gfx::AtlasStats::total_memory, yaze::gfx::AtlasStats::used_entries, and yaze::gfx::AtlasStats::utilization_percent.
Referenced by yaze::gfx::PerformanceDashboard::RenderMemoryUsage().
| void yaze::gfx::AtlasRenderer::Defragment | ( | ) |
Defragment the atlas to reclaim space.
Definition at line 285 of file atlas_renderer.cc.
References atlases_, and RebuildAtlas().

| void yaze::gfx::AtlasRenderer::Clear | ( | ) |
Clear all atlases.
Definition at line 300 of file atlas_renderer.cc.
References atlas_lookup_, atlases_, current_atlas_, yaze::gfx::IRenderer::DestroyTexture(), next_atlas_id_, and renderer_.
Referenced by Initialize(), and ~AtlasRenderer().

| void yaze::gfx::AtlasRenderer::RenderBitmap | ( | int | atlas_id, |
| float | x, | ||
| float | y, | ||
| float | scale_x = 1.0f, |
||
| float | scale_y = 1.0f |
||
| ) |
Render a single bitmap using atlas (convenience method)
| atlas_id | Atlas ID of bitmap to render |
| x | X position on screen |
| y | Y position on screen |
| scale_x | Horizontal scale factor |
| scale_y | Vertical scale factor |
Definition at line 318 of file atlas_renderer.cc.
References atlas_lookup_, atlases_, yaze::gfx::IRenderer::RenderCopy(), renderer_, and yaze::gfx::AtlasRenderer::AtlasEntry::uv_rect.

| SDL_Rect yaze::gfx::AtlasRenderer::GetUVCoordinates | ( | int | atlas_id | ) | const |
Get UV coordinates for a bitmap in the atlas.
| atlas_id | Atlas ID of bitmap |
Definition at line 347 of file atlas_renderer.cc.
References atlas_lookup_.
|
private |
Definition at line 356 of file atlas_renderer.cc.
References FindFreeRegion(), yaze::gfx::Bitmap::height(), MarkRegionUsed(), and yaze::gfx::Bitmap::width().
Referenced by AddBitmap().

|
private |
Definition at line 380 of file atlas_renderer.cc.
References atlases_, yaze::gfx::IRenderer::CreateTexture(), current_atlas_, and renderer_.
Referenced by AddBitmap(), and Initialize().

|
private |
Definition at line 398 of file atlas_renderer.cc.
References yaze::gfx::IRenderer::Clear(), yaze::gfx::AtlasRenderer::Atlas::entries, MarkRegionUsed(), yaze::gfx::IRenderer::RenderCopy(), renderer_, yaze::gfx::IRenderer::SetDrawColor(), yaze::gfx::IRenderer::SetRenderTarget(), yaze::gfx::AtlasRenderer::Atlas::texture, and yaze::gfx::AtlasRenderer::Atlas::used_regions.
Referenced by Defragment().
|
private |
Definition at line 417 of file atlas_renderer.cc.
References yaze::gfx::AtlasRenderer::Atlas::size, and yaze::gfx::AtlasRenderer::Atlas::used_regions.
Referenced by PackBitmap().
|
private |
Definition at line 442 of file atlas_renderer.cc.
References yaze::gfx::AtlasRenderer::Atlas::size, and yaze::gfx::AtlasRenderer::Atlas::used_regions.
Referenced by PackBitmap(), RebuildAtlas(), and RemoveBitmap().
|
private |
Definition at line 188 of file atlas_renderer.h.
Referenced by AddBitmap(), Clear(), CreateNewAtlas(), Initialize(), RebuildAtlas(), RenderBatch(), RenderBatchWithBppOptimization(), and RenderBitmap().
|
private |
Definition at line 189 of file atlas_renderer.h.
Referenced by AddBitmap(), Clear(), CreateNewAtlas(), Defragment(), GetStats(), RemoveBitmap(), RenderBatch(), RenderBatchWithBppOptimization(), and RenderBitmap().
|
private |
Definition at line 190 of file atlas_renderer.h.
Referenced by AddBitmap(), Clear(), GetUVCoordinates(), RemoveBitmap(), RenderBatch(), RenderBatchWithBppOptimization(), RenderBitmap(), and UpdateBitmap().
|
private |
Definition at line 191 of file atlas_renderer.h.
Referenced by AddBitmap(), Clear(), and Initialize().
|
private |
Definition at line 192 of file atlas_renderer.h.
Referenced by AddBitmap(), Clear(), CreateNewAtlas(), and Initialize().