diff --git a/TODO b/TODO index 520e9c0..eff4e67 100644 --- a/TODO +++ b/TODO @@ -28,7 +28,6 @@ Technology Preview 2 : - Fix "RGB parameters out of range" (and segfault) on preview while moving render params fast in render tab. => May need to change the updateData system. => Previews need to be paused while updating data. -- When there are two previews in the same view, balance rendering between the two. - Lock some previews together (eg: terrain height and colored preview). - Find a new licence. diff --git a/gui_qt/basepreview.cpp b/gui_qt/basepreview.cpp index da70358..9a357cb 100644 --- a/gui_qt/basepreview.cpp +++ b/gui_qt/basepreview.cpp @@ -25,6 +25,11 @@ public: _alive = true; } + inline BasePreview* preview() + { + return _preview; + } + inline bool isOnFront() { return _preview->isVisible() && _preview->window()->isActiveWindow(); @@ -132,6 +137,7 @@ PreviewDrawingManager::PreviewDrawingManager() { _thread_count = 1; } + _lastRendered = NULL; } void PreviewDrawingManager::startThreads() @@ -201,7 +207,7 @@ void PreviewDrawingManager::updateChunks(BasePreview* preview) chunk->update(); _lock.lock(); if (!_updateQueue.contains(chunk)) - { + { _updateQueue.prepend(chunk); } _lock.unlock(); @@ -220,7 +226,7 @@ void PreviewDrawingManager::updateAllChunks() chunk->update(); _lock.lock(); if (!_updateQueue.contains(chunk)) - { + { _updateQueue.prepend(chunk); } _lock.unlock(); @@ -236,12 +242,24 @@ void PreviewDrawingManager::performOneThreadJob() _lock.lock(); if (!_updateQueue.isEmpty()) { - chunk = _updateQueue.takeFirst(); + for (int i = _updateQueue.size(); i > 0; i--) + { + chunk = _updateQueue.takeFirst(); + if (chunk && i > 1 && chunk->preview() == _lastRendered) + { + _updateQueue.append(chunk); + } + else + { + break; + } + } } _lock.unlock(); if (chunk) { + _lastRendered = chunk->preview(); chunk->render(); } } diff --git a/gui_qt/basepreview.h b/gui_qt/basepreview.h index 52eba54..e5f9d58 100644 --- a/gui_qt/basepreview.h +++ b/gui_qt/basepreview.h @@ -136,6 +136,7 @@ private: QVector _threads; QVector _chunks; QList _updateQueue; + BasePreview* _lastRendered; QMutex _lock; };