mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-03-02 01:40:54 -05:00
ext_image_capture_source_v1: wait for capture client before sending frame event
We were sending an output frame event as soon as we were done rendering. As a result, the output would render in a busy loop when a client was using the capture output for frame pacing purposes. Instead, use the request_frame hook introduced in the previous commit to throttle output frame events. Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/4036
This commit is contained in:
parent
f93865ed1f
commit
368dcfb9f6
1 changed files with 3 additions and 15 deletions
|
|
@ -19,7 +19,6 @@ struct scene_node_source {
|
||||||
struct wlr_output output;
|
struct wlr_output output;
|
||||||
struct wlr_scene_output *scene_output;
|
struct wlr_scene_output *scene_output;
|
||||||
|
|
||||||
struct wl_event_source *idle_frame;
|
|
||||||
size_t num_started;
|
size_t num_started;
|
||||||
|
|
||||||
struct wl_listener node_destroy;
|
struct wl_listener node_destroy;
|
||||||
|
|
@ -131,6 +130,9 @@ static void source_stop(struct wlr_ext_image_capture_source_v1 *base) {
|
||||||
static void source_request_frame(struct wlr_ext_image_capture_source_v1 *base,
|
static void source_request_frame(struct wlr_ext_image_capture_source_v1 *base,
|
||||||
bool schedule_frame) {
|
bool schedule_frame) {
|
||||||
struct scene_node_source *source = wl_container_of(base, source, base);
|
struct scene_node_source *source = wl_container_of(base, source, base);
|
||||||
|
if (source->output.frame_pending) {
|
||||||
|
wlr_output_send_frame(&source->output);
|
||||||
|
}
|
||||||
if (schedule_frame) {
|
if (schedule_frame) {
|
||||||
wlr_output_update_needs_frame(&source->output);
|
wlr_output_update_needs_frame(&source->output);
|
||||||
}
|
}
|
||||||
|
|
@ -170,12 +172,6 @@ static void source_update_buffer_constraints(struct scene_node_source *source,
|
||||||
output->swapchain, output->renderer);
|
output->swapchain, output->renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void source_handle_idle_frame(void *data) {
|
|
||||||
struct scene_node_source *source = data;
|
|
||||||
source->idle_frame = NULL;
|
|
||||||
wlr_output_send_frame(&source->output);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool output_test(struct wlr_output *output, const struct wlr_output_state *state) {
|
static bool output_test(struct wlr_output *output, const struct wlr_output_state *state) {
|
||||||
struct scene_node_source *source = wl_container_of(output, source, output);
|
struct scene_node_source *source = wl_container_of(output, source, output);
|
||||||
|
|
||||||
|
|
@ -211,11 +207,6 @@ static bool output_test(struct wlr_output *output, const struct wlr_output_state
|
||||||
static bool output_commit(struct wlr_output *output, const struct wlr_output_state *state) {
|
static bool output_commit(struct wlr_output *output, const struct wlr_output_state *state) {
|
||||||
struct scene_node_source *source = wl_container_of(output, source, output);
|
struct scene_node_source *source = wl_container_of(output, source, output);
|
||||||
|
|
||||||
if (source->idle_frame != NULL) {
|
|
||||||
wlr_log(WLR_DEBUG, "Failed to commit capture output: a frame is still pending");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((state->committed & WLR_OUTPUT_STATE_ENABLED) && !state->enabled) {
|
if ((state->committed & WLR_OUTPUT_STATE_ENABLED) && !state->enabled) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -253,9 +244,6 @@ static bool output_commit(struct wlr_output *output, const struct wlr_output_sta
|
||||||
|
|
||||||
pixman_region32_fini(&full_damage);
|
pixman_region32_fini(&full_damage);
|
||||||
|
|
||||||
source->idle_frame =
|
|
||||||
wl_event_loop_add_idle(output->event_loop, source_handle_idle_frame, source);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue