From 1710430c2e916542f930429fa31303ede5283084 Mon Sep 17 00:00:00 2001 From: scawful Date: Fri, 2 May 2025 12:14:04 -0400 Subject: [PATCH] Remove unused methods and comments from Bitmap class for improved clarity and maintainability. This includes the removal of surface saving, initialization, cleanup, and palette management functions that are no longer needed. --- src/app/gfx/bitmap.cc | 62 ------------------------------------------- src/app/gfx/bitmap.h | 33 ----------------------- 2 files changed, 95 deletions(-) diff --git a/src/app/gfx/bitmap.cc b/src/app/gfx/bitmap.cc index 77ba011e..0fb0232e 100644 --- a/src/app/gfx/bitmap.cc +++ b/src/app/gfx/bitmap.cc @@ -211,18 +211,6 @@ Bitmap::Bitmap(int width, int height, int depth, SetPalette(palette); } -void Bitmap::SaveSurfaceToFile(std::string_view filename) { - SDL_SaveBMP(surface_, filename.data()); -} - -void Bitmap::Initialize(int width, int height, int depth, - std::span &data) { - width_ = width; - height_ = height; - depth_ = depth; - data_ = std::vector(data.begin(), data.end()); -} - void Bitmap::Create(int width, int height, int depth, std::span data) { data_ = std::vector(data.begin(), data.end()); Create(width, height, depth, data_); @@ -314,14 +302,6 @@ void Bitmap::UpdateTextureData() { modified_ = false; } -void Bitmap::CleanupUnusedTexture(uint64_t current_time, uint64_t timeout) { - if (texture_ && !texture_in_use_ && - (current_time - last_used_time_ > timeout)) { - Arena::Get().FreeTexture(texture_); - texture_ = nullptr; - } -} - void Bitmap::SetPalette(const SnesPalette &palette) { if (surface_ == nullptr) { throw std::runtime_error("Surface is null. Palette not applied"); @@ -348,28 +328,6 @@ void Bitmap::SetPalette(const SnesPalette &palette) { SDL_LockSurface(surface_); } -void Bitmap::SetPaletteFromPaletteGroup(const SnesPalette &palette, - int palette_id) { - auto start_index = palette_id * 8; - palette_ = palette.sub_palette(start_index, start_index + 8); - SDL_UnlockSurface(surface_); - for (size_t i = 0; i < palette_.size(); ++i) { - auto pal_color = palette_[i]; - if (pal_color.is_transparent()) { - surface_->format->palette->colors[i].r = 0; - surface_->format->palette->colors[i].g = 0; - surface_->format->palette->colors[i].b = 0; - surface_->format->palette->colors[i].a = 0; - } else { - surface_->format->palette->colors[i].r = pal_color.rgb().x; - surface_->format->palette->colors[i].g = pal_color.rgb().y; - surface_->format->palette->colors[i].b = pal_color.rgb().z; - surface_->format->palette->colors[i].a = pal_color.rgb().w; - } - } - SDL_LockSurface(surface_); -} - void Bitmap::SetPaletteWithTransparent(const SnesPalette &palette, size_t index, int length) { if (index < 0 || index >= palette.size()) { @@ -480,26 +438,6 @@ void Bitmap::Get16x16Tile(int tile_x, int tile_y, } } -void Bitmap::Cleanup() { - if (texture_) { - Arena::Get().FreeTexture(texture_); - texture_ = nullptr; - } - active_ = false; - width_ = 0; - height_ = 0; - depth_ = 0; - data_size_ = 0; - palette_.clear(); -} - -void Bitmap::Clear() { - Cleanup(); - data_.clear(); - pixel_data_ = nullptr; - texture_pixels = nullptr; -} - #if YAZE_LIB_PNG == 1 std::vector Bitmap::GetPngData() { std::vector png_data; diff --git a/src/app/gfx/bitmap.h b/src/app/gfx/bitmap.h index 23a540cc..dab4f992 100644 --- a/src/app/gfx/bitmap.h +++ b/src/app/gfx/bitmap.h @@ -4,7 +4,6 @@ #include #include -#include #include #include #include @@ -78,11 +77,6 @@ class Bitmap { Bitmap(int width, int height, int depth, const std::vector &data, const SnesPalette &palette); - /** - * @brief Initialize the bitmap with the given dimensions and data - */ - void Initialize(int width, int height, int depth, std::span &data); - /** * @brief Create a bitmap with the given dimensions and data */ @@ -105,11 +99,6 @@ class Bitmap { */ void Reformat(int format); - /** - * @brief Save the bitmap surface to a file - */ - void SaveSurfaceToFile(std::string_view filename); - /** * @brief Creates the underlying SDL_Texture to be displayed. */ @@ -125,12 +114,6 @@ class Bitmap { */ void UpdateTextureData(); - /** - * @brief Clean up unused textures after a timeout - */ - void CleanupUnusedTexture(uint64_t current_time, uint64_t timeout); - - // Palette management /** * @brief Set the palette for the bitmap */ @@ -142,11 +125,6 @@ class Bitmap { void SetPaletteWithTransparent(const SnesPalette &palette, size_t index, int length = 7); - /** - * @brief Set the palette from a palette group - */ - void SetPaletteFromPaletteGroup(const SnesPalette &palette, int palette_id); - /** * @brief Set the palette using SDL colors */ @@ -162,7 +140,6 @@ class Bitmap { */ void WriteColor(int position, const ImVec4 &color); - // Tile operations /** * @brief Extract an 8x8 tile from the bitmap */ @@ -175,16 +152,6 @@ class Bitmap { void Get16x16Tile(int tile_x, int tile_y, std::vector &tile_data, int &tile_data_offset); - /** - * @brief Clean up the bitmap resources - */ - void Cleanup(); - - /** - * @brief Clear the bitmap data - */ - void Clear(); - const SnesPalette &palette() const { return palette_; } SnesPalette *mutable_palette() { return &palette_; } int width() const { return width_; }