Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp251478ybe; Wed, 4 Sep 2019 19:15:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqwA8IDKtpgoDZ4KwnVyGs9VhqAYOriy8hKQ8xiGlGW/wC3C+1RycODKgLIlaSBBdj98Ek/T X-Received: by 2002:a62:7684:: with SMTP id r126mr926732pfc.26.1567649756584; Wed, 04 Sep 2019 19:15:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567649756; cv=none; d=google.com; s=arc-20160816; b=yLybJTUdrvD5HDKRHb7Fcg2jhdG3HZIabsA+qfW0YZs2qMy1smoBKyNgWsELDfuq8Q c+GXiMdsiRV3Z6aEZlJ9sKUv8Q5TrKcT34AdxBHydUwhQC4nloTF0S8ADo69ZZ4lPq3k cAmoCq9E3k8hwNPvhWXHn3Y74YSQjDAZCKGFdSyjC9iKRjTYjhltUFgcBXCjXcplKXwZ Up743XS3NItUBaKxe/6Fijcj8aeugcM4zh0+rQcRZ2oiZ8F9ljgJ4ddFyWinb0COtGCE XTMyaJA4ChadQdGW+r1SiRuYVmrSGmazm9XeTKIkU04XPg3qHXfgAoqwRe8+DFWePhH7 aWAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=8ULGV/s7+qxZzul0FZw0GFFC3DnLHdGN42oRHfNbhLE=; b=MqM6pH7QBHk142liQ8BktxbPb+eVLgR/JAxFLdCEtvczfT/Kh/7a04S1g5dKrBX5wZ Evvgxbnk0V+4CZnH2Oas17sP3Fz586YOE6AOh1SSFrn6SBmNHn0e+2Rzyq9DRtyPh13x szitEPN3Tan0fIGu/eK8wIDtzH7YUUx+etfjOCSY8Gfn9aIzMQuu+1pE3sllBc1XtAQh 9zZWIkHk2R9MaBarWjJcPQ0/dgg1mjisHbD3sliBvsnHQCpDSwbbsRlna00t1shgnOyn 5QkNm8vm1xwwy/SEQhrfZakVwxqKW31l7FeUZTW8prSB/WNNI94UasG0AeHldEzyZepO +diQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dNUFGdE6; 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 t35si447152pgm.8.2019.09.04.19.15.40; Wed, 04 Sep 2019 19:15:56 -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=dNUFGdE6; 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 S1730579AbfIEBxu (ORCPT + 99 others); Wed, 4 Sep 2019 21:53:50 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:34883 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727156AbfIEBxt (ORCPT ); Wed, 4 Sep 2019 21:53:49 -0400 Received: by mail-pf1-f196.google.com with SMTP id 205so642949pfw.2 for ; Wed, 04 Sep 2019 18:53:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8ULGV/s7+qxZzul0FZw0GFFC3DnLHdGN42oRHfNbhLE=; b=dNUFGdE6RxUVKSBcjKmrQrqlL9FPlzSO56kd0QMh/TXkHVoF9S8yiNeuZeb+6Rj0pz b2mVlOWxszR2z44QxOn4skZ+uB8WrXw0acG5obbeJVaFb8wo03HDJow4wz+ef+PhXBRK ug7KvfyBSxnZIR2bgmAdMnUyzu2z3W7q//XuxSXcAcHw6UII4eIiL2G/G95sOTe9DXiP m93lAHu5LNW7U2PPohSHrsS8kyfSdPbeOtsFjgtJE+gMCq6w7r+HXFQQRcxnls3Vwo15 282jOffbVZZJpHi7aDFAc3LfxYeclo4e37IccSvmb3dKzSAmCugucFoFIeG8iNK8D7+U QRVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8ULGV/s7+qxZzul0FZw0GFFC3DnLHdGN42oRHfNbhLE=; b=dwkfrUOap7XNo6QjSLr9PvYWNt/ZqqgVJaYmmbI/Hv/QqKiYydrypRMeO9CgxErFKn 3nFLpJ2cL0SNVEJ1PEoY4DWvYiyfpJ6n3rWKWfBlXPoLHeGY6W8NxLfmlUj9fU1+mzaq iSb86MaxcFbUToPXi3357lK6MttwdkO6BIHpo/fZKp7AUZ57NafFwuiwSOKZPLBEv1Iv Hg0DwC9yZbVIhDuUeK7IIkBmm2dcjd+AJMbvqD9IFyFXNExByPoCworI/qA2TRk9nDFe 7b8VsEedo2SYEJ8p/6XaQr0Zcqz77U8e1y9W3GVAKXXOUHmTfLXLVkIBFQLlEkLfWinh 1OAQ== X-Gm-Message-State: APjAAAUiq8PkBtyGMkLv0BymdJwv/mfIr9gIb9XV8fULcPmn9Nf6XrIg snpJHBCWBlFne1vbVcP9RC6Pnn3CfnM= X-Received: by 2002:a63:6fcf:: with SMTP id k198mr936312pgc.276.1567648428825; Wed, 04 Sep 2019 18:53:48 -0700 (PDT) Received: from localhost.localdomain ([61.83.141.141]) by smtp.gmail.com with ESMTPSA id z12sm330990pfj.41.2019.09.04.18.53.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2019 18:53:48 -0700 (PDT) From: Sidong Yang To: Rodrigo Siqueira Cc: Sidong Yang , Haneen Mohammed , Daniel Vetter , David Airlie , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= Subject: [PATCH v2] drm/vkms: Use alpha value to blend values. Date: Thu, 5 Sep 2019 02:53:26 +0100 Message-Id: <20190905015326.23853-1-realwakka@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- v1 -> v2: * Move variables to tighter scope. 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..181472efa08c 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -77,6 +77,9 @@ static void blend(void *vaddr_dst, void *vaddr_src, for (i = y_src, i_dst = y_dst; i < y_limit; ++i) { for (j = x_src, j_dst = x_dst; j < x_limit; ++j) { + u8 *src, *dst; + u32 alpha, inv_alpha; + offset_dst = dest_composer->offset + (i_dst * dest_composer->pitch) + (j_dst++ * dest_composer->cpp); @@ -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