Restoring drawing performance

This commit is contained in:
Matthias Koefferlein 2026-02-08 08:43:03 +01:00
parent 4a8a75f350
commit 5da83e670d
2 changed files with 15 additions and 19 deletions

View File

@ -1779,13 +1779,6 @@ Layout::end_changes_no_update ()
void void
Layout::force_update () Layout::force_update ()
{ {
// NOTE: the assumption is that either one thread is writing or
// multiple threads are reading. Hence, we do not need to lock hier_dirty() or bboxes_dirty().
// We still do double checking as another thread might do the update as well.
if (! update_needed ()) {
return;
}
tl::MutexLocker locker (&lock ()); tl::MutexLocker locker (&lock ());
force_update_no_lock (); force_update_no_lock ();
} }
@ -1817,18 +1810,23 @@ Layout::force_update_no_lock () const
void void
Layout::update () const Layout::update () const
{ {
tl::MutexLocker locker (&lock ()); // NOTE: this is double checking - which is not inherently thread-safe.
// However, it's so much faster, and the deal is to start multithreaded
// NOTE: the assumption is that either one thread is writing or // reads with an already-updated layout and not to do reading from one thread
// multiple threads are reading. Hence, we do not need to lock hier_dirty() or bboxes_dirty(). // while writing from another. So it's worth the risk.
// We still do double checking as another thread might do the update as well. if (! (hier_dirty () || bboxes_dirty () || prop_ids_dirty ())) {
if (under_construction () || (! hier_dirty () && ! bboxes_dirty () && ! prop_ids_dirty ())) {
return; return;
} }
if (! under_construction ()) { tl::MutexLocker locker (&lock ());
force_update_no_lock ();
// We do double checking here as another thread might do the update as well.
// Checking "under_constrcution" will also prevent recursion in "update".
if (under_construction () || ! (hier_dirty () || bboxes_dirty () || prop_ids_dirty ())) {
return;
} }
force_update_no_lock ();
} }
bool bool

View File

@ -57,7 +57,6 @@ public:
#else #else
// The non-Qt version is a dummy implementation as threading is not supported (yet)
class TL_PUBLIC Mutex class TL_PUBLIC Mutex
{ {
public: public:
@ -91,7 +90,6 @@ public:
class WaitConditionPrivate; class WaitConditionPrivate;
// The non-Qt version is a dummy implementation as threading is not supported (yet)
class TL_PUBLIC WaitCondition class TL_PUBLIC WaitCondition
{ {
public: public: