diff options
| author | Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> | 2025-09-12 15:44:14 +0300 |
|---|---|---|
| committer | Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> | 2025-09-12 15:44:27 +0300 |
| commit | 2efdd2583da9575242091bb53c57a311c3eacbc6 (patch) | |
| tree | 17a87333cb30382c8dd95eb8a155eaca3addc50b /kms++util | |
| parent | ce748d0b1e9f78b29cc2029f9446cd242af5fa3c (diff) | |
kms++util: Fix drawing outside fb boundaries
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Diffstat (limited to 'kms++util')
| -rw-r--r-- | kms++util/src/colorbar.cpp | 7 | ||||
| -rw-r--r-- | kms++util/src/drawing.cpp | 4 |
2 files changed, 11 insertions, 0 deletions
diff --git a/kms++util/src/colorbar.cpp b/kms++util/src/colorbar.cpp index cd0b978..c727306 100644 --- a/kms++util/src/colorbar.cpp +++ b/kms++util/src/colorbar.cpp @@ -99,6 +99,13 @@ static void drm_draw_color_bar_semiplanar_yuv(IFramebuffer& buf, int old_xpos, i void draw_color_bar(IFramebuffer& buf, int old_xpos, int xpos, int width) { + // Skip if the bar is not fully drawable + if (xpos + width > (int)buf.width()) + return; + + if (old_xpos >= 0 && old_xpos + width > (int)buf.width()) + old_xpos = -1; + switch (buf.format()) { case PixelFormat::NV12: case PixelFormat::NV21: diff --git a/kms++util/src/drawing.cpp b/kms++util/src/drawing.cpp index 862638b..7e3ca97 100644 --- a/kms++util/src/drawing.cpp +++ b/kms++util/src/drawing.cpp @@ -533,6 +533,10 @@ static bool get_char_pixel(char c, uint32_t x, uint32_t y) static void draw_char(IFramebuffer& buf, uint32_t xpos, uint32_t ypos, char c, RGB color) { + // Skip characters that are not fully drawable + if (xpos + 8 > buf.width() || ypos + 8 > buf.height()) + return; + unsigned x, y; YUV yuvcolor = color.yuv(); |
