AuburnSounds / Dplug

Make VST2 / VST3 / AU / AAX / CLAP / LV2 / FLP plug-ins for Linux/macOS/Windows, using D.
https://dplug.org/
Other
490 stars 32 forks source link

Towards solving the gordian knot of dirty rectangles in GUIGraphics #597

Open p0nce opened 3 years ago

p0nce commented 3 years ago

In IWindowListener, the following functions are guaranteed to be called non-concurrently:

getDirtyRectangle semantics is that once you have pulled the dirtyRectangle, you commit to have it mark as dirty to the OS, and consequent onDraw ensues with the proper WM_PAINT / dirtied area.

Try to see if there is potential conflict with: getDirtyRectangle then onResized then onResized since it may lead to the pending rect being abandoned.

p0nce commented 3 years ago

Shouldn't be an issue inside the Window implementation since we can expect the OS to send an Expose/WM_PAINT event for the whole window in case of resize (Linux also?)

p0nce commented 3 years ago

The high-level overview is that there are two places (for both Raw and PBR layers) where dirty rects can live:

and that breaks atomicity badly.

Those things should probably be merged, but doing that would also require that the dirty lists in UIContext are synchronized, then the audio thread would not be able to call them (only onAnimate), and onAnimate can currently be concurrent with other IWindowListener functions.

But at least we have a long-term plan lol.

p0nce commented 3 years ago

A good way to stress resizing is to override checkSizeConstraint in the VST3 client to always return true (well, except for REAPER on linux + macOS see #559 )

p0nce commented 3 years ago

Ideally would need another list of rects apart _rectsToUpdateDisjointedRaw/_rectsToUpdateDisjointedPBR from in "onDraw", that deals with resized rect and borders. (but can eliminate all races without doing that).