From patchwork Wed Jul 10 01:54:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 11037705 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6077713A4 for ; Wed, 10 Jul 2019 01:54:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 505AF288A9 for ; Wed, 10 Jul 2019 01:54:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4025928900; Wed, 10 Jul 2019 01:54:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CF128288A9 for ; Wed, 10 Jul 2019 01:54:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3A1F88992E; Wed, 10 Jul 2019 01:54:13 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by gabe.freedesktop.org (Postfix) with ESMTPS id 43E528992E for ; Wed, 10 Jul 2019 01:54:12 +0000 (UTC) Received: by mail-qt1-x844.google.com with SMTP id w17so741907qto.10 for ; Tue, 09 Jul 2019 18:54:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Rl/l0lv/RtftyGXlBncrpuyucSyNxpAjwoNFIcH2g3s=; b=L4moPOPZ6owV0vP5sfXqeBCA2j/8Rw/PtOxZItrl+kemlDztq8YoIwqvBfErERqFYY G9H4vUyNYZ8lvA9XZDRrU0/NdTfhJMXbx+69rQDI79r7dt1HKKsa0Ps8b/PhEQFqcaBw xkptGzqTN/dRcsn8+5SXljyP7lTvAeZZuJCfPzi8ZqR4PCKwXRwKrK7fnoFIzft/dnGH gRPjBcacDi9YSaamuExIcFH7ePiN4oFb4Bvt4WeotHm2I1QnbwNdLNU8zgDaQZV4UHI2 m9c3c9h/6NKOhTxVXIc4ScnF1SpbsjTiG4vdYYMJqb6XXYxwplsFwMB2mwcijFD2ntF6 RvEA== X-Gm-Message-State: APjAAAUQ/TpIpUF5fgVFksdfsh9VsdSIHAEDZrrbmnoeRIYckXt4uJjK 2UuHEudNKdt/QgTZoX3Mlww= X-Google-Smtp-Source: APXvYqwdGvebD5uoi6JfsmmnbR3yoS0xb1kwNdhLQ2mb7mTC91DvgkA4fuimynlpMDk6de4G6s28wg== X-Received: by 2002:ac8:2c17:: with SMTP id d23mr21131594qta.385.1562723651223; Tue, 09 Jul 2019 18:54:11 -0700 (PDT) Received: from smtp.gmail.com ([187.121.151.22]) by smtp.gmail.com with ESMTPSA id i22sm348098qti.30.2019.07.09.18.54.07 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 09 Jul 2019 18:54:10 -0700 (PDT) Date: Tue, 9 Jul 2019 22:54:05 -0300 From: Rodrigo Siqueira To: Daniel Vetter , Haneen Mohammed , David Airlie , Simon Ser , Oleg Vasilev , Mamta Shukla , Harry Wentland Subject: [PATCH 2/2] drm/vkms: Use alpha channel for blending cursor with primary Message-ID: References: MIME-Version: 1.0 In-Reply-To: User-Agent: NeoMutt/20180716 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Rl/l0lv/RtftyGXlBncrpuyucSyNxpAjwoNFIcH2g3s=; b=ejFKPXzvn1phIqms4yYo1HxB+xY6s8QiTpK9ZIM9O57fTojLMYHr/DRRFzDGTZ6WRr AfHD/+bLrnMSON1NNIFDBkrmigmXylIQs5w6oZMKtm6KatMB/VhnG0YdC1yrMZxSyxPz 563vtMNEkXSXr/+cvyhEZTIwSSa7d6Hzps4Sx6wGLO+75TAysv2hPme8AWIC852GRMoj 1P4K6TstYvbDRr91qonIYHaO1qCMF4pxk3FpIisyVcXK7iYJ4gZHomtRJawJfCuwaKGB mbYE4Kmc/j8BrNLum2hJwSB2zrSguVLEFdOd53KuH3R17Oj64eVTkggetf1le5Q3pnTU 88Sw== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Cc: Mamta Shukla Cc: Harry Wentland Cc: Daniel Vetter Signed-off-by: Rodrigo Siqueira --- 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++;