diff mbox series

[fbtest,07/17] drawops: Refactor generic_draw_ellipse()

Message ID 20241215104508.191237-8-geert@linux-m68k.org
State New
Headers show
Series Export feature and large ellipses support | expand

Commit Message

Geert Uytterhoeven Dec. 15, 2024, 10:44 a.m. UTC
Make generic_draw_ellipse() more similar to generic_fill_ellipse().

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 drawops/generic.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/drawops/generic.c b/drawops/generic.c
index e81dea1ba23d6595..4b64c20cc0fe68bc 100644
--- a/drawops/generic.c
+++ b/drawops/generic.c
@@ -309,15 +309,18 @@  void generic_draw_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel)
 	    int dS2 = -4*a2*(b-1);
 	    int dT2 = dS2+2*a2;
 
-	    draw_ellipse_points(x, y, x1, y1, pixel);
-	    do {
+	    while (1) {
 		if (S < 0) {
+		    draw_ellipse_points(x, y, x1, y1, pixel);
 		    S += dS1;
 		    T += dT1;
 		    dS1 += 4*b2;
 		    dT1 += 4*b2;
 		    x1++;
 		} else if (T < 0) {
+		    draw_ellipse_points(x, y, x1, y1, pixel);
+		    if (y1 == 0)
+			break;
 		    S += dS1+dS2;
 		    T += dT1+dT2;
 		    dS1 += 4*b2;
@@ -327,14 +330,16 @@  void generic_draw_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel)
 		    x1++;
 		    y1--;
 		} else {
+		    draw_ellipse_points(x, y, x1, y1, pixel);
+		    if (y1 == 0)
+			break;
 		    S += dS2;
 		    T += dT2;
 		    dS2 += 4*a2;
 		    dT2 += 4*a2;
 		    y1--;
 		}
-		draw_ellipse_points(x, y, x1, y1, pixel);
-	    } while (y1 > 0);
+	    }
 	} else {
 	    u32 x1 = a;
 	    u32 y1 = 0;
@@ -353,6 +358,7 @@  void generic_draw_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel)
 		    dS1 += 4*a2;
 		    dT1 += 4*a2;
 		    y1++;
+		    draw_ellipse_points(x, y, x1, y1, pixel);
 		} else if (T < 0) {
 		    S += dS1+dS2;
 		    T += dT1+dT2;
@@ -362,14 +368,15 @@  void generic_draw_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel)
 		    dT2 += 4*b2;
 		    x1--;
 		    y1++;
+		    draw_ellipse_points(x, y, x1, y1, pixel);
 		} else {
 		    S += dS2;
 		    T += dT2;
 		    dS2 += 4*b2;
 		    dT2 += 4*b2;
 		    x1--;
+		    draw_ellipse_points(x, y, x1, y1, pixel);
 		}
-		draw_ellipse_points(x, y, x1, y1, pixel);
 	    } while (x1 > 0);
 	}
     }