It looks like you're new here. If you want to get involved, click one of these buttons!
In your threaded rendering approach how do you finally draw the result. The original paint event that triggered the threads is over and you can't draw to a widget outside of a paint event. Do you use a timer to fire a paint event and then use the computed result?
Thanks!
Comments
Yes, basically that is the way it is done.
The basic class implementing that in KLayout is
lay::LayoutCanvas
(layLayoutCanvas.cc
) inLayoutCanvas::update_image
. This class connects to the drawing threads through asynchronous callbacks (signal_transfer_done
,signal_end_of_drawing
)."Asynchronous" means they can be called from any thread. They will be dispatched into the main thread by a mechanism called
deferred execution
in KLayout's source (tl::DeferredExecution
object). That is nothing else than a Qt timer which is used to delegate the execution of a method to the main thread. Today there is "Qt::QueuedConnection" mode which to my understanding works the same way, but wasn't there when KLayout was initiated.If you want to look further, the actual drawing happens inside a thread that is implemented in
layRedrawThreadWorker.cc
andlayRedrawThread.cc
(the names are slighly confusing asRedrawThread
is actually a thread group whileRedrawThreadWorker
is one of the multiple drawing threads).RedrawThreadWorker
regularly callestest_snapshot
which itself callswakeup
fromRedrawThread
after having stashed the current bitmaps for image composition. The latter will triggersignal_transfer_done
and this is the call that is delegated into the main thread and updates the screen image from the bitmaps.Hope that helps,
Matthias