Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 7709a96

Browse files
committed
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.
1 parent a2535b8 commit 7709a96

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

backend/drm/drm.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "backend/drm/drm.h"
2525
#include "backend/drm/iface.h"
2626
#include "backend/drm/util.h"
27+
#include "render/pixel_format.h"
2728
#include "render/swapchain.h"
2829
#include "util/signal.h"
2930

@@ -378,15 +379,6 @@ static bool drm_crtc_page_flip(struct wlr_drm_connector *conn) {
378379
return true;
379380
}
380381

381-
static uint32_t strip_alpha_channel(uint32_t format) {
382-
switch (format) {
383-
case DRM_FORMAT_ARGB8888:
384-
return DRM_FORMAT_XRGB8888;
385-
default:
386-
return DRM_FORMAT_INVALID;
387-
}
388-
}
389-
390382
static bool test_buffer(struct wlr_drm_connector *conn,
391383
struct wlr_buffer *wlr_buffer) {
392384
struct wlr_drm_backend *drm = conn->backend;
@@ -420,10 +412,12 @@ static bool test_buffer(struct wlr_drm_connector *conn,
420412
attribs.format, attribs.modifier)) {
421413
// The format isn't supported by the plane. Try stripping the alpha
422414
// channel, if any.
423-
uint32_t format = strip_alpha_channel(attribs.format);
424-
if (format != DRM_FORMAT_INVALID && wlr_drm_format_set_has(
425-
&crtc->primary->formats, format, attribs.modifier)) {
426-
attribs.format = format;
415+
const struct wlr_pixel_format_info *info =
416+
drm_get_pixel_format_info(attribs.format);
417+
if (info != NULL && info->opaque_substitute != DRM_FORMAT_INVALID &&
418+
wlr_drm_format_set_has(&crtc->primary->formats,
419+
info->opaque_substitute, attribs.modifier)) {
420+
attribs.format = info->opaque_substitute;
427421
} else {
428422
return false;
429423
}

0 commit comments

Comments
 (0)