refharness/ #
The pixel reference: real Windows XP draws visual-style parts, and XPlasma's renderer has to match what comes back. PLAN.md §7.
| File | Runs on | What |
|---|---|---|
vm.sh |
host | Starts VirtualBox's VM xp from a live snapshot (clean: Luna; classic: Windows Classic), so every run begins at the same settled desktop and keeps nothing. |
vm.py |
host | Drives the VM through VirtualBox's API (vboxapi): screendump, type, key, run, click, drag, restore, wait, powerdown; discs in and out. The pointer is a USB tablet: absolute screen pixels, no Guest Additions. |
reference.py |
host | Runs a job: builds an ISO, puts it in XP's CD drive, XP autoruns it, results come back over HTTP, and the black/white BMP pairs become RGBA PNGs. |
guest.py |
host | The same transport for any program: carries files in, runs a command, brings a directory back (guest.py OUTDIR FILE... -- CMD...). |
uxdump.c |
XP | Draws class part state w h with real uxtheme, over black and over white, and records uxtheme's metrics. Loads non-applied styles through uxtheme's ordinals 2/3/16 (OpenThemeFile, CloseThemeFile, OpenThemeDataFromFile). |
xpmeasure.c |
XP | Numbers no BMP carries: GetTextExtentPoint32W/GetCharWidth32W/GetTextMetricsW for a font at a given height, and the tray's and Start button's GetWindowRects, ideal size and text margin. |
xptaskbar.c |
XP | The taskbar's windows as Explorer lays them out under the applied style: the tray, its rebar, the task buttons' toolbar and the Start button, rects and sizes. |
xput.c |
XP | PUTs a directory's files to the host (10.0.2.2:8765). |
build.sh |
host | Cross-compiles both with Clang and LLD against mingw-w64's headers and import libraries (cmake/sdk/mingw.cmake): 32-bit, no C runtime (mingw-w64 now links the UCRT, which XP lacks), XP 5.1 subsystem. |
refharness/build.sh
refharness/vm.sh [classic] # restore and start (≈5 s, then ≈15 s to settle)
.venv/bin/python3 refharness/vm.py wait
.venv/bin/python3 refharness/reference.py job.txt out/ --style path/to/Royale.msstyles
The VM (2026-10-24): XP Professional SP3 from the CD image Setup downloads,
installed by VirtualBox's unattended setup; 512 MB, IDE disk, PCnet NIC, NAT,
USB tablet; logs in as Administrator (password xp) at 1024 x 768 32-bit;
Security Center alerts, Automatic Updates, the screensaver and power-down
off; the CD drive empty. The snapshots are live, so a restore lands at the
running desktop.
A job:
style - # the applied style
part Button 1 1 75 23
style {style:Royale.msstyles} NormalColor NormalSize # a style by file
part Button 1 2 75 23
Outputs are prefixed s<N>_ by style section (s1 = the first style line).
A class may be Sub::Class (part Start::Button 1 1 99 32): uxdump applies it
the way applications do -- SetWindowTheme(hwnd, Sub, NULL), then the plain
class -- and names the files Sub--Class.
Two directives measure a window rather than a part:
frame 400 300 # ordinary overlapped window; 400 300 tool or max
partat Window 18 1 10 10 21 21 61 41 # class part state x y w h canvasW canvasH
frame records user32's WM_NCHITTEST rectangles for close/min/max/sysmenu
and uxtheme's TS_MIN/TS_TRUE/TS_DRAW sizes and TMT_OFFSET/TMT_OFFSETTYPE
for those parts, then saves the window (non-client included) as
frame_<w>x<h><kind>.bmp. partat draws a part into a rect at (x, y) on a
larger black canvas. A direct DrawThemeBackground clips to that rect; the
window manager's caption path does not clip a button glyph to the slot, so do
not read the partat edges as the real caption's clipping.
Stock XP opens only Microsoft-signed styles; measuring a third-party one needs a VM whose uxtheme has been patched to accept it.
What we've learned from it #
-
Caption buttons: each is drawn in
SM_CXSIZE - 4bySM_CYSIZE - 4(the width following the close button art's proportions), atframe + 2from the top-right, 2 px apart, close included (Luna 21 x 21, Aero Vista 46 x 21). The glyph is centred in that rect inset by ContentMargins, negatives included, and isn't clipped to it; close is painted first. Offset/OffsetType aren't read. The hit rects are 1-2 px bigger. Details in docs/caption-buttons.md. -
A
Sub::Classis complete before its class: XP drawsStart::Button's push button (part 1) from[Start::Button], a class-level section, rather than from[Button.PushButton]-- not Wine's order. -
The taskbar (Luna, 800 x 600): 30px; task buttons are
TaskBand::Toolbarbuttons the full height of it (the checked frame for the active window); the Start button is 99 x 32 from the bar's top (2px off the screen), the flag (explorer.exe bitmap 143) at its content's left, centred. -
Windows Classic (Windows Standard, after restarting explorer so the taskbar lays itself out afresh): the taskbar is 30px too, its top edge Light3D then the highlight; task buttons are 22px push buttons 4px down; the Start button is a 22px push button at (2, 4) with bitmap 176 (16 x 16) 2px in and "Start" in bold Tahoma, drawn bi-level as Tahoma's gasp table asks. (Switching to Classic live left a 34px bar until explorer restarted.)
-
Transport (from the earlier QEMU VM, and still how it's done): QEMU's read-write
vvfatcrashed on the guest's first write ("cluster 0 used more than once"), so jobs go in on an ISO and results come out over HTTP. A round trip takes about 2 s. -
Semi-transparent pixels: recovering RGBA from the two renders is only exact to ±1 per channel (XP blends premultiplied). Compare composited renders, ours over black and white against uxdump's BMPs, not un-premultiplied RGBA.
-
uxtheme stretches without filtering. On Royale's push button every opaque pixel of a naive nine-slice already matches; the ±1 differences sit on the semi-transparent outer ring and come from filtering plus rounding.