the ideology
what the lib refuses to do, and why that is most of what makes it predictable
five rules. everything else in the lib falls out of them
1. the draw layer only sees a pointer and a stride
it never knows where the pixels end up
surface_t surf = presenter.begin(); // a pointer, a stride, a size, borrowed for this frame
renderer.begin_frame(surf);
... draw ...
renderer.end_frame();
presenter.end(dirty); // puts it on screenthat one rule is why the same drawing code goes out three different ways, and why a fourth would be a new file rather than a rewrite
| path | how |
|---|---|
| layered | UpdateLayeredWindow |
| opaque | BitBlt |
| dcomp | a composition swapchain |
the seam breaks the moment drawing code touches gdi or dxgi. there is no
windows.hin the blend2d backend at all, deliberately
2. every pixel is ours
hand drawn, no native controls anywhere, the titlebar included. a chromed window keeps the native frame for aero snap and win+arrows, then eats the whole thing as client area and draws its own
the cost is that we own every button, every scrollbar and every focus ring. the payoff is that a widget and an app window look like the same product, on any windows version
3. retained, not immediate
controls own their bounds and state and live in a tree
the deciding case is idle cost. the countdown bar changes once a day. retained draws it once and then costs nothing until tomorrow. immediate burns a core redrawing an identical bar forever
everything else follows from it, the dirty box, the cached brushes and paths, the 0.054ms hover repaint
4. the c abi is a shell over the c++, never the reverse
stock ahk finns ahk build c++ app
| | |
c abi + DllCall a built-in class |
+---------------------+---------------------+
|
c++ apithree consumers, one core. the c++ side is the lib and the exports are just one of its callers
so the exports get designed ahk first even though the c++ comes first. no export blocks, no export runs a
loop of its own, events queue rather than calling back, and every struct layout is static_asserted
5. the lib never owns a thread
a window is created on whichever thread calls in, and pumped by whoever wants to drive it
| entry | for |
|---|---|
pump_once() | a host with its own loop |
run(host) | an app that is the window, blocks until close |
spawn_ui_thread(desc) | a script that wants a window up while it carries on |
host pumped is the default. a window that freezes because the script is busy is honest feedback, and it is how every native app behaves
what it will not do
| no | why |
|---|---|
| no gdi+ | dropped, not ported |
| no blur | blend2d has no effects pipeline, shadows are stacked translucent rings |
| no subpixel text | grayscale aa only, so text sits a touch lighter than cleartype |
| no variable font axes | blend2d never implemented them and may never, a synthetic stroke stands in for weight |
| no threads in blend2d | 4 threads buys 16% on a full repaint and costs 77% on a dirty rect |