refactor(core/rendering): Surface desacoblat de Screen via Canvas (COUP-02b / COUP-03)
Surface::renderWithColorReplace usava Screen::get().getCanvasArgb() i companys per a obtenir el buffer destí. S'introdueix una abstracció mínima: - source/core/rendering/canvas.hpp: struct Canvas amb pixels/width/ height i la fàbrica activeCanvas() que retorna el canvas actiu. - source/core/rendering/canvas.cpp: implementació que delega a Screen. Surface ara inclou canvas.hpp en lloc de screen.hpp i crida Rendering::activeCanvas(). L'indirecció permet, més endavant, empènyer canvases alternatius (off-screen, efectes) sense tocar Surface; ara mateix es comporta idèntic al codi anterior. Build + smoke 5s xvfb OK (exit 124). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
029907d5a0
commit
81fe826d17
5 files changed
+50
-7
No files matched your search
@@ -6,8 +6,8 @@
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
|
||||
#include "core/rendering/canvas.hpp"
|
||||
#include "core/rendering/gif.hpp"
|
||||
#include "core/rendering/screen.hpp"
|
||||
#include "core/resources/resource_helper.hpp"
|
||||
#include "utils/utils.hpp"
|
||||
|
||||
@@ -86,9 +86,10 @@ void Surface::render(int x, int y, const SDL_FRect* src_rect, SDL_FlipMode flip)
|
||||
}
|
||||
|
||||
void Surface::renderWithColorReplace(int x, int y, Uint8 source_color, Uint8 target_color, const SDL_FRect* src_rect, SDL_FlipMode flip) const {
|
||||
Uint32* dst = Screen::get().getCanvasArgb();
|
||||
const int DST_W = Screen::get().getCanvasWidth();
|
||||
const int DST_H = Screen::get().getCanvasHeight();
|
||||
const auto CANVAS = Rendering::activeCanvas();
|
||||
Uint32* dst = CANVAS.pixels;
|
||||
const int DST_W = CANVAS.width;
|
||||
const int DST_H = CANVAS.height;
|
||||
|
||||
const int SX = (src_rect != nullptr) ? static_cast<int>(src_rect->x) : 0;
|
||||
const int SY = (src_rect != nullptr) ? static_cast<int>(src_rect->y) : 0;
|
||||
|
||||
Reference in new issue
Block a user