tl; dr: Render to bitmaps in the background thread in program mode. Draw from bitmaps to display the target in the UI thread in hardware mode.
The best approach that I have been able to find so far is to use background streams with software rendering ( IWICImagingFactory::CreateBitmap and ID2D1Factory::CreateWicBitmapRenderTarget ), and then copy it to the equipment bitmap in the stream using the target equipment rendering through ID2D1RenderTarget::CreateBitmapFromWicBitmap . And then blit using ID2D1RenderTarget::DrawBitmap .
Since paint.net 4.0 does rendering highlighting. When you draw a selection using the lasso tool, it will use a background thread to asynchronously draw a selection outline (the user interface thread does not wait for this to finish). You can get a very complex polygon due to the stroke style and animation. I do it 4 times, where each animation frame has a slightly different offset for the dash bar style.
Obviously, this rendering may take some time, as the polygon becomes more complex (that is, if you keep writing for a while). I have several other special optimizations when you use the Move Selection tool, which allows you to do transforms (rotate, translate, scale): if the background thread has not yet re-mapped the current polygon with the new transformation, then I will display the old bitmap (with current polygon and old transform) with the new transform applied. The allocation scheme may be distorted (scaled) or cropped (moved outside the visible region), while the background stream is gaining momentum, but this is a small price to pay for 60fps responsiveness. This optimization works very well because you cannot change the polygon and transform the selection at the same time.
source share