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
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 ());
force_update_no_lock ();
}
@ -1817,18 +1810,23 @@ Layout::force_update_no_lock () const
void
Layout::update () const
{
tl::MutexLocker locker (&lock ());
// 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 (under_construction () || (! hier_dirty () && ! bboxes_dirty () && ! prop_ids_dirty ())) {
// NOTE: this is double checking - which is not inherently thread-safe.
// However, it's so much faster, and the deal is to start multithreaded
// reads with an already-updated layout and not to do reading from one thread
// while writing from another. So it's worth the risk.
if (! (hier_dirty () || bboxes_dirty () || prop_ids_dirty ())) {
return;
}
if (! under_construction ()) {
force_update_no_lock ();
tl::MutexLocker locker (&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

View File

@ -57,13 +57,12 @@ public:
#else
// The non-Qt version is a dummy implementation as threading is not supported (yet)
class TL_PUBLIC Mutex
{
public:
Mutex () : m_spinlock () { }
void lock() { m_spinlock.lock(); }
void unlock() { m_spinlock.unlock(); }
void lock () { m_spinlock.lock (); }
void unlock () { m_spinlock.unlock (); }
private:
atomic::spinlock m_spinlock;
};
@ -91,7 +90,6 @@ public:
class WaitConditionPrivate;
// The non-Qt version is a dummy implementation as threading is not supported (yet)
class TL_PUBLIC WaitCondition
{
public: