paysages : Preview rendering is balanced when two previews are visible.

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@366 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2012-06-27 13:05:57 +00:00 committed by ThunderK
parent 1539c75d6d
commit 474e4284d4
3 changed files with 22 additions and 4 deletions

1
TODO
View file

@ -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. - 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. => May need to change the updateData system.
=> Previews need to be paused while updating data. => 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). - Lock some previews together (eg: terrain height and colored preview).
- Find a new licence. - Find a new licence.

View file

@ -25,6 +25,11 @@ public:
_alive = true; _alive = true;
} }
inline BasePreview* preview()
{
return _preview;
}
inline bool isOnFront() inline bool isOnFront()
{ {
return _preview->isVisible() && _preview->window()->isActiveWindow(); return _preview->isVisible() && _preview->window()->isActiveWindow();
@ -132,6 +137,7 @@ PreviewDrawingManager::PreviewDrawingManager()
{ {
_thread_count = 1; _thread_count = 1;
} }
_lastRendered = NULL;
} }
void PreviewDrawingManager::startThreads() void PreviewDrawingManager::startThreads()
@ -235,13 +241,25 @@ void PreviewDrawingManager::performOneThreadJob()
chunk = NULL; chunk = NULL;
_lock.lock(); _lock.lock();
if (!_updateQueue.isEmpty()) if (!_updateQueue.isEmpty())
{
for (int i = _updateQueue.size(); i > 0; i--)
{ {
chunk = _updateQueue.takeFirst(); chunk = _updateQueue.takeFirst();
if (chunk && i > 1 && chunk->preview() == _lastRendered)
{
_updateQueue.append(chunk);
}
else
{
break;
}
}
} }
_lock.unlock(); _lock.unlock();
if (chunk) if (chunk)
{ {
_lastRendered = chunk->preview();
chunk->render(); chunk->render();
} }
} }

View file

@ -136,6 +136,7 @@ private:
QVector<PreviewDrawingThread*> _threads; QVector<PreviewDrawingThread*> _threads;
QVector<PreviewChunk*> _chunks; QVector<PreviewChunk*> _chunks;
QList<PreviewChunk*> _updateQueue; QList<PreviewChunk*> _updateQueue;
BasePreview* _lastRendered;
QMutex _lock; QMutex _lock;
}; };