render/timeline: add wlr_render_timeline_import

This commit is contained in:
Simon Ser 2021-10-21 15:02:09 +02:00
parent f80f89b560
commit 7ae10e078a
2 changed files with 22 additions and 0 deletions

View file

@ -26,6 +26,23 @@ struct wlr_render_timeline *wlr_render_timeline_create(int drm_fd) {
return timeline;
}
struct wlr_render_timeline *wlr_render_timeline_import(int drm_fd,
int drm_syncobj_fd) {
struct wlr_render_timeline *timeline = calloc(1, sizeof(*timeline));
if (timeline == NULL) {
return NULL;
}
timeline->drm_fd = drm_fd;
if (drmSyncobjFDToHandle(drm_fd, drm_syncobj_fd, &timeline->handle) != 0) {
wlr_log_errno(WLR_ERROR, "drmSyncobjFDToHandle failed");
free(timeline);
return NULL;
}
return timeline;
}
void wlr_render_timeline_destroy(struct wlr_render_timeline *timeline) {
drmSyncobjDestroy(timeline->drm_fd, timeline->handle);
free(timeline);