Skip to content

Add graphics worlds to libQuickDraw - #72

Merged
colemancda merged 29 commits into
masterfrom
feature/quickdraw-gworld
Dec 3, 2026
Merged

colemancda merged 29 commits into
masterfrom
feature/quickdraw-gworld

Conversation

@colemancda

Copy link
Copy Markdown
Member

libQuickDraw gains graphics worlds: offscreen color ports at 1, 2, 4, 8, 16 and 32 bits, built on what Mac OS 9.2.2 did with a new probe (ReferenceTests/Retro68/GWorldCapture.c).

What changed

  • NewGWorld, UpdateGWorld, DisposeGWorld, Get/SetGWorld, the device calls, LockPixels and the other pixel calls.
  • RGBForeColor, RGBBackColor, GetForeColor, GetBackColor, GetCPixel, SetCPixel.
  • The drawing, text, region, polygon and CopyBits calls work in color ports, and CopyBits/CopyMask copy between any depths.
  • Quickdraw.h now declares CGrafPort, GDevice, SProcRec and CProcRec.

28 more functions, so 149 of 305 are implemented.

Engine changes (these affect every Graphite2D user)

  • Colors match indexed tables as Mac OS 9.2.2 did: exact entry first, then each component cut to 4 bits; gray tables by luminance.
  • A foreground that differs from the background but has the same pixel value draws as that value's inverse.
  • The 2-bit and 4-bit standard color tables have corrected values.
  • clipPix and stretchPix had the wrong bits; they are now bits 28 and 29.
  • PixelBuffer.alphaByte chooses the alpha byte written to 32-bit pixels.

Limits

  • The screen is still 1 bit deep, so depth 0 gives a 1-bit world.
  • Pixels never move or get purged.
  • UpdateGWorld keeps the same world and pixel map, and stretchPix does not mix colors as the Mac did.
  • On 64-bit hosts only portRect, visRgn and clipRgn are at the same offsets in GrafPort and CGrafPort; reading pnLoc, txFont and later fields of a world through a GrafPtr gets the wrong field.
  • RGBForeColor on a GrafPort and the main device's flags were not measured.
  • OpenCPort, pixel patterns, palettes, CopyDeepMask and pictures are still stubs.

Testing

  • GWorldCaptureTests replays the probe; 15 lines differ and the test lists each one.
  • Full swift test passes on macOS.
  • macOS and Linux (CMake, swift:6.4-trixie, FreeType off): 305 exports as declared, pure.c 26 checks and drawing.c 58 checks pass.
  • The Swift tests were not run on Linux locally.

Commits are one file each, so intermediate ones may not build on their own.

@colemancda
colemancda merged commit 3352908 into master Dec 3, 2026
3 checks passed
@colemancda
colemancda deleted the feature/quickdraw-gworld branch December 3, 2026 06:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant