1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-24 00:23:27 +00:00

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.
This commit is contained in:
Avi Halachmi (:avih) 2021-07-16 10:37:41 +03:00 committed by avih
parent 50280197e2
commit 59c10274b4

View File

@ -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