TileWidget: avoid a lot of useless repaintings

This commit is contained in:
Olivier Teulière 2012-01-29 14:35:59 +01:00
parent f6d7661367
commit ebea504aa7
2 changed files with 7 additions and 4 deletions

View file

@ -130,10 +130,8 @@ void BoardWidget::refresh()
{
if (m_game != NULL)
{
// XXX: in the future, this code could be changed to use signals
// emitted from the core. This would allow repainting only the needed
// tiles (the same performance improvement could be done with caching
// in the TileWidget class, though)
// Note: the TileWidget class will redraw the tile only if something
// has changed, to avoid useless repainting.
const Board &board = m_game->getBoard();
for (unsigned int row = BOARD_MIN; row <= BOARD_MAX; ++row)
{

View file

@ -108,6 +108,11 @@ int TileWidget::getSquareSize() const
void TileWidget::tileChanged(const Tile &iTile, bool isJoker, State state)
{
// This avoids a lot of useless redraws
if (m_state == state && m_tile == iTile && m_isJoker == isJoker)
return;
m_state = state;
m_tile = iTile;
m_isJoker = isJoker;
m_state = state;