backend/drm: Add pixel blend mode properties

This commit is contained in:
YaoBing Xiao 2026-03-26 10:07:27 +08:00
parent 413664e0b0
commit b09160aa3e
6 changed files with 22 additions and 1 deletions

View file

@ -474,6 +474,11 @@ static void set_plane_props(struct atomic *atom, struct wlr_drm_backend *drm,
atomic_add(atom, id, props->crtc_y, dst_box->y);
atomic_add(atom, id, props->crtc_w, dst_box->width);
atomic_add(atom, id, props->crtc_h, dst_box->height);
if (props->pixel_blend_mode != 0) {
enum wlr_drm_pixel_blend_mode blend_mode = fb->has_alpha ?
WLR_DRM_BLEND_PREMULTI : WLR_DRM_BLEND_PIXEL_NONE;
atomic_add(atom, id, props->pixel_blend_mode, blend_mode);
}
}
static void set_color_encoding_and_range(struct atomic *atom,

View file

@ -196,6 +196,7 @@ static struct wlr_drm_fb *drm_fb_create(struct wlr_drm_backend *drm,
fb->backend = drm;
fb->wlr_buf = buf;
fb->has_alpha = pixel_format_has_alpha(attribs.format);
wlr_addon_init(&fb->addon, &buf->addons, drm, &fb_addon_impl);
wl_list_insert(&drm->fbs, &fb->link);

View file

@ -159,6 +159,10 @@ static bool set_plane_props(struct wlr_drm_plane *plane,
}
// The src_* properties are in 16.16 fixed point
enum wlr_drm_pixel_blend_mode blend_mode = fb->has_alpha ?
WLR_DRM_BLEND_PREMULTI : WLR_DRM_BLEND_PIXEL_NONE;
bool set_blend_mode = plane->props.pixel_blend_mode == 0 ||
liftoff_layer_set_property(layer, "pixel blend mode", blend_mode) == 0;
return liftoff_layer_set_property(layer, "zpos", zpos) == 0 &&
liftoff_layer_set_property(layer, "SRC_X", src_box->x * (1 << 16)) == 0 &&
liftoff_layer_set_property(layer, "SRC_Y", src_box->y * (1 << 16)) == 0 &&
@ -168,7 +172,8 @@ static bool set_plane_props(struct wlr_drm_plane *plane,
liftoff_layer_set_property(layer, "CRTC_Y", dst_box->y) == 0 &&
liftoff_layer_set_property(layer, "CRTC_W", dst_box->width) == 0 &&
liftoff_layer_set_property(layer, "CRTC_H", dst_box->height) == 0 &&
liftoff_layer_set_property(layer, "FB_ID", fb->id) == 0;
liftoff_layer_set_property(layer, "FB_ID", fb->id) == 0 &&
set_blend_mode;
}
static bool disable_plane(struct wlr_drm_plane *plane) {

View file

@ -68,6 +68,7 @@ static const struct prop_info plane_info[] = {
{ "SRC_W", INDEX(src_w) },
{ "SRC_X", INDEX(src_x) },
{ "SRC_Y", INDEX(src_y) },
{ "pixel blend mode", INDEX(pixel_blend_mode) },
{ "rotation", INDEX(rotation) },
{ "type", INDEX(type) },
#undef INDEX