CFrame paint pessimisation [Windows]

To follow up after some more testing,
My local fix is simple & crude: Use the BeginPaint bounding rect to redraw and completely skip the GetRegionData rects.
This way there is only one search for controls to draw and no double-painting, but still some uncalled-for repaints.

Only 2 line changes.
In win32paint.cpp / Win32Frame::paint() function:

        if (deviceContext)
        {
            deviceContext->setClipRect (updateRect);
++            getFrame()->platformDrawRect(drawContext, updateRect);

--            DWORD len = GetRegionData(rgn, 0, NULL);
++            DWORD len = 0; //GetRegionData(rgn, 0, NULL);  // Skip the region rects Mikado stack

The last line and the following block should ofc be deleted if this stands.

Had to chase around for GetRegionData info.
Feng Yuan “Windows Graphics Programming” (2000), ch 9.6 has a detailed (and convoluted) description of memory layout and warns about memory costs. He suggests using it for bitmap masking and color keying for transparency. Fairly advanced old-school stuff.
(PS now I get it: Remember round windows anyone? A bit cheesy, never quite worked? Those.
There’s a function to get the exclusion region then you can blit from your bitmap and background.)

Wine description of Regions is easier to follow;
Region functions create the widest possible bands from its rects, and returns them strictly sorted by Y first, then X.
See: wine/region.c at d265dd88cd93ce6ffe56c9cfd640b064d7c14e29 · wine-mirror/wine · GitHub

So in my case there’s 1- and 2-pixel bands because some controls have a border, then there’s a same-size but borderless control way off to the left or right.
The control sticking up/down is sliced into 2-3 bands and the full search+paint is applied 2-3 times per call.
This will vary depending on app layouts.

Anyway,
Feeding the dirty rects into InvalidateRect, to tell Windows the area that will be updated, is the right and simple thing to do.
Windows also assumes paint will cover entire smallest rect covering all parts (it’s what we get back in BeginPaint struct).
But while it would be useful to get the original rects back (or even better, the controls themselves), the Region logic has the wrong behavior for the task.

Cheers,
/rasmus