From patchwork Sat Aug 31 17:25:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sidong Yang X-Patchwork-Id: 11124943 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 573BE14DE for ; Sat, 31 Aug 2019 17:25:57 +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 2DC0823407 for ; Sat, 31 Aug 2019 17:25:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2DC0823407 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 8FF356E148; Sat, 31 Aug 2019 17:25:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by gabe.freedesktop.org (Postfix) with ESMTPS id C47466E148 for ; Sat, 31 Aug 2019 17:25:55 +0000 (UTC) Received: by mail-pg1-x543.google.com with SMTP id u17so5132685pgi.6 for ; Sat, 31 Aug 2019 10:25:55 -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=tzRB9ZWH+om5vs/FPmsjl0+yv1rSAQ1B0oVxWEkE1EMImVYojuU8fEgYc6ivdnQKnp ZvKZfgEvEHJDfgrh4gfqu4TSkc7T2h2vVIz5YTasCd0UYfZ5VKGA9O4Q1CY7uKWvjQuX CXMEcw7+/hewO9LqT7d90CRaoQFJmAS5rwW0C/xr/EmjVXR91eIBrDrUI81hqYudu0Lz GBrULqtb7jVAeqO49tPbxeNXm7BRiuNMbbBgUxVYJ6tgRKA5M4+NHWHNFITaW3AzJvti 1swP+gbnRdcwRgJVk8GFfUaafNJ8vLo1TLZBFwdgtZWE7T8p+yQxRpBO6e9zv4ogkdd9 PP6g== X-Gm-Message-State: APjAAAWb2NuQFujL6umTCXZMd1OrTx/NVohxsGKlfdq9xGymLadyz8Kk q9N0IJ1qAqXqpS41t0ki+Ro= X-Google-Smtp-Source: APXvYqxdoO9pFlTeP02tVUV36XLk12Ox0QdQ2UHgL0ppo691dkIMsMrSYKu0tKtaDl5y02Jj5/kgUg== X-Received: by 2002:a17:90a:de0f:: with SMTP id m15mr4855206pjv.18.1567272355239; Sat, 31 Aug 2019 10:25:55 -0700 (PDT) Received: from raspberrypi ([61.83.141.141]) by smtp.gmail.com with ESMTPSA id v8sm6151231pje.6.2019.08.31.10.25.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 31 Aug 2019 10:25:54 -0700 (PDT) Date: Sat, 31 Aug 2019 18:25:46 +0100 From: Sidong Yang To: Rodrigo Siqueira Subject: [PATCH] drm/vkms: Use alpha value to blend values. Message-ID: <20190831172546.GA1972@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=EnZ5tugQP34UeJgn4IKjljMkw6g/r2XQhYWuLXTTBrbhaKStb+RM0UVzzufhpp1qLv Ff8Ywjqj3au5uIP4uAbejFYh1DshxGMprh90esrq87mkg/MlR5mfIHwPLT1vOCXMZrYq u26RhYDgu8LqLRf6DrYGSGHXLgs6jjGIv3AGIrWuoQ3tMsU+WG4WFTtG7dudJQVTJxRb KXhMt6ktrAEKhhMHN/L3muV7uzKb83a/VxYfVsNltHbsPc0EKYfGdu962XXPRbJEjcOe x6loROZolOFlkaCR9Kapw0tT+ePPv4b1WsQ88b1gzFjlqvR9pJtoegxkY3AdX5OPoWrZ 4vyQ== 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: David Airlie , Haneen Mohammed , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.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 Reviewed-by: Ville Syrjälä --- 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++; }