aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2021-07-11 19:43:51 +0200
committerSimon Zeni <simon@bl4ckb0ne.ca>2021-07-12 09:16:09 -0400
commit9dba176e8d0ceee456de2aa9ac91908b740628e2 (patch)
tree88eeeae069d2a3c9d593c42260195116e1b786f4
parent9b70eab19494550c6765910affb5fc8c3f883662 (diff)
render/gles2: set has_alpha for DMA-BUFs
Use our internal pixel format table to figure out whether an imported DMA-BUF has alpha.
-rw-r--r--render/gles2/texture.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/render/gles2/texture.c b/render/gles2/texture.c
index b6b8ba57..417d4c1b 100644
--- a/render/gles2/texture.c
+++ b/render/gles2/texture.c
@@ -248,11 +248,19 @@ static struct wlr_texture *gles2_texture_from_dmabuf(
if (texture == NULL) {
return NULL;
}
- texture->has_alpha = true;
texture->drm_format = DRM_FORMAT_INVALID; // texture can't be written anyways
texture->inverted_y =
(attribs->flags & WLR_DMABUF_ATTRIBUTES_FLAGS_Y_INVERT) != 0;
+ const struct wlr_pixel_format_info *drm_fmt =
+ drm_get_pixel_format_info(attribs->format);
+ if (drm_fmt != NULL) {
+ texture->has_alpha = drm_fmt->has_alpha;
+ } else {
+ // We don't know, assume the texture has an alpha channel
+ texture->has_alpha = true;
+ }
+
struct wlr_egl_context prev_ctx;
wlr_egl_save_context(&prev_ctx);
wlr_egl_make_current(renderer->egl);