diff mbox series

[fbtest,08/17] drawops: Return early in generic_{draw,fill}_ellipse()

Message ID 20241215104508.191237-9-geert@linux-m68k.org (mailing list archive)
State New
Headers show
Series Export feature and large ellipses support | expand

Commit Message

Geert Uytterhoeven Dec. 15, 2024, 10:44 a.m. UTC
This reduces indentation in the largest branches.

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

Patch

diff --git a/drawops/generic.c b/drawops/generic.c
index 4b64c20cc0fe68bc..471aefe38d43aaa4 100644
--- a/drawops/generic.c
+++ b/drawops/generic.c
@@ -295,90 +295,90 @@  static void draw_ellipse_points(u32 cx, u32 cy, u32 x, u32 y, pixel_t pixel)
 void generic_draw_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel)
 {
     if (a == b)
-	draw_circle(x, y, a, pixel);
-    else {
-	u32 a2 = a*a;
-	u32 b2 = b*b;
-	if (a <= b) {
-	    u32 x1 = 0;
-	    u32 y1 = b;
-	    int S = a2*(1-2*b)+2*b2;
-	    int T = b2-2*a2*(2*b-1);
-	    int dT1 = 4*b2;
-	    int dS1 = dT1+2*b2;
-	    int dS2 = -4*a2*(b-1);
-	    int dT2 = dS2+2*a2;
-
-	    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;
-		    dT1 += 4*b2;
-		    dS2 += 4*a2;
-		    dT2 += 4*a2;
-		    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--;
-		}
+	return draw_circle(x, y, a, pixel);
+
+    u32 a2 = a*a;
+    u32 b2 = b*b;
+
+    if (a <= b) {
+	u32 x1 = 0;
+	u32 y1 = b;
+	int S = a2*(1-2*b)+2*b2;
+	int T = b2-2*a2*(2*b-1);
+	int dT1 = 4*b2;
+	int dS1 = dT1+2*b2;
+	int dS2 = -4*a2*(b-1);
+	int dT2 = dS2+2*a2;
+
+	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;
+		dT1 += 4*b2;
+		dS2 += 4*a2;
+		dT2 += 4*a2;
+		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--;
 	    }
-	} else {
-	    u32 x1 = a;
-	    u32 y1 = 0;
-            int S = b2*(1-2*a)+2*a2;
-            int T = a2-2*b2*(2*a-1);
-            int dT1 = 4*a2;
-            int dS1 = dT1+2*a2;
-            int dS2 = -4*b2*(a-1);
-            int dT2 = dS2+2*b2;
-
-	    draw_ellipse_points(x, y, x1, y1, pixel);
-	    do {
-		if (S < 0) {
-		    S += dS1;
-		    T += dT1;
-		    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;
-		    dS1 += 4*a2;
-		    dT1 += 4*a2;
-		    dS2 += 4*b2;
-		    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);
-		}
-	    } while (x1 > 0);
 	}
+    } else {
+	u32 x1 = a;
+	u32 y1 = 0;
+	int S = b2*(1-2*a)+2*a2;
+	int T = a2-2*b2*(2*a-1);
+	int dT1 = 4*a2;
+	int dS1 = dT1+2*a2;
+	int dS2 = -4*b2*(a-1);
+	int dT2 = dS2+2*b2;
+
+	draw_ellipse_points(x, y, x1, y1, pixel);
+	do {
+	    if (S < 0) {
+		S += dS1;
+		T += dT1;
+		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;
+		dS1 += 4*a2;
+		dT1 += 4*a2;
+		dS2 += 4*b2;
+		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);
+	    }
+	} while (x1 > 0);
     }
 }
 
@@ -403,88 +403,88 @@  static void fill_ellipse_points(u32 cx, u32 cy, u32 x, u32 y, pixel_t pixel)
 void generic_fill_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel)
 {
     if (a == b)
-	fill_circle(x, y, a, pixel);
-    else {
-	u32 a2 = a*a;
-	u32 b2 = b*b;
-	if (a <= b) {
-	    u32 x1 = 0;
-	    u32 y1 = b;
-	    int S = a2*(1-2*b)+2*b2;
-	    int T = b2-2*a2*(2*b-1);
-	    int dT1 = 4*b2;
-	    int dS1 = dT1+2*b2;
-	    int dS2 = -4*a2*(b-1);
-	    int dT2 = dS2+2*a2;
-
-	    while (1) {
-		if (S < 0) {
-		    S += dS1;
-		    T += dT1;
-		    dS1 += 4*b2;
-		    dT1 += 4*b2;
-		    x1++;
-		} else if (T < 0) {
-		    fill_ellipse_points(x, y, x1, y1, pixel);
-		    if (y1 == 0)
-			break;
-		    S += dS1+dS2;
-		    T += dT1+dT2;
-		    dS1 += 4*b2;
-		    dT1 += 4*b2;
-		    dS2 += 4*a2;
-		    dT2 += 4*a2;
-		    x1++;
-		    y1--;
-		} else {
-		    fill_ellipse_points(x, y, x1, y1, pixel);
-		    if (y1 == 0)
-			break;
-		    S += dS2;
-		    T += dT2;
-		    dS2 += 4*a2;
-		    dT2 += 4*a2;
-		    y1--;
-		}
+	return fill_circle(x, y, a, pixel);
+
+    u32 a2 = a*a;
+    u32 b2 = b*b;
+
+    if (a <= b) {
+	u32 x1 = 0;
+	u32 y1 = b;
+	int S = a2*(1-2*b)+2*b2;
+	int T = b2-2*a2*(2*b-1);
+	int dT1 = 4*b2;
+	int dS1 = dT1+2*b2;
+	int dS2 = -4*a2*(b-1);
+	int dT2 = dS2+2*a2;
+
+	while (1) {
+	    if (S < 0) {
+		S += dS1;
+		T += dT1;
+		dS1 += 4*b2;
+		dT1 += 4*b2;
+		x1++;
+	    } else if (T < 0) {
+		fill_ellipse_points(x, y, x1, y1, pixel);
+		if (y1 == 0)
+		    break;
+		S += dS1+dS2;
+		T += dT1+dT2;
+		dS1 += 4*b2;
+		dT1 += 4*b2;
+		dS2 += 4*a2;
+		dT2 += 4*a2;
+		x1++;
+		y1--;
+	    } else {
+		fill_ellipse_points(x, y, x1, y1, pixel);
+		if (y1 == 0)
+		    break;
+		S += dS2;
+		T += dT2;
+		dS2 += 4*a2;
+		dT2 += 4*a2;
+		y1--;
 	    }
-	} else {
-	    u32 x1 = a;
-	    u32 y1 = 0;
-            int S = b2*(1-2*a)+2*a2;
-            int T = a2-2*b2*(2*a-1);
-            int dT1 = 4*a2;
-            int dS1 = dT1+2*a2;
-            int dS2 = -4*b2*(a-1);
-            int dT2 = dS2+2*b2;
-
-	    fill_ellipse_points(x, y, x1, y1, pixel);
-	    do {
-		if (S < 0) {
-		    S += dS1;
-		    T += dT1;
-		    dS1 += 4*a2;
-		    dT1 += 4*a2;
-		    y1++;
-		    fill_ellipse_points(x, y, x1, y1, pixel);
-		} else if (T < 0) {
-		    S += dS1+dS2;
-		    T += dT1+dT2;
-		    dS1 += 4*a2;
-		    dT1 += 4*a2;
-		    dS2 += 4*b2;
-		    dT2 += 4*b2;
-		    x1--;
-		    y1++;
-		    fill_ellipse_points(x, y, x1, y1, pixel);
-		} else {
-		    S += dS2;
-		    T += dT2;
-		    dS2 += 4*b2;
-		    dT2 += 4*b2;
-		    x1--;
-		}
-	    } while (x1 > 0);
 	}
+    } else {
+	u32 x1 = a;
+	u32 y1 = 0;
+	int S = b2*(1-2*a)+2*a2;
+	int T = a2-2*b2*(2*a-1);
+	int dT1 = 4*a2;
+	int dS1 = dT1+2*a2;
+	int dS2 = -4*b2*(a-1);
+	int dT2 = dS2+2*b2;
+
+	fill_ellipse_points(x, y, x1, y1, pixel);
+	do {
+	    if (S < 0) {
+		S += dS1;
+		T += dT1;
+		dS1 += 4*a2;
+		dT1 += 4*a2;
+		y1++;
+		fill_ellipse_points(x, y, x1, y1, pixel);
+	    } else if (T < 0) {
+		S += dS1+dS2;
+		T += dT1+dT2;
+		dS1 += 4*a2;
+		dT1 += 4*a2;
+		dS2 += 4*b2;
+		dT2 += 4*b2;
+		x1--;
+		y1++;
+		fill_ellipse_points(x, y, x1, y1, pixel);
+	    } else {
+		S += dS2;
+		T += dT2;
+		dS2 += 4*b2;
+		dT2 += 4*b2;
+		x1--;
+	    }
+	} while (x1 > 0);
     }
 }