pausing TileRenderer and canceling all tiles in progress upon GUI interaction to avoid extremely expensive glReadPixels.

This commit is contained in:
rachytski 2012-02-14 17:43:56 +04:00 committed by Alex Zolotarev
parent 99f4ff8382
commit e89ba4e44e
3 changed files with 42 additions and 4 deletions

View file

@ -31,7 +31,8 @@ TileRenderer::TileRenderer(
m_skinName(skinName),
m_bgColor(bgColor),
m_sequenceID(0),
m_isExiting(false)
m_isExiting(false),
m_isPaused(false)
{
m_resourceManager = rm;
m_primaryContext = primaryRC;
@ -139,6 +140,9 @@ void TileRenderer::DrawTile(core::CommandsQueue::Environment const & env,
Tiler::RectInfo const & rectInfo,
int sequenceID)
{
if (m_isPaused)
return;
/// commands from the previous sequence are ignored
if (sequenceID < m_sequenceID)
return;
@ -250,8 +254,6 @@ void TileRenderer::DrawTile(core::CommandsQueue::Environment const & env,
FinishTile(rectInfo);
double duration = timer.ElapsedSeconds();
if (env.isCancelled())
{
if (!m_isExiting)
@ -262,7 +264,7 @@ void TileRenderer::DrawTile(core::CommandsQueue::Environment const & env,
tileInfoLayer,
frameScreen,
rectInfo,
duration,
0,
paintEvent->isEmptyDrawing()));
}
@ -335,6 +337,8 @@ void TileRenderer::FinishTile(Tiler::RectInfo const & rectInfo)
m_tilesInProgress.erase(rectInfo);
}
void TileRenderer::SetIsPaused(bool flag)
{
m_isPaused = flag;
}

View file

@ -57,6 +57,8 @@ protected:
int m_sequenceID;
bool m_isExiting;
bool m_isPaused;
threads::Mutex m_tilesInProgressMutex;
set<Tiler::RectInfo> m_tilesInProgress;
@ -106,4 +108,5 @@ public:
void StartTile(Tiler::RectInfo const & rectInfo);
void FinishTile(Tiler::RectInfo const & rectInfo);
void SetIsPaused(bool flag);
};

View file

@ -297,11 +297,42 @@ TileRenderer & TilingRenderPolicyST::GetTileRenderer()
void TilingRenderPolicyST::StartScale()
{
m_isScaling = true;
m_tileRenderer->SetIsPaused(true);
m_tileRenderer->CancelCommands();
}
void TilingRenderPolicyST::StopScale()
{
m_isScaling = false;
m_tileRenderer->SetIsPaused(false);
m_doForce = true;
RenderPolicy::StopScale();
}
void TilingRenderPolicyST::StartDrag()
{
m_tileRenderer->SetIsPaused(true);
m_tileRenderer->CancelCommands();
}
void TilingRenderPolicyST::StopDrag()
{
m_tileRenderer->SetIsPaused(false);
m_doForce = true;
RenderPolicy::StopDrag();
}
void TilingRenderPolicyST::StartRotate(double a, double timeInSec)
{
m_tileRenderer->SetIsPaused(true);
m_tileRenderer->CancelCommands();
}
void TilingRenderPolicyST::StopRotate(double a, double timeInSec)
{
m_tileRenderer->SetIsPaused(false);
m_doForce = true;
RenderPolicy::StopRotate(a, timeInSec);
}
bool TilingRenderPolicyST::IsTiling() const