summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorAvi Halachmi (:avih) <avihpit@yahoo.com>2021-07-16 10:37:41 +0300
committeravih <avih@users.noreply.github.com>2021-07-19 22:06:50 +0300
commit59c10274b402c7fcca5d2765cb38e535e17907c2 (patch)
treed53bd19691d1a738acc1da733deb3b3bc45bb16f /player
parent50280197e26e83210d63165572b6748e329d140f (diff)
downloadmpv-59c10274b402c7fcca5d2765cb38e535e17907c2.tar.bz2
mpv-59c10274b402c7fcca5d2765cb38e535e17907c2.tar.xz
stats.lua: scroll: allow throttling page-rebuild (no-op)
Typically the current page is rebuilt and rendered once per second, howeve, scrolling can invoke the rebuild function very frequently, even at a rate which is too fast for the rebuild function to keep up. This can result in high CPU usage and input lag. This commit adds an argument to the page-rebuild function, letting it know whether or not it's called following a scroll keypress, thus allowing it to cache intermediate data so that it doesn't have to re-calculate the whole page from scratch. This additional argument is unused currently, but it could be useful for the internal performance page - which can be relatively heavy.
Diffstat (limited to 'player')
-rw-r--r--player/lua/stats.lua9
1 files changed, 5 insertions, 4 deletions
diff --git a/player/lua/stats.lua b/player/lua/stats.lua
index 653a367b77..93dc453da4 100644
--- a/player/lua/stats.lua
+++ b/player/lua/stats.lua
@@ -838,11 +838,12 @@ local function record_data(skip)
end
-- Call the function for `page` and print it to OSD
-local function print_page(page)
+local function print_page(page, after_scroll)
if o.persistent_overlay then
- mp.set_osd_ass(0, 0, pages[page].f())
+ mp.set_osd_ass(0, 0, pages[page].f(after_scroll))
else
- mp.osd_message(pages[page].f(), display_timer.oneshot and o.duration or o.redraw_delay + 1)
+ mp.osd_message(pages[page].f(after_scroll),
+ display_timer.oneshot and o.duration or o.redraw_delay + 1)
end
end
@@ -854,7 +855,7 @@ end
local function scroll_delta(d)
if display_timer.oneshot then display_timer:kill() ; display_timer:resume() end
pages[curr_page].offset = (pages[curr_page].offset or 1) + d
- print_page(curr_page)
+ print_page(curr_page, true)
end
local function scroll_up() scroll_delta(-o.scroll_lines) end
local function scroll_down() scroll_delta(o.scroll_lines) end