Add BPP format management and optimization features

- Introduced BPPFormatManager for handling various bitmap formats (2BPP, 3BPP, 4BPP, 8BPP) with conversion capabilities.
- Enhanced AtlasRenderer to support bitmap addition with BPP format optimization and added methods for optimized rendering.
- Implemented GraphicsOptimizer for analyzing and optimizing graphics sheets based on BPP formats, including memory and performance considerations.
- Developed BppFormatUI for user interface interactions related to BPP format selection and conversion previews.
- Integrated BPP format management into the canvas system, allowing for format selection and conversion within the GUI.
- Updated CMake configuration to include new source files related to BPP management and optimization.
This commit is contained in:
scawful
2025-09-29 21:21:49 -04:00
parent 100fc23a2e
commit 9e0f614ce8
12 changed files with 2469 additions and 5 deletions

View File

@@ -8,6 +8,7 @@
#include "app/gfx/bitmap.h"
#include "app/gfx/performance_profiler.h"
#include "app/gfx/bpp_format_manager.h"
namespace yaze {
namespace gfx {
@@ -88,6 +89,14 @@ class AtlasRenderer {
*/
int AddBitmap(const Bitmap& bitmap);
/**
* @brief Add a bitmap to the atlas with BPP format optimization
* @param bitmap Bitmap to add to atlas
* @param target_bpp Target BPP format for optimization
* @return Atlas ID for referencing this bitmap
*/
int AddBitmapWithBppOptimization(const Bitmap& bitmap, BppFormat target_bpp);
/**
* @brief Remove a bitmap from the atlas
* @param atlas_id Atlas ID of bitmap to remove
@@ -107,6 +116,14 @@ class AtlasRenderer {
*/
void RenderBatch(const std::vector<RenderCommand>& render_commands);
/**
* @brief Render multiple bitmaps with BPP-aware batching
* @param render_commands Vector of render commands
* @param bpp_groups Map of BPP format to command groups for optimization
*/
void RenderBatchWithBppOptimization(const std::vector<RenderCommand>& render_commands,
const std::unordered_map<BppFormat, std::vector<int>>& bpp_groups);
/**
* @brief Get atlas statistics
* @return Atlas usage statistics
@@ -149,9 +166,14 @@ class AtlasRenderer {
SDL_Rect uv_rect; // UV coordinates in atlas
SDL_Texture* texture;
bool in_use;
BppFormat bpp_format; // BPP format of this entry
int original_width;
int original_height;
AtlasEntry(int id, const SDL_Rect& rect, SDL_Texture* tex)
: atlas_id(id), uv_rect(rect), texture(tex), in_use(true) {}
AtlasEntry(int id, const SDL_Rect& rect, SDL_Texture* tex, BppFormat bpp = BppFormat::kBpp8,
int width = 0, int height = 0)
: atlas_id(id), uv_rect(rect), texture(tex), in_use(true),
bpp_format(bpp), original_width(width), original_height(height) {}
};
struct Atlas {