diff options
-rw-r--r-- | backend/drm/drm.c | 26 | ||||
-rw-r--r-- | include/wlr/interfaces/wlr_output.h | 3 | ||||
-rw-r--r-- | include/wlr/types/wlr_output.h | 9 | ||||
-rw-r--r-- | types/wlr_output.c | 10 |
4 files changed, 27 insertions, 21 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c index fabdf77b..0f548f45 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -868,8 +868,8 @@ static uint32_t strip_alpha_channel(uint32_t format) { } } -static bool drm_connector_set_dmabuf(struct wlr_output *output, - struct wlr_dmabuf_attributes *attribs) { +static bool drm_connector_attach_buffer(struct wlr_output *output, + struct wlr_buffer *buffer) { struct wlr_drm_connector *conn = get_drm_connector_from_output(output); struct wlr_drm_backend *drm = get_drm_backend_from_backend(output->backend); if (!drm->session->active) { @@ -881,27 +881,29 @@ static bool drm_connector_set_dmabuf(struct wlr_output *output, return false; } - if (attribs->width != output->width || attribs->height != output->height) { + struct wlr_dmabuf_attributes attribs; + if (!wlr_buffer_get_dmabuf(buffer, &attribs)) { + return false; + } + + if (attribs.width != output->width || attribs.height != output->height) { return false; } - struct wlr_dmabuf_attributes attribs_stripped_alpha; if (!wlr_drm_format_set_has(&crtc->primary->formats, - attribs->format, attribs->modifier)) { + attribs.format, attribs.modifier)) { // The format isn't supported by the plane. Try stripping the alpha // channel, if any. - uint32_t format = strip_alpha_channel(attribs->format); + uint32_t format = strip_alpha_channel(attribs.format); if (format != DRM_FORMAT_INVALID && wlr_drm_format_set_has( - &crtc->primary->formats, format, attribs->modifier)) { - attribs_stripped_alpha = *attribs; - attribs_stripped_alpha.format = format; - attribs = &attribs_stripped_alpha; + &crtc->primary->formats, format, attribs.modifier)) { + attribs.format = format; } else { return false; } } - struct gbm_bo *bo = import_gbm_bo(&drm->renderer, attribs); + struct gbm_bo *bo = import_gbm_bo(&drm->renderer, &attribs); if (bo == NULL) { wlr_log(WLR_ERROR, "import_gbm_bo failed"); return NULL; @@ -950,7 +952,7 @@ static const struct wlr_output_impl output_impl = { .get_gamma_size = drm_connector_get_gamma_size, .export_dmabuf = drm_connector_export_dmabuf, .schedule_frame = drm_connector_schedule_frame, - .set_dmabuf = drm_connector_set_dmabuf, + .attach_buffer = drm_connector_attach_buffer, }; bool wlr_output_is_drm(struct wlr_output *output) { diff --git a/include/wlr/interfaces/wlr_output.h b/include/wlr/interfaces/wlr_output.h index a70c86e6..dc7a76d2 100644 --- a/include/wlr/interfaces/wlr_output.h +++ b/include/wlr/interfaces/wlr_output.h @@ -34,8 +34,7 @@ struct wlr_output_impl { bool (*export_dmabuf)(struct wlr_output *output, struct wlr_dmabuf_attributes *attribs); bool (*schedule_frame)(struct wlr_output *output); - bool (*set_dmabuf)(struct wlr_output *output, - struct wlr_dmabuf_attributes *attribs); + bool (*attach_buffer)(struct wlr_output *output, struct wlr_buffer *buffer); }; void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend, diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index 163d54ad..ffe13fb8 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -15,6 +15,7 @@ #include <wayland-server.h> #include <wayland-util.h> #include <wlr/render/dmabuf.h> +#include <wlr/types/wlr_buffer.h> struct wlr_output_mode { uint32_t flags; // enum wl_output_mode @@ -224,6 +225,12 @@ void wlr_output_effective_resolution(struct wlr_output *output, */ bool wlr_output_attach_render(struct wlr_output *output, int *buffer_age); /** + * Attach a buffer to the output. Compositors should call `wlr_output_commit` + * to submit the new frame. + */ +bool wlr_output_attach_buffer(struct wlr_output *output, + struct wlr_buffer *buffer); +/** * Get the preferred format for reading pixels. * This function might change the current rendering context. */ @@ -243,8 +250,6 @@ bool wlr_output_preferred_read_format(struct wlr_output *output, */ void wlr_output_set_damage(struct wlr_output *output, pixman_region32_t *damage); -bool wlr_output_set_dmabuf(struct wlr_output *output, - struct wlr_dmabuf_attributes *attribs); /** * Commit the pending output state. If `wlr_output_attach_render` has been * called, the pending frame will be submitted for display. diff --git a/types/wlr_output.c b/types/wlr_output.c index 07cdcc7c..389d4c1e 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -478,8 +478,8 @@ bool wlr_output_commit(struct wlr_output *output) { return true; } -bool wlr_output_set_dmabuf(struct wlr_output *output, - struct wlr_dmabuf_attributes *attribs) { +bool wlr_output_attach_buffer(struct wlr_output *output, + struct wlr_buffer *buffer) { if (output->frame_pending) { wlr_log(WLR_ERROR, "Tried to swap buffers when a frame is pending"); return false; @@ -489,15 +489,15 @@ bool wlr_output_set_dmabuf(struct wlr_output *output, output->idle_frame = NULL; } - if (!output->impl->set_dmabuf) { + if (!output->impl->attach_buffer) { return false; } - if (!output->impl->set_dmabuf(output, attribs)) { + if (!output->impl->attach_buffer(output, buffer)) { return false; } output->frame_pending = true; - output->needs_swap = false; + output->needs_frame = false; pixman_region32_clear(&output->damage); return true; } |