From 62626cbfec08ac58b8419ca30566fae322b46763 Mon Sep 17 00:00:00 2001 From: Harish Krupo Date: Fri, 7 Jun 2019 11:09:56 +0530 Subject: [PATCH] gl-renderer: Obscure protected content on unprotected display The content protection protocol requires that in enforced mode, parts of the surfaces which lie on outputs with protection level lower than that of the surface be censored. This patch uses a solid shader to color such regions with dark red. Signed-off-by: Harish Krupo --- libweston/renderer-gl/gl-renderer.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c index 3de711ea1..e502e7fc8 100644 --- a/libweston/renderer-gl/gl-renderer.c +++ b/libweston/renderer-gl/gl-renderer.c @@ -955,6 +955,8 @@ draw_view(struct weston_view *ev, struct weston_output *output, pixman_region32_t surface_blend; GLint filter; int i; + bool shader_replaced = false; + struct gl_shader *tmp_shader = NULL; /* In case of a runtime switch of renderers, we may not have received * an attach for this surface since the switch. In that case we don't @@ -973,6 +975,17 @@ draw_view(struct weston_view *ev, struct weston_output *output, if (ensure_surface_buffer_is_ready(gr, gs) < 0) goto out; + if (ev->surface->protection_mode == WESTON_SURFACE_PROTECTION_MODE_ENFORCED && + ev->surface->desired_protection > output->current_protection) { + tmp_shader = gs->shader; + shader_replaced = true; + gs->color[0] = 0.40; + gs->color[1] = 0.0; + gs->color[2] = 0.0; + gs->color[3] = 1.0; + gs->shader = &gr->solid_shader; + } + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); if (gr->fan_debug) { @@ -1046,6 +1059,9 @@ draw_view(struct weston_view *ev, struct weston_output *output, out: pixman_region32_fini(&repaint); + + if (shader_replaced) + gs->shader = tmp_shader; } static void