40 #include <QApplication>
51 m_currentPosition(0, 0, 0),
56 m_renderRequestsLock(QMutex::Recursive),
57 m_renderRequestSetLock(QMutex::Recursive),
58 m_precacheRequestsLock(QMutex::Recursive),
59 m_precacheRequestSetLock(QMutex::Recursive),
60 m_textureLoadedLock(QMutex::Recursive)
110 catch(
const std::exception& e)
112 std::cout <<
"An exception occurred queuing a tile to be cached: " << e.what() << std::endl;
129 int sizes[] = {3, 2, 2, 1, 1, 1};
133 for (
int i = 1; i <= 5; i++)
136 if (layer < m_tileSet->LayerCount())
156 int startRow = std::max(0, row - size);
157 int endRow = std::min(layer->
RowCount() - 1, row + size);
158 int startColumn = std::max(0, column - size);
159 int endColumn = std::min(layer->
ColumnCount() - 1, column + size);
161 for (
int c = startColumn; c <= endColumn; c++)
163 for (
int r = startRow; r <= endRow; r++)
178 catch (
const std::exception& e)
180 std::cout <<
"An exception occurred queuing tiles for precaching: " << e.what() << std::endl;
207 catch (
const std::exception& e)
209 std::cout <<
"An exception occurred loading texture: " << e.what() << std::endl;
216 QApplication::postEvent(
m_widget,
new QEvent(QEvent::UpdateRequest));
233 catch (
const std::exception& e)
235 std::cout <<
"An exception occurred unloading texture: " << e.what() << std::endl;
265 if (abs(tile->
Row() - row) <= 3 || abs(tile->
Column() - column) < 3)
276 printf(
"failed to load image\n");
320 catch (
const std::exception& e)
322 std::cout <<
"An exception occurred precaching texture: " << e.what() << std::endl;
331 if (abs(tile->
Row() - row) <= 3 || abs(tile->
Column() - column) <= 3)
341 printf(
"failed to precache load image\n");
362 std::map<int64_t, Tile*>* tiles;
363 p->m_textureLoadedLock.lock();
365 tiles =
new std::map<int64_t, Tile*>(p->m_textureLoaded);
367 p->m_textureLoadedLock.unlock();
369 std::map<int64_t, Tile*>::iterator iter;
371 for (iter = tiles->begin(); iter != tiles->end(); ++iter)
373 Tile* tile = iter->second;
375 p->m_tileSet->GetLayer(tile->
Layer())->GetTileIndex(p->m_currentPosition, row, column);
377 if (abs(tile->
Row() - row) > 6 || abs(tile->
Column() - column) > 6)
379 p->m_renderRequestSetLock.lock();
380 p->m_renderRequestSet.erase(tile->
TileID());
381 p->m_renderRequestSetLock.unlock();
383 p->m_precacheRequestSetLock.lock();
384 p->m_precacheRequestSet.erase(tile->
TileID());
385 p->m_precacheRequestSetLock.unlock();