aboutsummaryrefslogtreecommitdiff
path: root/include/wlr
diff options
context:
space:
mode:
Diffstat (limited to 'include/wlr')
-rw-r--r--include/wlr/backend.h4
-rw-r--r--include/wlr/backend/interface.h2
-rw-r--r--include/wlr/interfaces/wlr_output.h2
-rw-r--r--include/wlr/types/meson.build9
-rw-r--r--include/wlr/types/wlr_output.h32
-rw-r--r--include/wlr/types/wlr_presentation_time.h59
6 files changed, 104 insertions, 4 deletions
diff --git a/include/wlr/backend.h b/include/wlr/backend.h
index dfb8d2a8..54f2b5e8 100644
--- a/include/wlr/backend.h
+++ b/include/wlr/backend.h
@@ -62,5 +62,9 @@ struct wlr_renderer *wlr_backend_get_renderer(struct wlr_backend *backend);
* Might return NULL for backends that don't use a session.
*/
struct wlr_session *wlr_backend_get_session(struct wlr_backend *backend);
+/**
+ * Returns the clock used by the backend for presentation feedback.
+ */
+clockid_t wlr_backend_get_presentation_clock(struct wlr_backend *backend);
#endif
diff --git a/include/wlr/backend/interface.h b/include/wlr/backend/interface.h
index 2c300709..4a6a5cbb 100644
--- a/include/wlr/backend/interface.h
+++ b/include/wlr/backend/interface.h
@@ -10,6 +10,7 @@
#define WLR_BACKEND_INTERFACE_H
#include <stdbool.h>
+#include <time.h>
#include <wlr/backend.h>
#include <wlr/render/egl.h>
@@ -18,6 +19,7 @@ struct wlr_backend_impl {
void (*destroy)(struct wlr_backend *backend);
struct wlr_renderer *(*get_renderer)(struct wlr_backend *backend);
struct wlr_session *(*get_session)(struct wlr_backend *backend);
+ clockid_t (*get_presentation_clock)(struct wlr_backend *backend);
};
/**
diff --git a/include/wlr/interfaces/wlr_output.h b/include/wlr/interfaces/wlr_output.h
index bfb3bc9d..52581768 100644
--- a/include/wlr/interfaces/wlr_output.h
+++ b/include/wlr/interfaces/wlr_output.h
@@ -45,5 +45,7 @@ void wlr_output_update_enabled(struct wlr_output *output, bool enabled);
void wlr_output_update_needs_swap(struct wlr_output *output);
void wlr_output_damage_whole(struct wlr_output *output);
void wlr_output_send_frame(struct wlr_output *output);
+void wlr_output_send_present(struct wlr_output *output,
+ struct wlr_output_event_present *event);
#endif
diff --git a/include/wlr/types/meson.build b/include/wlr/types/meson.build
index 6a8955c3..7a02c3da 100644
--- a/include/wlr/types/meson.build
+++ b/include/wlr/types/meson.build
@@ -5,10 +5,10 @@ install_headers(
'wlr_cursor.h',
'wlr_data_device.h',
'wlr_export_dmabuf_v1.h',
- 'wlr_gamma_control.h',
'wlr_gamma_control_v1.h',
- 'wlr_idle.h',
+ 'wlr_gamma_control.h',
'wlr_idle_inhibit_v1.h',
+ 'wlr_idle.h',
'wlr_input_device.h',
'wlr_input_inhibitor.h',
'wlr_keyboard.h',
@@ -16,10 +16,11 @@ install_headers(
'wlr_linux_dmabuf_v1.h',
'wlr_list.h',
'wlr_matrix.h',
- 'wlr_output.h',
'wlr_output_damage.h',
'wlr_output_layout.h',
+ 'wlr_output.h',
'wlr_pointer.h',
+ 'wlr_presentation_time.h',
'wlr_primary_selection.h',
'wlr_region.h',
'wlr_screencopy_v1.h',
@@ -36,7 +37,7 @@ install_headers(
'wlr_xcursor_manager.h',
'wlr_xdg_decoration_v1.h',
'wlr_xdg_output_v1.h',
- 'wlr_xdg_shell.h',
'wlr_xdg_shell_v6.h',
+ 'wlr_xdg_shell.h',
subdir: 'wlr/types',
)
diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h
index 96394ba4..9ccfbbb5 100644
--- a/include/wlr/types/wlr_output.h
+++ b/include/wlr/types/wlr_output.h
@@ -88,9 +88,15 @@ struct wlr_output {
float transform_matrix[9];
struct {
+ // Request to render a frame
struct wl_signal frame;
+ // Emitted when buffers need to be swapped (because software cursors or
+ // fullscreen damage or because of backend-specific logic)
struct wl_signal needs_swap;
+ // Emitted right before buffer swap
struct wl_signal swap_buffers; // wlr_output_event_swap_buffers
+ // Emitted right after the buffer has been presented to the user
+ struct wl_signal present; // wlr_output_event_present
struct wl_signal enable;
struct wl_signal mode;
struct wl_signal scale;
@@ -123,6 +129,32 @@ struct wlr_output_event_swap_buffers {
pixman_region32_t *damage;
};
+enum wlr_output_present_flag {
+ // The presentation was synchronized to the "vertical retrace" by the
+ // display hardware such that tearing does not happen.
+ WLR_OUTPUT_PRESENT_VSYNC = 0x1,
+ // The display hardware provided measurements that the hardware driver
+ // converted into a presentation timestamp.
+ WLR_OUTPUT_PRESENT_HW_CLOCK = 0x2,
+ // The display hardware signalled that it started using the new image
+ // content.
+ WLR_OUTPUT_PRESENT_HW_COMPLETION = 0x4,
+ // The presentation of this update was done zero-copy.
+ WLR_OUTPUT_PRESENT_ZERO_COPY = 0x8,
+};
+
+struct wlr_output_event_present {
+ struct wlr_output *output;
+ // Time when the content update turned into light the first time.
+ struct timespec *when;
+ // Vertical retrace counter. Zero if unavailable.
+ unsigned seq;
+ // Prediction of how many nanoseconds after `when` the very next output
+ // refresh may occur. Zero if unknown.
+ int refresh; // nsec
+ uint32_t flags; // enum wlr_output_present_flag
+};
+
struct wlr_surface;
/**
diff --git a/include/wlr/types/wlr_presentation_time.h b/include/wlr/types/wlr_presentation_time.h
new file mode 100644
index 00000000..9f9f0e87
--- /dev/null
+++ b/include/wlr/types/wlr_presentation_time.h
@@ -0,0 +1,59 @@
+/*
+ * This an unstable interface of wlroots. No guarantees are made regarding the
+ * future consistency of this API.
+ */
+#ifndef WLR_USE_UNSTABLE
+#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
+#endif
+
+#ifndef WLR_TYPES_WLR_PRESENTATION_TIME_H
+#define WLR_TYPES_WLR_PRESENTATION_TIME_H
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <time.h>
+#include <wayland-server.h>
+
+struct wlr_presentation {
+ struct wl_global *global;
+ struct wl_list resources; // wl_resource_get_link
+ struct wl_list feedbacks; // wlr_presentation_feedback::link
+ clockid_t clock;
+
+ struct {
+ struct wl_signal destroy;
+ } events;
+
+ struct wl_listener display_destroy;
+};
+
+struct wlr_presentation_feedback {
+ struct wl_resource *resource;
+ struct wlr_presentation *presentation;
+ struct wlr_surface *surface;
+ bool committed;
+ struct wl_list link; // wlr_presentation::feedbacks
+
+ struct wl_listener surface_commit;
+ struct wl_listener surface_destroy;
+};
+
+struct wlr_presentation_event {
+ struct wlr_output *output;
+ uint64_t tv_sec;
+ uint32_t tv_nsec;
+ uint32_t refresh;
+ uint64_t seq;
+ uint32_t flags; // wp_presentation_feedback_kind
+};
+
+struct wlr_backend;
+
+struct wlr_presentation *wlr_presentation_create(struct wl_display *display,
+ struct wlr_backend *backend);
+void wlr_presentation_destroy(struct wlr_presentation *presentation);
+void wlr_presentation_send_surface_presented(
+ struct wlr_presentation *presentation, struct wlr_surface *surface,
+ struct wlr_presentation_event *event);
+
+#endif