News for hackers. Stuff that matters.
Re:I translated a simple C program to x86_64 and it was slower by saagarjha on Saturday April 25, 2020 @03:11PM (#22980506)
Re:I translated a simple C program to x86_64 and it was slower by cheerlessbog on Saturday April 25, 2020 @03:24PM (#22980617)
Interesting but it left me wondering what was his fast routine for drawing rounded rects. The squarical formula?
Re:I translated a simple C program to x86_64 and it was slower by Someone on Saturday April 25, 2020 @03:57PM (#22980922)
Here’s my guess: the Mac’s drawing routines all did clipping in software. That was accomplished by having drawing of rectangles, circles, ovals, polygons and rounded rectangles (for various operations such as erasing or filling them, drawing a frame along the outside, inverting the bits inside) all come down to:

- compute the set of bits (called a ‘region’) to operate on

- call the appropriate function to erase/fill/… that region

I would guess drawing ovals was done this way:

- create a region for a circle with radius equal to that of the radius of the corners.

- insert horizontal parts to each row of bits in the region to ‘stretch’ the region horizontally into a rounded rectangle that has the correct width, but is only as high as the circle.

- insert vertical parts to each column of bits in the region to ‘stretch’ the region vertically into a rounded rectangle that has the correct width and height.

The first step was identical for the code for drawing circles; the region data structure made the last two operations cheap; they did not require any memory allocations. You had to walk the entire data structure, but for small corner radiuses, it wasn’t that large. Also, one could probably optimize for speed by doing that while creating the region for the circle.

I can’t find a good description of the region data structure, but https://www.folklore.org/StoryView.py?project=Macintosh&stor... might be enough for some to figure out how it, conceptually, worked.

Re:I translated a simple C program to x86_64 and it was slower by pengaru on Saturday April 25, 2020 @04:10PM (#22981025)
My guess is they didn't even need to be fast, just render once when the window is configured and keep a cache of rounded corners in the window system complete with the masks. They're tiny, and symmetrical.
Re:I translated a simple C program to x86_64 and it was slower by Someone on Saturday April 25, 2020 @04:26PM (#22981161)
Compute once when the window is created or resized is what happened, yes, but that doesn’t work when using them for buttons (unlike MS Windows, where every control is a ‘Window’, on Mac OS controls inside a window didn’t have their own drawing context), or when using them for window content (e.g. in a drawing program)

And remember: the original Mac had about 28 kilobytes of RAM free for applications. The system unloaded icons, code and fonts that were available on disk all the time. Few objects were ‘tiny’ at the time.

Re:I translated a simple C program to x86_64 and it was slower by jlokier on Saturday April 25, 2020 @03:30PM (#22980682)
Probably the fastest way to calculate it is the Bresenham circle algorithm. But if there are a lot of roundrects with the same few small corner size (likely in a window system), a table for that size might be better.
Re:I translated a simple C program to x86_64 and it was slower by ngcc_hk on Saturday April 25, 2020 @03:32PM (#22980701)
Always wonder about those round rect