From c0f3cb87be776941546a71dc10d37312a0b2636f Mon Sep 17 00:00:00 2001 From: Veeresh Kadasani Date: Fri, 24 Apr 2020 13:23:52 +0900 Subject: [PATCH] backend-drm: Pass view alpha to plane state and commit We map view alpha(0.0-1.0) to plane state's alpha by using the max plane alpha value got from drm. Signed-off-by: Hsuan-Yu Lin Signed-off-by: Veeresh Kadasani Signed-off-by: Vinh Nguyen Trong --- libweston/backend-drm/fb.c | 6 ------ libweston/backend-drm/state-helpers.c | 8 ++++++++ libweston/backend-drm/state-propose.c | 8 ++++++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/libweston/backend-drm/fb.c b/libweston/backend-drm/fb.c index 40d4bf0c1..0c2c0f6ef 100644 --- a/libweston/backend-drm/fb.c +++ b/libweston/backend-drm/fb.c @@ -695,12 +695,6 @@ drm_fb_get_from_paint_node(struct drm_output_state *state, struct drm_fb *fb; struct drm_plane *plane; - if (ev->alpha != 1.0f) { - pnode->try_view_on_plane_failure_reasons |= - FAILURE_REASONS_GLOBAL_ALPHA; - return NULL; - } - if (ev->surface->protection_mode == WESTON_SURFACE_PROTECTION_MODE_ENFORCED && ev->surface->desired_protection > output->base.current_protection) { pnode->try_view_on_plane_failure_reasons |= diff --git a/libweston/backend-drm/state-helpers.c b/libweston/backend-drm/state-helpers.c index 57a2621ff..b8fe7d87e 100644 --- a/libweston/backend-drm/state-helpers.c +++ b/libweston/backend-drm/state-helpers.c @@ -225,6 +225,8 @@ drm_plane_state_coords_for_paint_node(struct drm_plane_state *state, pixman_box32_t *box; struct weston_coord corners[2]; float sxf1, syf1, sxf2, syf2; + uint16_t min_alpha = state->plane->alpha_min; + uint16_t max_alpha = state->plane->alpha_max; if (!drm_paint_node_transform_supported(node, state->plane)) return false; @@ -305,6 +307,12 @@ drm_plane_state_coords_for_paint_node(struct drm_plane_state *state, /* apply zpos if available */ state->zpos = zpos; + /* The alpha of the view is normalized to alpha value range + * [min_alpha, max_alpha] that got from drm. The alpha value would + * never exceed max_alpha if ev->alpha <= 1.0. + */ + state->alpha = min_alpha + (uint16_t)round((max_alpha - min_alpha) * ev->alpha); + return true; } diff --git a/libweston/backend-drm/state-propose.c b/libweston/backend-drm/state-propose.c index 7cd7714c0..077de8241 100644 --- a/libweston/backend-drm/state-propose.c +++ b/libweston/backend-drm/state-propose.c @@ -583,6 +583,14 @@ drm_output_find_plane_for_view(struct drm_output_state *state, continue; } + /* if view has alpha check if this plane supports plane alpha */ + if (ev->alpha != 1.0f && plane->alpha_max == plane->alpha_min) { + drm_debug(b, "\t\t\t\t[plane] not trying plane %d:" + "plane-alpha not supported\n", + plane->plane_id); + continue; + } + if (plane->zpos_min >= current_lowest_zpos) { drm_debug(b, "\t\t\t\t[plane] not trying plane %d: " "plane's minimum zpos (%"PRIu64") above "