diff options
author | Simon Ser <contact@emersion.fr> | 2019-04-22 09:08:10 +0300 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-06-07 09:06:11 -0400 |
commit | 5c78f1b0d5d6572dd9035e2d43e2a7bddd466a58 (patch) | |
tree | de62e57142fd14441259aab181c00aa2dc2caf18 | |
parent | e516ea4c798d4c02e77836d5e8196decb90a8774 (diff) |
backend/drm: strip alpha channel on scan-out
-rw-r--r-- | backend/drm/drm.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c index a2a117d6..fabdf77b 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -859,6 +859,15 @@ static bool drm_connector_schedule_frame(struct wlr_output *output) { return true; } +static uint32_t strip_alpha_channel(uint32_t format) { + switch (format) { + case DRM_FORMAT_ARGB8888: + return DRM_FORMAT_XRGB8888; + default: + return DRM_FORMAT_INVALID; + } +} + static bool drm_connector_set_dmabuf(struct wlr_output *output, struct wlr_dmabuf_attributes *attribs) { struct wlr_drm_connector *conn = get_drm_connector_from_output(output); @@ -875,9 +884,21 @@ static bool drm_connector_set_dmabuf(struct wlr_output *output, 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)) { - return false; + // The format isn't supported by the plane. Try stripping the alpha + // channel, if any. + 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; + } else { + return false; + } } struct gbm_bo *bo = import_gbm_bo(&drm->renderer, attribs); |