Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2876548ybl; Sun, 1 Sep 2019 02:01:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqwz0XAM0c/lvN/XdQComFfgIBR7/k8qF36+ozlM3g1CMqJ9PojthGnedB3ehgoLVV0Tan2r X-Received: by 2002:a63:484a:: with SMTP id x10mr11521478pgk.430.1567328507240; Sun, 01 Sep 2019 02:01:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567328507; cv=none; d=google.com; s=arc-20160816; b=XR4HeDJ3OEbQ2LQWEtIAb3mhr4+kqx80evYzy7j261Z43OMp41qzwBT2taNEWBh4Q6 foLK6D7yvX0NFbl+5YyY2RoYaQ/KH0aNLP02WAJBXySloGIflomcHbYIf2U+2a6VH2Nt O4oNlWdqymvGNEtt8mxfcFg4UilIUv44vqOCFKoBppVhV962JRgwn4BTTGEkut/iKIkT mXDmUI2dDjfUGNrpYBo3MyQKDLxUhN09cnqSj8RHuNsqOIAyQJmLr8hfDCgRnOZb6cWV EdHcEuLFuK2N7ej2/JJcxUYufx+V+6P8C9paefdm69ugdGNsCb3lxCzsvjdOecWRMXpF LmPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=W+lYISWLd+dLXJ92WanX0SAmm2/oFeQWs1BfMT2py3w=; b=VZAhHounQICqv9AS7OQaRCf8XESfM09SZw1D9Mva+71VO2DNjFa+go4hF6C9pObNLb U9NbD7ZA6ZkiB+hjCdCAqM29CqDjPln9yjTUnHMzTnvvyLb8UtS3vygJEmQ2Rlw/sKA+ POwDtudYrINhop50REN1bMD1hBwwxTrK9wnI3CNoy3qRT6zrsm9RMcg1QB8K0MDBbSen q1wa6QDsIqAXv/E7+wROljesgFhOMJzW7Tj7ATKCgvIXmuLU6yv/OhRd02rqY1eqmsdr xrmm/8uHN+OSl71iwNkCjkyzYAxH8Bn9ESEo82mt/maFATj1bhvGg+sG4zlKoPgKjS8m hTsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oDP406rR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y62si8488508pgy.348.2019.09.01.02.00.37; Sun, 01 Sep 2019 02:01:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oDP406rR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728904AbfIAI4u (ORCPT + 99 others); Sun, 1 Sep 2019 04:56:50 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:32775 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726631AbfIAI4u (ORCPT ); Sun, 1 Sep 2019 04:56:50 -0400 Received: by mail-pf1-f194.google.com with SMTP id q10so2093162pfl.0 for ; Sun, 01 Sep 2019 01:56:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=W+lYISWLd+dLXJ92WanX0SAmm2/oFeQWs1BfMT2py3w=; b=oDP406rRTaIX39SIvUpLS8n0W8bK0owcW8hoEKLZcbg/OVy/p5EpAq1CqHu8KDmO6B aQmESyGa4lhvcBPvzUEHJ17ay/eelPd73K5hmprOsZhcqrtcLeh3/G8Bvge4Jl8n+Y8G 1obxUDHjBNa3S+Sp5HmfQGhxq+z7x9VFcGbZorCIhWxezN81617sNaK/4E3cD4fNwPEw 3T5kfPxqgQnP5cfBt75vBXbe5FSmxCEYVtiFRYn7CctZ8V2PhR4hFmOAjCkke0pZIxih d2JLv2xFNxPZAbPyfkhx1gtJHjrMDcpCSXPZJiEhPUR3jMaH9Ca+B+GpHz9OGt9JXuph vtqQ== 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:mime-version :content-disposition:user-agent; bh=W+lYISWLd+dLXJ92WanX0SAmm2/oFeQWs1BfMT2py3w=; b=bKCZg6GB73p9Nr0Em6yOJKfEUEh1mX2xnSr+Bgg8KQ2pu63IRkigkQfU1zUOhJNMMf dZtARGTQNnFEPxOxKJusVCvnlwFQ9y9VM8ULmlC1fo1tFVi/lFGFad5htgKAzO1o7XFx zg/QSubtc01LNirP0u5+/69/b+OwmGOZD7B0nPeiRxnenJQLuVAYiI/f3oWwYB/nd6nJ oTS1bEP4hT86XRA6Bnp6SsxQytEzRg/heFZ764UUCSQLH4/tVd3BwSgnSGH5sr2AdqnZ 7tu2YcWfWn/aa5jrxFgZ489hp9mbQgcCF0pWf88ctkXXs7yiyqOoynokyqagUTH6kr54 n4ow== X-Gm-Message-State: APjAAAWYGCYbyVjmFwl5jVqPVQRgxm59PIDGBoo/+CboelvrZLUWMoSE I3aLoKnJmcSpJulWK05IzLNid2kjeyE= X-Received: by 2002:a65:4106:: with SMTP id w6mr19893392pgp.175.1567328209482; Sun, 01 Sep 2019 01:56:49 -0700 (PDT) Received: from raspberrypi ([61.83.141.141]) by smtp.gmail.com with ESMTPSA id c12sm16779697pfc.22.2019.09.01.01.56.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Sep 2019 01:56:48 -0700 (PDT) Date: Sun, 1 Sep 2019 09:56:39 +0100 From: Sidong Yang To: Rodrigo Siqueira , Haneen Mohammed , Daniel Vetter , David Airlie Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/vkms: Use alpha value to blend values. Message-ID: <20190901085639.GA20694@raspberrypi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use alpha value to blend source value and destination value Instead of just overwrite with source value. Signed-off-by: Sidong Yang --- drivers/gpu/drm/vkms/vkms_composer.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index d5585695c64d..b776185e5cb5 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -75,6 +75,9 @@ static void blend(void *vaddr_dst, void *vaddr_src, int y_limit = y_src + h_dst; int x_limit = x_src + w_dst; + u8 *src, *dst; + u32 alpha, inv_alpha; + for (i = y_src, i_dst = y_dst; i < y_limit; ++i) { for (j = x_src, j_dst = x_dst; j < x_limit; ++j) { offset_dst = dest_composer->offset @@ -84,8 +87,14 @@ static void blend(void *vaddr_dst, void *vaddr_src, + (i * src_composer->pitch) + (j * src_composer->cpp); - memcpy(vaddr_dst + offset_dst, - vaddr_src + offset_src, sizeof(u32)); + src = vaddr_src + offset_src; + dst = vaddr_dst + offset_dst; + alpha = src[3] + 1; + inv_alpha = 256 - src[3]; + dst[0] = (alpha * src[0] + inv_alpha * dst[0]) >> 8; + dst[1] = (alpha * src[1] + inv_alpha * dst[1]) >> 8; + dst[2] = (alpha * src[2] + inv_alpha * dst[2]) >> 8; + dst[3] = 0xff; } i_dst++; } -- 2.20.1