core: don't request vblank events when we are not rendering
Previously everytime we receive a vblank event, we always request a new one. This made the logic somewhat simpler. But this generated many useless vblank events, and wasted power. We only need vblank events for two things: 1. after we rendered a frame, we need to know when it has been displayed on the screen. 2. estimating the refresh rate. This commit makes sure we only request vblank events when it's actually needed. Fixes #1079 Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
12
src/x.c
12
src/x.c
@@ -10,6 +10,7 @@
|
||||
#include <xcb/composite.h>
|
||||
#include <xcb/damage.h>
|
||||
#include <xcb/glx.h>
|
||||
#include <xcb/present.h>
|
||||
#include <xcb/randr.h>
|
||||
#include <xcb/render.h>
|
||||
#include <xcb/sync.h>
|
||||
@@ -777,6 +778,17 @@ err:
|
||||
return false;
|
||||
}
|
||||
|
||||
void x_request_vblank_event(session_t *ps, uint64_t msc) {
|
||||
if (ps->vblank_event_requested) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto cookie =
|
||||
xcb_present_notify_msc(ps->c.c, session_get_target_window(ps), 0, msc, 0, 0);
|
||||
set_cant_fail_cookie(&ps->c, cookie);
|
||||
ps->vblank_event_requested = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a struct conv to a X picture convolution filter, normalizing the kernel
|
||||
* in the process. Allow the caller to specify the element at the center of the kernel,
|
||||
|
||||
Reference in New Issue
Block a user