drawops: Fix crash when drawing large ellipses

"test002" crashes when run with a display resolution of e.g. 2560x1440
pixels, due to 32-bit overflow in the ellipse drawing routine.

Fix this by creating a copy that uses 64-bit arithmetic.  Use a
heuristic to pick either the 32-bit or the 64-bit version, to avoid the
overhead of the 64-bit version on small systems with small displays.
On ARM Cortex-A9, draw_ellipse(400, 240, 300, 239, ...) with a dummy
(empty) set_pixel() method using the 64-bit version takes 44% longer
than the 32-bit version.

Replace (unsigned) int by u32/s32 in the 32-bit version for clarity.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
2 files changed