Refactor Bitmap class for improved data handling

- Removed unused data_size_ member and updated size() method to return the size of data_ directly.
- Simplified data size checks in Create method to enhance clarity.
- Updated UpdateTexture method to use memcpy for pixel data assignment, improving performance.
- Ensured WriteToPixel method updates both pixel_data_ and data_ for consistency in modifications.
This commit is contained in:
scawful
2025-05-15 23:01:03 -04:00
parent ab729fc198
commit ceab496226
3 changed files with 7 additions and 8 deletions

View File

@@ -151,7 +151,7 @@ class Bitmap {
int width() const { return width_; }
int height() const { return height_; }
int depth() const { return depth_; }
int size() const { return data_size_; }
int size() const { return data_.size(); }
const uint8_t *data() const { return data_.data(); }
std::vector<uint8_t> &mutable_data() { return data_; }
SDL_Surface *surface() const { return surface_; }
@@ -172,7 +172,6 @@ class Bitmap {
int width_ = 0;
int height_ = 0;
int depth_ = 0;
int data_size_ = 0;
bool active_ = false;
bool modified_ = false;