Changeset - r26897:a6ae56d8c0f0
[Not reviewed]
master
0 1 0
Nik Nyby - 22 months ago 2023-02-20 21:18:25
nikolas@gnu.org
Fix #10222: Adjust line drawing algorithm (#10491)
1 file changed with 12 insertions and 10 deletions:
0 comments (0 inline, 0 general)
src/blitter/common.hpp
Show inline comments
 
@@ -106,25 +106,26 @@ void Blitter::DrawLineGeneric(int x1, in
 
		x2++;
 
		if (x2 > screen_width) {
 
			x2 = screen_width;
 
		}
 

	
 
		while (x1 != x2) {
 
			if (dash_count < dash) {
 
				for (int y = y_low; y != y_high; y += stepy) {
 
					if (y >= 0 && y < screen_height) set_pixel(x1, y);
 
				}
 
			}
 
			if (frac_low >= 0) {
 
				y_low += stepy;
 
				frac_low -= dx;
 
			}
 
			if (frac_high >= 0) {
 
				y_high += stepy;
 
				frac_high -= dx;
 
			}
 
			if (dash_count < dash) {
 
				for (int y = y_low; y != y_high; y += stepy) {
 
					if (y >= 0 && y < screen_height) set_pixel(x1, y);
 
				}
 
			}
 

	
 
			x1++;
 
			frac_low += dy;
 
			frac_high += dy;
 
			if (++dash_count >= dash + gap) dash_count = 0;
 
		}
 
	} else {
 
@@ -168,25 +169,26 @@ void Blitter::DrawLineGeneric(int x1, in
 
		y2++;
 
		if (y2 > screen_height) {
 
			y2 = screen_height;
 
		}
 

	
 
		while (y1 != y2) {
 
			if (dash_count < dash) {
 
				for (int x = x_low; x != x_high; x += stepx) {
 
					if (x >= 0 && x < screen_width) set_pixel(x, y1);
 
				}
 
			}
 
			if (frac_low >= 0) {
 
				x_low += stepx;
 
				frac_low -= dy;
 
			}
 
			if (frac_high >= 0) {
 
				x_high += stepx;
 
				frac_high -= dy;
 
			}
 
			if (dash_count < dash) {
 
				for (int x = x_low; x != x_high; x += stepx) {
 
					if (x >= 0 && x < screen_width) set_pixel(x, y1);
 
				}
 
			}
 

	
 
			y1++;
 
			frac_low += dx;
 
			frac_high += dx;
 
			if (++dash_count >= dash + gap) dash_count = 0;
 
		}
 
	}
0 comments (0 inline, 0 general)