QuickDraw

QuickDraw was the 2D graphics library and associated application programming interface (API) which is a core part of classic Mac OS.

[1] QuickDraw still existed as part of the libraries of Mac OS X, but had been largely superseded by the more modern Quartz graphics system.

A raster system requires much less processing power however, and was the prevailing paradigm at the time that QuickDraw was developed.

This originally simplified the API, since all operations pertained to "the current port," but as the OS developed, this use of global state has also made QuickDraw much harder to integrate with modern design approaches such as multi-threading and pre-emptive multitasking.

Note that, because the pen is rectangular and axis-aligned, diagonal lines will end up thicker than horizontal or vertical ones.

An important feature of QuickDraw was support for transfer modes, which governed how a destination pixel value was related to its previous value and the color of the object being drawn.

They define an arbitrary set of pixels, rather like a bitmap, but in a compressed form which can be very rapidly manipulated in complex ways.

Although regions could allow powerful graphic manipulations they are limited by the current implementation that restricts the maximum region data storage size to a sixteen bit value and so are not practical as a general-purpose drawing composition tool and practical use at high resolution is also restricted.

Regions underpin the rest of QuickDraw, permitting clipping to arbitrary shapes, essential for the implementation of multiple overlapping windows.

The internal structure of a region, other than the storage length and its bounding rectangle, is opaque - there are no Apple-published documents available, though the mechanism is outlined in the patent.

(Bitmaps may also be rotated using well known methods, but with various degrees of image degradation depending upon angle chosen, the storage and processor cycles available to the operation, and the complexity of the algorithm.)

Apple has recently (in the Carbon API) defined regions as an opaque structure under some program compilation options.

An entire BitMap (or PixMap, when referring to color images) may be copied from one GrafPort to another, with scaling and clipping.

QuickDraw provides a similar blitting function which is designed to implement scrolling within a GrafPort - the image in the port can be shifted to a new location without scaling (but with clipping if desired).

Each graphics primitive operation is vectored through the StdProcs, a series of function pointers stored in the GrafPort.

In this way, QuickDraw can be rendered using PostScript, a fact that enabled the Macintosh to practically invent desktop publishing.

While convenient, this made it easy to write erroneous code that passed an offscreen graphics port into API that expected a full-blown window.

The use of these two high bits would come back to haunt QuickDraw later, as it forced a maximum row width of just 4,095 on 32-bit PixMaps, which became problematic for high-resolution graphics work.

The architecture of QuickDraw had always allowed the creation of GrafPorts and their associated BitMaps or PixMaps "offscreen", where graphics could be composed in memory without it being visible immediately on the screen.

This could be error-prone, as it involved three or more separate and fairly complex data structures (CGrafPort, PixMap and GDevice, and for indexed devices, the color look-up table and its inverse).

The video buffer (PixMap) of a GWorld could be stored in main memory, or when available in unused parts of video ram where copying to the screen could be optimized for speed by avoiding the need to transfer a large amount of pixel data across the main memory bus.

After this, apart from back-end changes to optimize for new processor architectures (PowerPC), QuickDraw remained largely unchanged throughout the rest of the life of the classic Mac OS.