export-dmabuf: wait for the frame to be ready, send timestamp
This commit is contained in:
parent
5ba1a9af56
commit
e26f4dff98
|
@ -11,6 +11,8 @@ struct wlr_export_dmabuf_frame_v1 {
|
|||
struct wl_list link;
|
||||
|
||||
struct wlr_output *output;
|
||||
|
||||
struct wl_listener output_swap_buffers;
|
||||
};
|
||||
|
||||
struct wlr_export_dmabuf_manager_v1 {
|
||||
|
|
|
@ -82,7 +82,7 @@ struct wlr_output {
|
|||
struct {
|
||||
struct wl_signal frame;
|
||||
struct wl_signal needs_swap;
|
||||
struct wl_signal swap_buffers;
|
||||
struct wl_signal swap_buffers; // wlr_output_event_swap_buffers
|
||||
struct wl_signal enable;
|
||||
struct wl_signal mode;
|
||||
struct wl_signal scale;
|
||||
|
@ -108,6 +108,12 @@ struct wlr_output {
|
|||
void *data;
|
||||
};
|
||||
|
||||
struct wlr_output_event_swap_buffers {
|
||||
struct wlr_output *output;
|
||||
struct timespec *when;
|
||||
pixman_region32_t *damage;
|
||||
};
|
||||
|
||||
struct wlr_surface;
|
||||
|
||||
void wlr_output_enable(struct wlr_output *output, bool enable);
|
||||
|
|
|
@ -30,9 +30,25 @@ static const struct zwlr_export_dmabuf_frame_v1_interface frame_impl = {
|
|||
static void frame_handle_resource_destroy(struct wl_resource *resource) {
|
||||
struct wlr_export_dmabuf_frame_v1 *frame = frame_from_resource(resource);
|
||||
wl_list_remove(&frame->link);
|
||||
wl_list_remove(&frame->output_swap_buffers.link);
|
||||
free(frame);
|
||||
}
|
||||
|
||||
static void frame_output_handle_swap_buffers(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct wlr_export_dmabuf_frame_v1 *frame =
|
||||
wl_container_of(listener, frame, output_swap_buffers);
|
||||
struct wlr_output_event_swap_buffers *event = data;
|
||||
|
||||
wl_list_remove(&frame->output_swap_buffers.link);
|
||||
wl_list_init(&frame->output_swap_buffers.link);
|
||||
|
||||
uint32_t tv_sec_hi = event->when->tv_sec << 32;
|
||||
uint32_t tv_sec_lo = event->when->tv_sec & 0xFFFFFFFF;
|
||||
zwlr_export_dmabuf_frame_v1_send_ready(frame->resource,
|
||||
tv_sec_hi, tv_sec_lo, event->when->tv_nsec);
|
||||
}
|
||||
|
||||
|
||||
static const struct zwlr_export_dmabuf_manager_v1_interface manager_impl;
|
||||
|
||||
|
@ -87,7 +103,7 @@ static void manager_handle_capture_output(struct wl_client *client,
|
|||
|
||||
uint32_t frame_flags = 0;
|
||||
uint32_t mod_high = attribs.modifier[0] >> 32;
|
||||
uint32_t mod_low = attribs.modifier[0];
|
||||
uint32_t mod_low = attribs.modifier[0] & 0xFFFFFFFF;
|
||||
|
||||
zwlr_export_dmabuf_frame_v1_send_frame(frame->resource,
|
||||
output->width, output->height, output->scale, output->transform,
|
||||
|
@ -106,9 +122,8 @@ static void manager_handle_capture_output(struct wl_client *client,
|
|||
attribs.offset[i], attribs.stride[i]);
|
||||
}
|
||||
|
||||
// TODO: wait for the frame to be ready
|
||||
// TODO: timestamps
|
||||
zwlr_export_dmabuf_frame_v1_send_ready(frame->resource, 0, 0, 0);
|
||||
frame->output_swap_buffers.notify = frame_output_handle_swap_buffers;
|
||||
wl_signal_add(&output->events.swap_buffers, &frame->output_swap_buffers);
|
||||
}
|
||||
|
||||
static const struct zwlr_export_dmabuf_manager_v1_interface manager_impl = {
|
||||
|
|
|
@ -467,7 +467,12 @@ bool wlr_output_swap_buffers(struct wlr_output *output, struct timespec *when,
|
|||
output->idle_frame = NULL;
|
||||
}
|
||||
|
||||
wlr_signal_emit_safe(&output->events.swap_buffers, damage);
|
||||
struct wlr_output_event_swap_buffers event = {
|
||||
.output = output,
|
||||
.when = when,
|
||||
.damage = damage,
|
||||
};
|
||||
wlr_signal_emit_safe(&output->events.swap_buffers, &event);
|
||||
|
||||
int width, height;
|
||||
wlr_output_transformed_resolution(output, &width, &height);
|
||||
|
|
Loading…
Reference in New Issue