From patchwork Sun Sep 1 08:56:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidong Yang X-Patchwork-Id: 11125163 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 C045614E5 for ; Sun, 1 Sep 2019 08:56: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 A60462190F for ; Sun, 1 Sep 2019 08:56:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A60462190F 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 87B386E1BD; Sun, 1 Sep 2019 08:56:51 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by gabe.freedesktop.org (Postfix) with ESMTPS id 262576E1BD for ; Sun, 1 Sep 2019 08:56:50 +0000 (UTC) Received: by mail-pg1-x542.google.com with SMTP id 4so2164974pgm.12 for ; Sun, 01 Sep 2019 01:56:50 -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:mime-version :content-disposition:user-agent; bh=W+lYISWLd+dLXJ92WanX0SAmm2/oFeQWs1BfMT2py3w=; b=NBuHuEFwXKsGiOWZrSMXHAv6uSap4wbq4+DQNEImc2/SkUUJiOuG6KeN07jCJ/a8OZ iXBkWG24iHqvYVKyRh1j46BuxQ/gtyC+GPswQ85LDizJtgw7rLZSdp6Y/bWmITU27Urd poHLE4KUN7Zw67JubDSOplCH2yXzo9x1OUutEewwBVf1DCTX51LGkQ48aYSNRBSSUIS4 kxxXsN80MSGtSvBoQAmZSpaIk7lWFFMnrXaz9wtHvrAzJ8mrF3E6LaTef0+++rnOcGTr 3zYsXFqhugWUbzRhOAPQtxsARGO4/55CnTyhqUGL+sHzqbFtv/ngG0osequBdyszNG4w lnNQ== X-Gm-Message-State: APjAAAUf7CinIx1gtx7L5N5OrjSMLHAvP/obD1XXVe/CiR5+KBXRtQjH uDGGMIP/jEW1CGeuyzxlp0o= X-Google-Smtp-Source: APXvYqy8daAkWI0h/2UCCRkS0vvaIRVjrZj/5mthq1euwOPfZ7ZhxdNHprlrtZwigNBFdz55q8iTkA== 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 Subject: [PATCH] drm/vkms: Use alpha value to blend values. Message-ID: <20190901085639.GA20694@raspberrypi> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) 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: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-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" 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++; }