mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-29 05:40:12 -04:00
scene: use output with highest refresh rate for frame pacing
If a surface is mirrored on two outputs, we don't want to pick the first output if the second has a higher refresh rate. Also fixes duplicate frame/feedback events when a surface is added to multiple scenes.
This commit is contained in:
parent
51d051497d
commit
6204fc3278
2 changed files with 24 additions and 7 deletions
|
|
@ -123,6 +123,10 @@ struct wlr_scene_surface {
|
|||
struct {
|
||||
struct wlr_box clip;
|
||||
|
||||
// Output used for frame pacing (surface frame callbacks, presentation
|
||||
// time feedback, etc), may be NULL
|
||||
struct wlr_output *frame_pacing_output;
|
||||
|
||||
struct wlr_addon addon;
|
||||
|
||||
struct wl_listener outputs_update;
|
||||
|
|
@ -178,8 +182,7 @@ struct wlr_scene_buffer {
|
|||
/**
|
||||
* The output that the largest area of this buffer is displayed on.
|
||||
* This may be NULL if the buffer is not currently displayed on any
|
||||
* outputs. This is the output that should be used for frame callbacks,
|
||||
* presentation feedback, etc.
|
||||
* outputs.
|
||||
*/
|
||||
struct wlr_scene_output *primary_output;
|
||||
|
||||
|
|
|
|||
|
|
@ -22,11 +22,25 @@ static double get_surface_preferred_buffer_scale(struct wlr_surface *surface) {
|
|||
return scale;
|
||||
}
|
||||
|
||||
static struct wlr_output *get_surface_frame_pacing_output(struct wlr_surface *surface) {
|
||||
struct wlr_output *frame_pacing_output = NULL;
|
||||
struct wlr_surface_output *surface_output;
|
||||
wl_list_for_each(surface_output, &surface->current_outputs, link) {
|
||||
if (frame_pacing_output == NULL ||
|
||||
surface_output->output->refresh > frame_pacing_output->refresh) {
|
||||
frame_pacing_output = surface_output->output;
|
||||
}
|
||||
}
|
||||
return frame_pacing_output;
|
||||
}
|
||||
|
||||
static void handle_scene_buffer_outputs_update(
|
||||
struct wl_listener *listener, void *data) {
|
||||
struct wlr_scene_surface *surface =
|
||||
wl_container_of(listener, surface, outputs_update);
|
||||
|
||||
surface->frame_pacing_output = get_surface_frame_pacing_output(surface->surface);
|
||||
|
||||
double scale = get_surface_preferred_buffer_scale(surface->surface);
|
||||
wlr_fractional_scale_v1_notify_scale(surface->surface, scale);
|
||||
wlr_surface_set_preferred_buffer_scale(surface->surface, ceil(scale));
|
||||
|
|
@ -60,15 +74,15 @@ static void handle_scene_buffer_output_sample(
|
|||
struct wlr_scene_surface *surface =
|
||||
wl_container_of(listener, surface, output_sample);
|
||||
const struct wlr_scene_output_sample_event *event = data;
|
||||
struct wlr_scene_output *scene_output = event->output;
|
||||
if (surface->buffer->primary_output != scene_output) {
|
||||
struct wlr_output *output = event->output->output;
|
||||
if (surface->frame_pacing_output != output) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event->direct_scanout) {
|
||||
wlr_presentation_surface_scanned_out_on_output(surface->surface, scene_output->output);
|
||||
wlr_presentation_surface_scanned_out_on_output(surface->surface, output);
|
||||
} else {
|
||||
wlr_presentation_surface_textured_on_output(surface->surface, scene_output->output);
|
||||
wlr_presentation_surface_textured_on_output(surface->surface, output);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -77,7 +91,7 @@ static void handle_scene_buffer_frame_done(
|
|||
struct wlr_scene_surface *surface =
|
||||
wl_container_of(listener, surface, frame_done);
|
||||
struct wlr_scene_frame_done_event *event = data;
|
||||
if (surface->buffer->primary_output != event->output) {
|
||||
if (surface->frame_pacing_output != event->output->output) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue