diff --git a/src/app/gfx/bitmap.cc b/src/app/gfx/bitmap.cc index 3b4c38bd..ddf04741 100644 --- a/src/app/gfx/bitmap.cc +++ b/src/app/gfx/bitmap.cc @@ -288,7 +288,7 @@ void Bitmap::CreateTexture(SDL_Renderer *renderer) { SDL_Log("SDL_CreateTextureFromSurface failed: %s\n", SDL_GetError()); } - converted_surface_ = std::shared_ptr{ + auto converted_surface_ = std::shared_ptr{ SDL_ConvertSurfaceFormat(surface_.get(), SDL_PIXELFORMAT_ARGB8888, 0), SDL_Surface_Deleter{}}; if (converted_surface_ == nullptr) { @@ -304,19 +304,17 @@ void Bitmap::CreateTexture(SDL_Renderer *renderer) { } void Bitmap::UpdateTexture(SDL_Renderer *renderer) { - SDL_Surface *converted_surface = - SDL_ConvertSurfaceFormat(surface_.get(), SDL_PIXELFORMAT_ARGB8888, 0); - if (converted_surface) { - converted_surface_ = std::unique_ptr( - converted_surface, SDL_Surface_Deleter()); - } else { + auto converted_surface = std::unique_ptr( + SDL_ConvertSurfaceFormat(surface_.get(), SDL_PIXELFORMAT_ARGB8888, 0), + SDL_Surface_Deleter()); + if (converted_surface == nullptr) { SDL_Log("SDL_ConvertSurfaceFormat failed: %s\n", SDL_GetError()); } SDL_LockTexture(texture_.get(), nullptr, (void **)&texture_pixels, - &converted_surface_->pitch); - memcpy(texture_pixels, converted_surface_->pixels, - converted_surface_->h * converted_surface_->pitch); + &converted_surface->pitch); + memcpy(texture_pixels, converted_surface->pixels, + converted_surface->h * converted_surface->pitch); SDL_UnlockTexture(texture_.get()); } diff --git a/src/app/gfx/bitmap.h b/src/app/gfx/bitmap.h index d628e979..002aab63 100644 --- a/src/app/gfx/bitmap.h +++ b/src/app/gfx/bitmap.h @@ -150,12 +150,6 @@ class Bitmap { palette_.clear(); } - auto sdl_palette() { - if (surface_ == nullptr) { - throw std::runtime_error("Surface is null."); - } - return surface_->format->palette; - } auto palette() const { return palette_; } auto mutable_palette() { return &palette_; } auto palette_size() const { return palette_.size(); } @@ -168,8 +162,6 @@ class Bitmap { auto &mutable_data() { return data_; } auto surface() const { return surface_.get(); } auto mutable_surface() { return surface_.get(); } - auto converted_surface() const { return converted_surface_.get(); } - auto mutable_converted_surface() { return converted_surface_.get(); } auto vector() const { return data_; } auto at(int i) const { return data_[i]; } @@ -196,7 +188,6 @@ class Bitmap { gfx::SnesPalette palette_; std::shared_ptr texture_ = nullptr; std::shared_ptr surface_ = nullptr; - std::shared_ptr converted_surface_ = nullptr; }; using BitmapTable = std::unordered_map;