From 52a34d7915bc411ed5d3c1b94e67ad16f1d3086b Mon Sep 17 00:00:00 2001 From: Mika Tuupola Date: Sun, 8 Mar 2026 13:15:34 +0200 Subject: [PATCH 1/2] Add failing test for vline height with custom clip window --- tests/test_vline.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/test_vline.c b/tests/test_vline.c index 5cb335b..709462d 100644 --- a/tests/test_vline.c +++ b/tests/test_vline.c @@ -328,6 +328,32 @@ TEST test_draw_vline_xyh_custom_clip_regression(void) { PASS(); } +/* + * Line clipped by top edge of custom clip window only: + * Only y=50..59 visible. + */ +TEST test_draw_vline_xyh_custom_clip_top(void) { + hagl_set_clip(&bitmap, 50, 50, 200, 200); + hagl_draw_vline_xyh(&bitmap, 75, 40, 20, 0xFFFF); + + /* On line: top edge of clip window */ + ASSERT_EQ(0xFFFF, hagl_get_pixel(&bitmap, 75, 50)); + + /* On line: bottom endpoint of original line */ + ASSERT_EQ(0xFFFF, hagl_get_pixel(&bitmap, 75, 59)); + + /* Outside: just above clip window */ + ASSERT_EQ(0x0000, hagl_get_pixel(&bitmap, 75, 49)); + + /* Outside: just below original line end */ + ASSERT_EQ(0x0000, hagl_get_pixel(&bitmap, 75, 60)); + + /* Total: 10 pixels */ + ASSERT_EQ(10, count_pixels(&bitmap, 0xFFFF)); + + PASS(); +} + SUITE(vline_suite) { SET_SETUP(setup_callback, NULL); SET_TEARDOWN(teardown_callback, NULL); @@ -345,6 +371,7 @@ SUITE(vline_suite) { RUN_TEST(test_draw_vline_xyh_outside); RUN_TEST(test_draw_vline_xyh_custom_clip); RUN_TEST(test_draw_vline_xyh_custom_clip_regression); + RUN_TEST(test_draw_vline_xyh_custom_clip_top); } GREATEST_MAIN_DEFS(); From 09cdb81c765372e20a75cf52342b9172ecaf8dc2 Mon Sep 17 00:00:00 2001 From: Mika Tuupola Date: Sun, 8 Mar 2026 13:23:39 +0200 Subject: [PATCH 2/2] Fix vline height with custom clip window --- src/hagl_vline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hagl_vline.c b/src/hagl_vline.c index 946b2e0..1d09a87 100644 --- a/src/hagl_vline.c +++ b/src/hagl_vline.c @@ -52,7 +52,7 @@ void hagl_draw_vline_xyh( /* y0 is top of clip window, ignore start part. */ if (y0 < surface->clip.y0) { - height = height + y0; + height = height - (surface->clip.y0 - y0); y0 = surface->clip.y0; }