feat(gfx): enhance Bitmap class with palette management and metadata support

- Added methods for applying palettes based on metadata, allowing for flexible palette handling in different bitmap types.
- Introduced a new BitmapMetadata struct to track source format and palette requirements.
- Enhanced ApplyStoredPalette and SetPaletteWithTransparent methods for improved palette application and transparency handling.
- Updated SDL surface pixel management with a new UpdateSurfacePixels method for better pixel data handling.

Benefits:
- Improves the rendering capabilities of the Bitmap class by supporting various palette formats.
- Enhances user experience with more intuitive palette management in graphics operations.
This commit is contained in:
scawful
2025-10-13 17:06:10 -04:00
parent 1314d9daf9
commit 668fdc8068
10 changed files with 600 additions and 66 deletions

View File

@@ -93,7 +93,7 @@ bool LoadROMPaletteGroups(Rom* rom, CanvasPaletteManager& palette_manager) {
}
}
bool ApplyPaletteGroup(gfx::IRenderer* renderer, gfx::Bitmap* bitmap, const CanvasPaletteManager& palette_manager,
bool ApplyPaletteGroup(gfx::IRenderer* renderer, gfx::Bitmap* bitmap, CanvasPaletteManager& palette_manager,
int group_index, int palette_index) {
if (!bitmap) return false;
@@ -110,11 +110,13 @@ bool ApplyPaletteGroup(gfx::IRenderer* renderer, gfx::Bitmap* bitmap, const Canv
bitmap->SetPaletteWithTransparent(palette, palette_index);
}
bitmap->set_modified(true);
palette_manager.palette_dirty = true;
// Queue texture update via Arena's deferred system
if (renderer) {
// Queue texture update only if live_update is enabled
if (palette_manager.live_update_enabled && renderer) {
gfx::Arena::Get().QueueTextureCommand(
gfx::Arena::TextureCommandType::UPDATE, bitmap);
palette_manager.palette_dirty = false; // Clear dirty flag after update
}
return true;
}