mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2024-11-25 00:22:25 +00:00
render/drm_syncobj: de-duplicate drm_syncobj timeline init
This commit is contained in:
parent
c3acef0dc0
commit
8e36040e88
@ -12,36 +12,45 @@
|
|||||||
#include <sys/eventfd.h>
|
#include <sys/eventfd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct wlr_drm_syncobj_timeline *wlr_drm_syncobj_timeline_create(int drm_fd) {
|
static struct wlr_drm_syncobj_timeline *timeline_create(int drm_fd, uint32_t handle) {
|
||||||
struct wlr_drm_syncobj_timeline *timeline = calloc(1, sizeof(*timeline));
|
struct wlr_drm_syncobj_timeline *timeline = calloc(1, sizeof(*timeline));
|
||||||
if (timeline == NULL) {
|
if (timeline == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
timeline->drm_fd = drm_fd;
|
timeline->drm_fd = drm_fd;
|
||||||
timeline->n_refs = 1;
|
timeline->n_refs = 1;
|
||||||
|
timeline->handle = handle;
|
||||||
|
|
||||||
if (drmSyncobjCreate(drm_fd, 0, &timeline->handle) != 0) {
|
return timeline;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct wlr_drm_syncobj_timeline *wlr_drm_syncobj_timeline_create(int drm_fd) {
|
||||||
|
uint32_t handle = 0;
|
||||||
|
if (drmSyncobjCreate(drm_fd, 0, &handle) != 0) {
|
||||||
wlr_log_errno(WLR_ERROR, "drmSyncobjCreate failed");
|
wlr_log_errno(WLR_ERROR, "drmSyncobjCreate failed");
|
||||||
free(timeline);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct wlr_drm_syncobj_timeline *timeline = timeline_create(drm_fd, handle);
|
||||||
|
if (timeline == NULL) {
|
||||||
|
drmSyncobjDestroy(drm_fd, handle);
|
||||||
|
}
|
||||||
|
|
||||||
return timeline;
|
return timeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_drm_syncobj_timeline *wlr_drm_syncobj_timeline_import(int drm_fd,
|
struct wlr_drm_syncobj_timeline *wlr_drm_syncobj_timeline_import(int drm_fd,
|
||||||
int drm_syncobj_fd) {
|
int drm_syncobj_fd) {
|
||||||
struct wlr_drm_syncobj_timeline *timeline = calloc(1, sizeof(*timeline));
|
uint32_t handle = 0;
|
||||||
if (timeline == NULL) {
|
if (drmSyncobjFDToHandle(drm_fd, drm_syncobj_fd, &handle) != 0) {
|
||||||
|
wlr_log_errno(WLR_ERROR, "drmSyncobjFDToHandle failed");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
timeline->drm_fd = drm_fd;
|
|
||||||
timeline->n_refs = 1;
|
|
||||||
|
|
||||||
if (drmSyncobjFDToHandle(drm_fd, drm_syncobj_fd, &timeline->handle) != 0) {
|
struct wlr_drm_syncobj_timeline *timeline = timeline_create(drm_fd, handle);
|
||||||
wlr_log_errno(WLR_ERROR, "drmSyncobjFDToHandle failed");
|
if (timeline == NULL) {
|
||||||
free(timeline);
|
drmSyncobjDestroy(drm_fd, handle);
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return timeline;
|
return timeline;
|
||||||
|
Loading…
Reference in New Issue
Block a user