Rename get_present_clock to get_presentation clock, use it

master
emersion 6 years ago
parent abddfc99f2
commit b0635bf3e7

@ -64,9 +64,9 @@ struct wlr_session *wlr_backend_get_session(struct wlr_backend *backend) {
return NULL; return NULL;
} }
clockid_t wlr_backend_get_present_clock(struct wlr_backend *backend) { clockid_t wlr_backend_get_presentation_clock(struct wlr_backend *backend) {
if (backend->impl->get_present_clock) { if (backend->impl->get_presentation_clock) {
return backend->impl->get_present_clock(backend); return backend->impl->get_presentation_clock(backend);
} }
return CLOCK_MONOTONIC; return CLOCK_MONOTONIC;
} }

@ -65,7 +65,7 @@ static struct wlr_renderer *backend_get_renderer(
} }
} }
static clockid_t backend_get_present_clock(struct wlr_backend *backend) { static clockid_t backend_get_presentation_clock(struct wlr_backend *backend) {
struct wlr_drm_backend *drm = get_drm_backend_from_backend(backend); struct wlr_drm_backend *drm = get_drm_backend_from_backend(backend);
return drm->clock; return drm->clock;
} }
@ -74,7 +74,7 @@ static struct wlr_backend_impl backend_impl = {
.start = backend_start, .start = backend_start,
.destroy = backend_destroy, .destroy = backend_destroy,
.get_renderer = backend_get_renderer, .get_renderer = backend_get_renderer,
.get_present_clock = backend_get_present_clock, .get_presentation_clock = backend_get_presentation_clock,
}; };
bool wlr_backend_is_drm(struct wlr_backend *b) { bool wlr_backend_is_drm(struct wlr_backend *b) {

@ -1,6 +1,8 @@
#define _POSIX_C_SOURCE 199309L
#include <assert.h> #include <assert.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
#include <time.h>
#include <wlr/backend/interface.h> #include <wlr/backend/interface.h>
#include <wlr/backend/session.h> #include <wlr/backend/session.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
@ -77,11 +79,26 @@ static struct wlr_session *multi_backend_get_session(
return backend->session; return backend->session;
} }
static clockid_t multi_backend_get_presentation_clock(
struct wlr_backend *backend) {
struct wlr_multi_backend *multi = multi_backend_from_backend(backend);
struct subbackend_state *sub;
wl_list_for_each(sub, &multi->backends, link) {
if (sub->backend->impl->get_presentation_clock) {
return wlr_backend_get_presentation_clock(sub->backend);
}
}
return CLOCK_MONOTONIC;
}
struct wlr_backend_impl backend_impl = { struct wlr_backend_impl backend_impl = {
.start = multi_backend_start, .start = multi_backend_start,
.destroy = multi_backend_destroy, .destroy = multi_backend_destroy,
.get_renderer = multi_backend_get_renderer, .get_renderer = multi_backend_get_renderer,
.get_session = multi_backend_get_session, .get_session = multi_backend_get_session,
.get_presentation_clock = multi_backend_get_presentation_clock,
}; };
static void handle_display_destroy(struct wl_listener *listener, void *data) { static void handle_display_destroy(struct wl_listener *listener, void *data) {

@ -65,6 +65,6 @@ struct wlr_session *wlr_backend_get_session(struct wlr_backend *backend);
/** /**
* Returns the clock used by the backend for presentation feedback. * Returns the clock used by the backend for presentation feedback.
*/ */
clockid_t wlr_backend_get_present_clock(struct wlr_backend *backend); clockid_t wlr_backend_get_presentation_clock(struct wlr_backend *backend);
#endif #endif

@ -19,7 +19,7 @@ struct wlr_backend_impl {
void (*destroy)(struct wlr_backend *backend); void (*destroy)(struct wlr_backend *backend);
struct wlr_renderer *(*get_renderer)(struct wlr_backend *backend); struct wlr_renderer *(*get_renderer)(struct wlr_backend *backend);
struct wlr_session *(*get_session)(struct wlr_backend *backend); struct wlr_session *(*get_session)(struct wlr_backend *backend);
clockid_t (*get_present_clock)(struct wlr_backend *backend); clockid_t (*get_presentation_clock)(struct wlr_backend *backend);
}; };
/** /**

@ -47,7 +47,10 @@ struct wlr_presentation_event {
uint32_t flags; // wp_presentation_feedback_kind uint32_t flags; // wp_presentation_feedback_kind
}; };
struct wlr_presentation *wlr_presentation_create(struct wl_display *display); 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_destroy(struct wlr_presentation *presentation);
void wlr_presentation_send_surface_presented( void wlr_presentation_send_surface_presented(
struct wlr_presentation *presentation, struct wlr_surface *surface, struct wlr_presentation *presentation, struct wlr_surface *surface,

@ -565,7 +565,7 @@ void wlr_output_send_present(struct wlr_output *output, struct timespec *when,
unsigned seq, uint32_t flags) { unsigned seq, uint32_t flags) {
struct timespec now; struct timespec now;
if (when == NULL) { if (when == NULL) {
clockid_t clock = wlr_backend_get_present_clock(output->backend); clockid_t clock = wlr_backend_get_presentation_clock(output->backend);
errno = 0; errno = 0;
if (clock_gettime(clock, &now) != 0) { if (clock_gettime(clock, &now) != 0) {
wlr_log_errno(WLR_ERROR, "failed to send output present event: " wlr_log_errno(WLR_ERROR, "failed to send output present event: "

@ -3,6 +3,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <wlr/types/wlr_presentation_time.h> #include <wlr/types/wlr_presentation_time.h>
#include <wlr/types/wlr_surface.h> #include <wlr/types/wlr_surface.h>
#include <wlr/backend.h>
#include "presentation-time-protocol.h" #include "presentation-time-protocol.h"
#include "util/signal.h" #include "util/signal.h"
@ -147,7 +148,7 @@ static void presentation_bind(struct wl_client *client, void *data,
presentation_handle_resource_destroy); presentation_handle_resource_destroy);
wl_list_insert(&presentation->resources, wl_resource_get_link(resource)); wl_list_insert(&presentation->resources, wl_resource_get_link(resource));
wp_presentation_send_clock_id(resource, presentation->clock); wp_presentation_send_clock_id(resource, (uint32_t)presentation->clock);
} }
static void handle_display_destroy(struct wl_listener *listener, void *data) { static void handle_display_destroy(struct wl_listener *listener, void *data) {
@ -156,7 +157,8 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
wlr_presentation_destroy(presentation); wlr_presentation_destroy(presentation);
} }
struct wlr_presentation *wlr_presentation_create(struct wl_display *display) { struct wlr_presentation *wlr_presentation_create(struct wl_display *display,
struct wlr_backend *backend) {
struct wlr_presentation *presentation = struct wlr_presentation *presentation =
calloc(1, sizeof(struct wlr_presentation)); calloc(1, sizeof(struct wlr_presentation));
if (presentation == NULL) { if (presentation == NULL) {
@ -170,8 +172,7 @@ struct wlr_presentation *wlr_presentation_create(struct wl_display *display) {
return NULL; return NULL;
} }
// TODO: get clock from backend presentation->clock = wlr_backend_get_presentation_clock(backend);
presentation->clock = CLOCK_MONOTONIC;
wl_list_init(&presentation->resources); wl_list_init(&presentation->resources);
wl_list_init(&presentation->feedbacks); wl_list_init(&presentation->feedbacks);

Loading…
Cancel
Save