aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2021-03-31 17:14:33 +0200
committerSimon Ser <contact@emersion.fr>2021-03-31 17:29:31 +0200
commit7709a965e596f66efabaf6c22967adbac0bbddb2 (patch)
tree3f03539ac9419fcc7ff66172dda1371b8d6e6782 /backend
parenta2535b80ce139c4f1ce1df0cc36bb3d048c0e328 (diff)
backend/drm: use format table in test_buffer
Instead of an ad-hoc strip_alpha_channel function, use the centralized format table to get an opaque substitute.
Diffstat (limited to 'backend')
-rw-r--r--backend/drm/drm.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index a74c9ca7..a9c1b3c9 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -24,6 +24,7 @@
#include "backend/drm/drm.h"
#include "backend/drm/iface.h"
#include "backend/drm/util.h"
+#include "render/pixel_format.h"
#include "render/swapchain.h"
#include "util/signal.h"
@@ -378,15 +379,6 @@ static bool drm_crtc_page_flip(struct wlr_drm_connector *conn) {
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 test_buffer(struct wlr_drm_connector *conn,
struct wlr_buffer *wlr_buffer) {
struct wlr_drm_backend *drm = conn->backend;
@@ -420,10 +412,12 @@ static bool test_buffer(struct wlr_drm_connector *conn,
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);
- if (format != DRM_FORMAT_INVALID && wlr_drm_format_set_has(
- &crtc->primary->formats, format, attribs.modifier)) {
- attribs.format = format;
+ const struct wlr_pixel_format_info *info =
+ drm_get_pixel_format_info(attribs.format);
+ if (info != NULL && info->opaque_substitute != DRM_FORMAT_INVALID &&
+ wlr_drm_format_set_has(&crtc->primary->formats,
+ info->opaque_substitute, attribs.modifier)) {
+ attribs.format = info->opaque_substitute;
} else {
return false;
}