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.
This commit is contained in:
@@ -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<uint8_t> &data) {
|
||||
width_ = width;
|
||||
height_ = height;
|
||||
depth_ = depth;
|
||||
data_ = std::vector<uint8_t>(data.begin(), data.end());
|
||||
}
|
||||
|
||||
void Bitmap::Create(int width, int height, int depth, std::span<uint8_t> data) {
|
||||
data_ = std::vector<uint8_t>(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<uint8_t> Bitmap::GetPngData() {
|
||||
std::vector<uint8_t> png_data;
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <SDL.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
@@ -78,11 +77,6 @@ class Bitmap {
|
||||
Bitmap(int width, int height, int depth, const std::vector<uint8_t> &data,
|
||||
const SnesPalette &palette);
|
||||
|
||||
/**
|
||||
* @brief Initialize the bitmap with the given dimensions and data
|
||||
*/
|
||||
void Initialize(int width, int height, int depth, std::span<uint8_t> &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<uint8_t> &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_; }
|
||||
|
||||
Reference in New Issue
Block a user