From: Geert Uytterhoeven <geert@linux-m68k.org>
To: linux-fbdev@vger.kernel.org
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Subject: [PATCH fbtest 07/17] drawops: Refactor generic_draw_ellipse()
Date: Sun, 15 Dec 2024 11:44:58 +0100 [thread overview]
Message-ID: <20241215104508.191237-8-geert@linux-m68k.org> (raw)
In-Reply-To: <20241215104508.191237-1-geert@linux-m68k.org>
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 --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);
}
}
--
2.34.1
next prev parent reply other threads:[~2024-12-15 10:51 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-15 10:44 [PATCH fbtest 00/17] Export feature and large ellipses support Geert Uytterhoeven
2024-12-15 10:44 ` [PATCH fbtest 01/17] Add support for exporting virtual test images Geert Uytterhoeven
2024-12-15 10:44 ` [PATCH fbtest 02/17] tests: Print test description in debug mode Geert Uytterhoeven
2024-12-15 10:44 ` [PATCH fbtest 03/17] Test002: Fix test description Geert Uytterhoeven
2024-12-15 10:44 ` [PATCH fbtest 04/17] drawops: Extract do_circle() Geert Uytterhoeven
2024-12-15 10:44 ` [PATCH fbtest 05/17] drawops: Use "y == 0" in draw_ellipse_points() Geert Uytterhoeven
2024-12-15 10:44 ` [PATCH fbtest 06/17] drawops: Remove always-false check in generic_fill_ellipse() Geert Uytterhoeven
2024-12-15 10:44 ` Geert Uytterhoeven [this message]
2024-12-15 10:44 ` [PATCH fbtest 08/17] drawops: Return early in generic_{draw,fill}_ellipse() Geert Uytterhoeven
2024-12-15 10:45 ` [PATCH fbtest 09/17] drawops: Extract do_ellipse() Geert Uytterhoeven
2024-12-15 10:45 ` [PATCH fbtest 10/17] drawops: Make de in do_circle() unsigned Geert Uytterhoeven
2024-12-15 10:45 ` [PATCH fbtest 11/17] drawops: Make dT1 and dS1 in do_ellipse() unsigned Geert Uytterhoeven
2024-12-15 10:45 ` [PATCH fbtest 12/17] drawops: Fix crash when drawing large ellipses Geert Uytterhoeven
2024-12-15 15:08 ` Helge Deller
2024-12-18 16:29 ` Geert Uytterhoeven
2024-12-18 18:00 ` Helge Deller
2024-12-15 10:45 ` [PATCH fbtest 13/17] tests: Clear frame buffer before each test Geert Uytterhoeven
2024-12-15 10:45 ` [PATCH fbtest 14/17] Make variables that are never negative unsigned Geert Uytterhoeven
2024-12-15 10:45 ` [PATCH fbtest 15/17] test013: Fix off-by-one error in maximum circle calculation Geert Uytterhoeven
2024-12-15 10:45 ` [PATCH fbtest 16/17] visops: Mark fall-through switch case Geert Uytterhoeven
2024-12-15 10:45 ` [PATCH fbtest 17/17] util: Use __attribute__ Geert Uytterhoeven
2024-12-24 13:07 ` [PATCH fbtest 00/17] Export feature and large ellipses support Geert Uytterhoeven
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241215104508.191237-8-geert@linux-m68k.org \
--to=geert@linux-m68k.org \
--cc=linux-fbdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).