From 5f0b4355e4e29e54e942dc296f21bf4482939869 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sat, 18 Apr 2026 12:16:46 +0200 Subject: [PATCH] =?UTF-8?q?surface:=20hallazgo=204=20=E2=80=94=20elimina?= =?UTF-8?q?=20render(6=20floats)=20sin=20callers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit La sobrecarga render(float dx, float dy, float sx, float sy, float w, float h) no tenía un solo caller en el proyecto. Las otras dos sobrecargas (con SDL_FRect) cubren todos los casos de uso reales. Co-Authored-By: Claude Opus 4.7 (1M context) --- source/core/rendering/surface.cpp | 31 ------------------------------- source/core/rendering/surface.hpp | 1 - 2 files changed, 32 deletions(-) diff --git a/source/core/rendering/surface.cpp b/source/core/rendering/surface.cpp index cc16cb0..10cb601 100644 --- a/source/core/rendering/surface.cpp +++ b/source/core/rendering/surface.cpp @@ -247,37 +247,6 @@ void Surface::drawLine(float x1, float y1, float x2, float y2, Uint8 color) { / } } -void Surface::render(float dx, float dy, float sx, float sy, float w, float h) { // NOLINT(readability-make-member-function-const) - auto surface_data = Screen::get()->getRendererSurface()->getSurfaceData(); - - // Limitar la región para evitar accesos fuera de rango en origen - w = std::min(w, surface_data_->width - sx); - h = std::min(h, surface_data_->height - sy); - - // Limitar la región para evitar accesos fuera de rango en destino - w = std::min(w, surface_data->width - dx); - h = std::min(h, surface_data->height - dy); - - const Uint8* src_ptr = surface_data_->data.get(); - Uint8* dst_ptr = surface_data->data.get(); - for (int iy = 0; iy < h; ++iy) { - for (int ix = 0; ix < w; ++ix) { - // Verificar que las coordenadas de destino están dentro de los límites - if (int dest_x = dx + ix; dest_x >= 0 && dest_x < surface_data->width) { - if (int dest_y = dy + iy; dest_y >= 0 && dest_y < surface_data->height) { - int src_x = sx + ix; - int src_y = sy + iy; - - Uint8 color = src_ptr[static_cast(src_x + (src_y * surface_data_->width))]; - if (color != static_cast(transparent_color_)) { - dst_ptr[static_cast(dest_x + (dest_y * surface_data->width))] = sub_palette_[color]; - } - } - } - } - } -} - void Surface::render(int x, int y, SDL_FRect* src_rect, SDL_FlipMode flip) { // NOLINT(readability-make-member-function-const) auto surface_data_dest = Screen::get()->getRendererSurface()->getSurfaceData(); diff --git a/source/core/rendering/surface.hpp b/source/core/rendering/surface.hpp index 91f80c6..6bb26a7 100644 --- a/source/core/rendering/surface.hpp +++ b/source/core/rendering/surface.hpp @@ -80,7 +80,6 @@ class Surface { void loadPalette(const Palette& palette); // Copia una región de la SurfaceData de origen a la SurfaceData de destino - void render(float dx, float dy, float sx, float sy, float w, float h); void render(int x, int y, SDL_FRect* src_rect = nullptr, SDL_FlipMode flip = SDL_FLIP_NONE); void render(SDL_FRect* src_rect = nullptr, SDL_FRect* dst_rect = nullptr, SDL_FlipMode flip = SDL_FLIP_NONE);