From patchwork Thu Sep 5 01:53:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidong Yang X-Patchwork-Id: 11132007 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B04CD1398 for ; Thu, 5 Sep 2019 01:53:53 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8D7142073F for ; Thu, 5 Sep 2019 01:53:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D7142073F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6BB618947A; Thu, 5 Sep 2019 01:53:51 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id 897C08947A for ; Thu, 5 Sep 2019 01:53:49 +0000 (UTC) Received: by mail-pf1-x443.google.com with SMTP id y72so609663pfb.12 for ; Wed, 04 Sep 2019 18:53:49 -0700 (PDT) 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=Jp/DNMLeV0LULyU98lA+qSWp2LB6VikgGe1uflU4WiI/Zv4cOUPqSTuHQOkddbjT3I EedhvASL0zblQ/AEFsLaovhC9AI1yEpdsYuWU8vz6OuAwcg9J0g39C19X0ke8re2wezh aUfgMMePb2SOBVLApFaLjXg+ekxT4PD9tlbtdhp2Bl7qyWk5hf6fKUt54H4RupQKPqSR RRwrljaEKwd0iZSYgPKZfgZ4kgTrBV7F9zFCT2qMAbQjg2hcHa76/C/1i410xukdfnWJ 5ur8NEjmbYr1w13HqGCdbKR16CPeFnCIJZ4SuiU2rMWWC/Qoj9L3DG+xwTEDeIBF4UdD w1Uw== X-Gm-Message-State: APjAAAX0Nnzlz1o797deg5U1LhgEA4NSewWUnzatVENCBX+FsE5cFEUO jONRb1E8NqiPSOEMwbu41Vs= X-Google-Smtp-Source: APXvYqw1w8fU8E5K0bJsKsZgOMHGnxpe8l++eG8ZPXQwHo7rLedG7gEMXj3dlyn8sF5oBeQVtvNNaw== 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 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 X-Mailman-Original-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-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: Haneen Mohammed , David Airlie , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Sidong Yang Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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++; }