refactor(core/rendering): esborrar codi mort de Text (DEAD-01 + DEAD-02)
Eliminats cinc mètodes sense callers externs: - writeShadowed / writeCentered: la funcionalitat viu a writeDX(flags, ...) que és l'API reutilitzable; ningú crida aquestes variants discretes. - glyphWidth / getGlyphClip: getters per glif no consumits enlloc. - codepointToUtf8: helper de serialització UTF-8 no consumit (només es consumeix el parser nextCodepoint, que queda). 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
81fe826d17
commit
b51109e380
3 files changed
+4
-55
No files matched your search
@@ -94,8 +94,8 @@ Los IDs se mantienen estables una vez asignados. Cada entrada apunta al(los) fic
|
|||||||
|
|
||||||
| ID | Fichero:línea | Hallazgo | Severidad | Estado | Notas |
|
| ID | Fichero:línea | Hallazgo | Severidad | Estado | Notas |
|
||||||
|----|---------------|----------|-----------|--------|-------|
|
|----|---------------|----------|-----------|--------|-------|
|
||||||
| DEAD-01 | `text.hpp:50-51` | `writeShadowed`, `writeCentered` sin callers externos | Importante | PENDING | borrar |
|
| DEAD-01 | `text.hpp:50-51` | `writeShadowed`, `writeCentered` sin callers externos | Importante | DONE | esborrats |
|
||||||
| DEAD-02 | `text.hpp:62-63,67` | `glyphWidth`, `getGlyphClip`, `codepointToUtf8` sin callers | Importante | PENDING | borrar |
|
| DEAD-02 | `text.hpp:62-63,67` | `glyphWidth`, `getGlyphClip`, `codepointToUtf8` sin callers | Importante | DONE | esborrats |
|
||||||
| DEAD-03 | `text.hpp:64` | `getSprite()` sin callers | Menor | PENDING | borrar |
|
| DEAD-03 | `text.hpp:64` | `getSprite()` sin callers | Menor | PENDING | borrar |
|
||||||
| DEAD-04 | `sprite.hpp:33` | `getRect()` sin callers | Menor | PENDING | borrar |
|
| DEAD-04 | `sprite.hpp:33` | `getRect()` sin callers | Menor | PENDING | borrar |
|
||||||
| DEAD-05 | `sprite.hpp:42-43` | `incX`, `incY` sin callers | Menor | PENDING | borrar |
|
| DEAD-05 | `sprite.hpp:42-43` | `incX`, `incY` sin callers | Menor | PENDING | borrar |
|
||||||
@@ -126,4 +126,5 @@ Los IDs se mantienen estables una vez asignados. Cada entrada apunta al(los) fic
|
|||||||
- `5f46fb2` — CONV-03 + DUP-04 + DUP-05 + PATCH-07: shaders MSL i helpers extrets a `sdl3gpu/msl/` i `sdl3gpu/shader_factory.hpp`
|
- `5f46fb2` — CONV-03 + DUP-04 + DUP-05 + PATCH-07: shaders MSL i helpers extrets a `sdl3gpu/msl/` i `sdl3gpu/shader_factory.hpp`
|
||||||
- `a63deac` — DUP-03 + HC-01: `Text` amb `resolveGlyph` i constants `INK_COLOR_INDEX` / `DEFAULT_TEXT_COLOR`
|
- `a63deac` — DUP-03 + HC-01: `Text` amb `resolveGlyph` i constants `INK_COLOR_INDEX` / `DEFAULT_TEXT_COLOR`
|
||||||
- `029907d` — COUP-02a: `Screen` desacoblat de `SDL3GPUShader` via `makeDefaultShaderBackend()`
|
- `029907d` — COUP-02a: `Screen` desacoblat de `SDL3GPUShader` via `makeDefaultShaderBackend()`
|
||||||
- `<pendent>` — COUP-02b (= COUP-03): `Surface` usa `Rendering::activeCanvas()` en lloc de `Screen::get()`
|
- `81fe826` — COUP-02b (= COUP-03): `Surface` usa `Rendering::activeCanvas()` en lloc de `Screen::get()`
|
||||||
|
- `<pendent>` — DEAD-01 + DEAD-02: esborrats `writeShadowed`/`writeCentered`/`glyphWidth`/`getGlyphClip`/`codepointToUtf8`
|
||||||
@@ -47,26 +47,6 @@ auto Text::nextCodepoint(const std::string& s, std::size_t& pos) -> std::uint32_
|
|||||||
return cp;
|
return cp;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Text::codepointToUtf8(std::uint32_t cp) -> std::string {
|
|
||||||
std::string result;
|
|
||||||
if (cp < 0x80) {
|
|
||||||
result += static_cast<char>(cp);
|
|
||||||
} else if (cp < 0x800) {
|
|
||||||
result += static_cast<char>(0xC0 | (cp >> 6));
|
|
||||||
result += static_cast<char>(0x80 | (cp & 0x3F));
|
|
||||||
} else if (cp < 0x10000) {
|
|
||||||
result += static_cast<char>(0xE0 | (cp >> 12));
|
|
||||||
result += static_cast<char>(0x80 | ((cp >> 6) & 0x3F));
|
|
||||||
result += static_cast<char>(0x80 | (cp & 0x3F));
|
|
||||||
} else {
|
|
||||||
result += static_cast<char>(0xF0 | (cp >> 18));
|
|
||||||
result += static_cast<char>(0x80 | ((cp >> 12) & 0x3F));
|
|
||||||
result += static_cast<char>(0x80 | ((cp >> 6) & 0x3F));
|
|
||||||
result += static_cast<char>(0x80 | (cp & 0x3F));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Format .fnt: claus "box_width/box_height/columns/cell_spacing/row_spacing"
|
// Format .fnt: claus "box_width/box_height/columns/cell_spacing/row_spacing"
|
||||||
// i una línia per glif amb "codepoint_decimal amplada_visual". Els glifs
|
// i una línia per glif amb "codepoint_decimal amplada_visual". Els glifs
|
||||||
// s'ordenen al png per ordre d'aparició al .fnt (glyph_index).
|
// s'ordenen al png per ordre d'aparició al .fnt (glyph_index).
|
||||||
@@ -165,16 +145,6 @@ void Text::writeColored(int x, int y, const std::string& text, Uint8 color, int
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Text::writeShadowed(int x, int y, const std::string& text, Uint8 color, Uint8 shadow_distance, int kerning, int length) {
|
|
||||||
writeColored(x + shadow_distance, y + shadow_distance, text, color, kerning, length);
|
|
||||||
write(x, y, text, kerning, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Text::writeCentered(int x, int y, const std::string& text, int kerning, int length) {
|
|
||||||
x -= (Text::length(text, kerning) / 2);
|
|
||||||
write(x, y, text, kerning, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Text::writeDX(Uint8 flags, int x, int y, const std::string& text, int kerning, Uint8 text_color, Uint8 shadow_distance, Uint8 shadow_color, int length) {
|
void Text::writeDX(Uint8 flags, int x, int y, const std::string& text, int kerning, Uint8 text_color, Uint8 shadow_distance, Uint8 shadow_color, int length) {
|
||||||
const bool CENTERED = ((flags & CENTER_FLAG) == CENTER_FLAG);
|
const bool CENTERED = ((flags & CENTER_FLAG) == CENTER_FLAG);
|
||||||
const bool SHADOWED = ((flags & SHADOW_FLAG) == SHADOW_FLAG);
|
const bool SHADOWED = ((flags & SHADOW_FLAG) == SHADOW_FLAG);
|
||||||
@@ -265,22 +235,6 @@ auto Text::length(const std::string& text, int kerning) const -> int {
|
|||||||
return shift > 0 ? shift - kerning : 0;
|
return shift > 0 ? shift - kerning : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Text::glyphWidth(std::uint32_t codepoint, int kerning) const -> int {
|
|
||||||
if (const Offset* off = resolveGlyph(codepoint); off != nullptr) {
|
|
||||||
return off->w + kerning;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto Text::getGlyphClip(std::uint32_t codepoint) const -> SDL_FRect {
|
|
||||||
const Offset* off = resolveGlyph(codepoint);
|
|
||||||
if (off == nullptr) { return {.x = 0.0F, .y = 0.0F, .w = 0.0F, .h = 0.0F}; }
|
|
||||||
return {.x = static_cast<float>(off->x),
|
|
||||||
.y = static_cast<float>(off->y),
|
|
||||||
.w = static_cast<float>(box_width_),
|
|
||||||
.h = static_cast<float>(box_height_)};
|
|
||||||
}
|
|
||||||
|
|
||||||
auto Text::resolveGlyph(std::uint32_t cp) const -> const Offset* {
|
auto Text::resolveGlyph(std::uint32_t cp) const -> const Offset* {
|
||||||
auto it = offset_.find(cp);
|
auto it = offset_.find(cp);
|
||||||
if (it == offset_.end()) { it = offset_.find('?'); }
|
if (it == offset_.end()) { it = offset_.find('?'); }
|
||||||
|
|||||||
@@ -54,8 +54,6 @@ class Text {
|
|||||||
|
|
||||||
void write(int x, int y, const std::string& text, int kerning = 1, int length = -1);
|
void write(int x, int y, const std::string& text, int kerning = 1, int length = -1);
|
||||||
void writeColored(int x, int y, const std::string& text, Uint8 color, int kerning = 1, int length = -1);
|
void writeColored(int x, int y, const std::string& text, Uint8 color, int kerning = 1, int length = -1);
|
||||||
void writeShadowed(int x, int y, const std::string& text, Uint8 color, Uint8 shadow_distance = 1, int kerning = 1, int length = -1);
|
|
||||||
void writeCentered(int x, int y, const std::string& text, int kerning = 1, int length = -1);
|
|
||||||
void writeDX(Uint8 flags, int x, int y, const std::string& text, int kerning = 1, Uint8 text_color = 0, Uint8 shadow_distance = 1, Uint8 shadow_color = 0, int length = -1);
|
void writeDX(Uint8 flags, int x, int y, const std::string& text, int kerning = 1, Uint8 text_color = 0, Uint8 shadow_distance = 1, Uint8 shadow_color = 0, int length = -1);
|
||||||
|
|
||||||
// Dibuixa amb amplada fixa només per als dígits '0'-'9' (cadascun centrat
|
// Dibuixa amb amplada fixa només per als dígits '0'-'9' (cadascun centrat
|
||||||
@@ -66,12 +64,8 @@ class Text {
|
|||||||
[[nodiscard]] auto length(const std::string& text, int kerning = 1) const -> int;
|
[[nodiscard]] auto length(const std::string& text, int kerning = 1) const -> int;
|
||||||
[[nodiscard]] auto lengthMonoDigits(const std::string& text, int digit_cell_w, int kerning = 1) const -> int;
|
[[nodiscard]] auto lengthMonoDigits(const std::string& text, int digit_cell_w, int kerning = 1) const -> int;
|
||||||
[[nodiscard]] auto getCharacterSize() const -> int { return box_width_; }
|
[[nodiscard]] auto getCharacterSize() const -> int { return box_width_; }
|
||||||
[[nodiscard]] auto glyphWidth(std::uint32_t codepoint, int kerning = 0) const -> int;
|
|
||||||
[[nodiscard]] auto getGlyphClip(std::uint32_t codepoint) const -> SDL_FRect;
|
|
||||||
[[nodiscard]] auto getSprite() const -> Sprite* { return sprite_.get(); }
|
|
||||||
|
|
||||||
static auto loadTextFile(const std::string& file_path) -> std::shared_ptr<File>;
|
static auto loadTextFile(const std::string& file_path) -> std::shared_ptr<File>;
|
||||||
static auto codepointToUtf8(std::uint32_t cp) -> std::string;
|
|
||||||
static auto nextCodepoint(const std::string& s, std::size_t& pos) -> std::uint32_t;
|
static auto nextCodepoint(const std::string& s, std::size_t& pos) -> std::uint32_t;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in new issue
Block a user