From 0be12e05b22b62a1800046874933a1532ae0f363 Mon Sep 17 00:00:00 2001 From: ennewalker Date: Sun, 29 Mar 2009 20:46:47 +0000 Subject: Tiles performance improvements to eliminate mouse lag on slower systems. It should redraw the screen far less frequently. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9568 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/tilesdl.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/crawl-ref/source/tilesdl.cc b/crawl-ref/source/tilesdl.cc index 1eebc00ec8..9db08291c6 100644 --- a/crawl-ref/source/tilesdl.cc +++ b/crawl-ref/source/tilesdl.cc @@ -709,6 +709,10 @@ struct cursor_loc && rhs.cy == cy && reg); } + bool operator!=(const cursor_loc &rhs) const + { + return !(*this == rhs); + } Region *reg; int cx, cy; @@ -721,10 +725,11 @@ int TilesFramework::getch_ck() SDL_Event event; cursor_loc cur_loc; cursor_loc tip_loc; + cursor_loc last_loc; int key = 0; - const unsigned int ticks_per_redraw = 16; // 60 FPS = 16.6 ms/frame + const unsigned int ticks_per_redraw = 50; unsigned int last_redraw_tick = 0; unsigned int res = std::max(30, Options.tile_tooltip_ms); @@ -744,6 +749,8 @@ int TilesFramework::getch_ck() { ticks = SDL_GetTicks(); + last_loc = cur_loc; + if (event.type != SDL_USEREVENT) { tiles.clear_text_tags(TAG_CELL_DESC); @@ -871,15 +878,19 @@ int TilesFramework::getch_ck() if (reg->update_tip_text(m_tooltip)) break; } + m_need_redraw = true; } } else { + if (last_loc != cur_loc) + m_need_redraw = true; + m_tooltip.clear(); tip_loc.reset(); } - if (ticks - last_redraw_tick > ticks_per_redraw) + if ((ticks - last_redraw_tick > ticks_per_redraw) && need_redraw()) { redraw(); last_redraw_tick = ticks; -- cgit v1.2.3-54-g00ecf