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:
parent
1539c75d6d
commit
474e4284d4
3 changed files with 22 additions and 4 deletions
1
TODO
1
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.
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,6 +136,7 @@ private:
|
|||
QVector<PreviewDrawingThread*> _threads;
|
||||
QVector<PreviewChunk*> _chunks;
|
||||
QList<PreviewChunk*> _updateQueue;
|
||||
BasePreview* _lastRendered;
|
||||
QMutex _lock;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue