Skip to content

Commit 569edab

Browse files
committed
2X unroll loop
From 37167 to 38621 lines per second on RP2040-GEEK.
1 parent 82ae872 commit 569edab

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

src/hagl_line.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,27 @@ void hagl_draw_line(
6767
while (1) {
6868
surface->put_pixel((void *)_surface, x0, y0, color);
6969

70-
if (x0 == x1 && y0 == y1) {
70+
if ((x0 == x1) && (y0 == y1)) {
7171
break;
72-
};
72+
}
73+
74+
e2 = err + err;
75+
76+
if (e2 > -dx) {
77+
err -= dy;
78+
x0 += sx;
79+
}
80+
81+
if (e2 < dy) {
82+
err += dx;
83+
y0 += sy;
84+
}
85+
86+
surface->put_pixel((void *)_surface, x0, y0, color);
87+
88+
if ((x0 == x1) && (y0 == y1)) {
89+
break;
90+
}
7391

7492
e2 = err + err;
7593

0 commit comments

Comments
 (0)