lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f09271656e9b29cb56e63c0bbf864060e5974cad.1562695974.git.rodrigosiqueiramelo@gmail.com>
Date:   Tue, 9 Jul 2019 22:54:05 -0300
From:   Rodrigo Siqueira <rodrigosiqueiramelo@...il.com>
To:     Daniel Vetter <daniel@...ll.ch>,
        Haneen Mohammed <hamohammed.sa@...il.com>,
        David Airlie <airlied@...ux.ie>,
        Simon Ser <contact@...rsion.fr>,
        Oleg Vasilev <oleg.vasilev@...el.com>,
        Mamta Shukla <mamtashukla555@...il.com>,
        Harry Wentland <harry.wentland@....com>
Cc:     dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: [PATCH 2/2] drm/vkms: Use alpha channel for blending cursor with
 primary

Currently, the blend function overwriting the cursor value into the
primary plane. This patch utilizes the alpha value for a fully
transparent blend of the cursor (vaddr_src) with primary (vaddr_dst)
instead of overwriting it in blend().

Cc: Haneen Mohammed <hamohammed.sa@...il.com>
Cc: Mamta Shukla <mamtashukla555@...il.com>
Cc: Harry Wentland <harry.wentland@....com>
Cc: Daniel Vetter <daniel@...ll.ch>
Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@...il.com>
---
 drivers/gpu/drm/vkms/vkms_composer.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c
index fb106964d8bf..bb758a5131a4 100644
--- a/drivers/gpu/drm/vkms/vkms_composer.c
+++ b/drivers/gpu/drm/vkms/vkms_composer.c
@@ -26,6 +26,17 @@ static void set_pixel(int x, int y, u8 *buffer,
 	*dst = value;
 }
 
+static u32 apply_alpha(u32 src, u32 dst)
+{
+	u8 alpha;
+	u32 k;
+
+	alpha = src >> 24;
+	alpha = (alpha + 1) >> 8;
+	k = (alpha << 24) - alpha;
+	return (k & src) | (~k & dst);
+}
+
 /**
  * compute_crc - Compute CRC value on output frame
  *
@@ -89,15 +100,19 @@ static void blend(void *vaddr_dst, void *vaddr_src,
 	int y_limit = y_src + h_dst;
 	int x_limit = x_src + w_dst;
 
-	u32 pixel_src;
+	u32 pixel_src, pixel_dst, new_pixel;
 
 	for (y = y_src, i_dst = y_dst; y < y_limit; ++y) {
 		for (x = x_src, j_dst = x_dst; x < x_limit; ++x) {
 			pixel_src = get_pixel_from_buffer(x, y,
 							  vaddr_src,
 							  src_composer);
-			set_pixel(j_dst, i_dst, vaddr_dst, dest_composer,
-				  pixel_src);
+			pixel_dst = get_pixel_from_buffer(j_dst, i_dst,
+							  vaddr_dst,
+							  dst_composer);
+			new_pixel = apply_alpha(pixel_src, pixel_dst);
+			set_pixel(j_dst, i_dst, vaddr_dst, dst_composer,
+				  new_pixel);
 			j_dst++;
 		}
 		i_dst++;
-- 
2.21.0

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ