From patchwork Thu Aug 30 21:47:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 11116 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 9081823F27 for ; Thu, 30 Aug 2012 21:47:42 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id E0470A192FB for ; Thu, 30 Aug 2012 21:47:05 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id j25so3732075iaf.11 for ; Thu, 30 Aug 2012 14:47:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :dkim-signature:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=vsf0sz8N5jq0kT1SMw3kPI/Xm0F+kF8R4l8OVVVcmpQ=; b=YclHMJ6XALeqwDRPRgdOd68qEv8zyhQS5ValUhuDvAbE+BJfG1Vk9tlEpy+cs6GHu4 UX4nSn/v6IIRL0sW7/XLJo2A+c+ffEf38gZYerUFW0LjyG6US4Gas82OftaxNdKJWq8E VZqC8qG/YF+KN1k18f1i5qjVieVTqpiu6SH70tZPpkvx88ygwPb/ESjlWuyVYwmZljzK x0kGRq6Tdu3ZqaMlvmzCqQ4c/s7QE3MVRFQRbA9w8GDuK3nisj17Inam1TDSG7z0npwv CwY0ip5nGBdeekpOOVHISaNQwghgp0XUp+lzsHs/xhjexxxbdOEWLZVSr5M6Fx/doeT3 xMRw== Received: by 10.42.60.139 with SMTP id q11mr6356055ich.53.1346363262022; Thu, 30 Aug 2012 14:47:42 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp33037igc; Thu, 30 Aug 2012 14:47:41 -0700 (PDT) Received: by 10.68.130.65 with SMTP id oc1mr13560300pbb.29.1346363261296; Thu, 30 Aug 2012 14:47:41 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id iq5si4768719pbc.314.2012.08.30.14.47.41 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 30 Aug 2012 14:47:41 -0700 (PDT) Received-SPF: pass (google.com: domain of robdclark@gmail.com designates 209.85.160.50 as permitted sender) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=pass (google.com: domain of robdclark@gmail.com designates 209.85.160.50 as permitted sender) smtp.mail=robdclark@gmail.com; dkim=pass header.i=@gmail.com Received: by mail-pb0-f50.google.com with SMTP id md12so4150965pbc.37 for ; Thu, 30 Aug 2012 14:47:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=vsf0sz8N5jq0kT1SMw3kPI/Xm0F+kF8R4l8OVVVcmpQ=; b=NG08kb0cP6nvqADCtmTr2JSB7LRrIKBW0AKxRcguM6q7XfvF+ePNEp7zc6xuF3M5GL hDqxW58Q2Gscoy3fWbb/TY+3IsVW5Fi/DfhTA9yYWErAMXZrxbAaN/uHwWSIYXQZOfVr 5PckyzpDpORn6KpI0qTBML4l9MvMxWKMhUB/Mt3ET0LZVbjIQwN7Au24XjeZeYn369sT wLoir3dHjqVw3sU7m78IOYOxEikBZqjv8J7jRPvRPcJT/DC6g6V9LthbBcfISZq+YfiC SznIkKfk6gA9AzTw6T/RMGX1ZI/2/alAWtf6PDHTtXfh4erqIjRVUDjcrN5/wk4XGWGo v9DA== Received: by 10.68.134.97 with SMTP id pj1mr13589630pbb.55.1346363261048; Thu, 30 Aug 2012 14:47:41 -0700 (PDT) Received: from localhost ([38.96.16.75]) by mx.google.com with ESMTPS id gf3sm2204778pbc.74.2012.08.30.14.47.39 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 30 Aug 2012 14:47:40 -0700 (PDT) Sender: Rob Clark From: Rob Clark To: wayland-devel@lists.freedesktop.org Cc: patches@linaro.org, Pekka Paalanen Subject: [PATCH weston 4/5] compositor: fix blending for full-surface alpha Date: Thu, 30 Aug 2012 16:47:20 -0500 Message-Id: <1346363241-29219-5-git-send-email-rob.clark@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1346363241-29219-1-git-send-email-rob.clark@linaro.org> References: <1346363241-29219-1-git-send-email-rob.clark@linaro.org> X-Gm-Message-State: ALoCoQkSqBrCWIp83Tfwsag9JUfNzesFGlHefjO8H1KBbKz0yxpINsihZsYGwvW/OYfQSvw2SkX+ From: Pekka Paalanen We can use and render the opaque region only, if we are not applying a full-surface alpha. Test case: weston-terminal; use super+alt+mousewheel to adjust the window transparency. Before it went black, now it blends correctly. Signed-off-by: Pekka Paalanen --- src/compositor.c | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/src/compositor.c b/src/compositor.c index 030ec8f..e9fa56e 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -1280,18 +1280,17 @@ repaint_region(struct weston_surface *es, pixman_region32_t *region, WL_EXPORT void weston_surface_draw(struct weston_surface *es, struct weston_output *output, - pixman_region32_t *damage) + pixman_region32_t *damage) /* in global coordinates */ { struct weston_compositor *ec = es->compositor; /* repaint bounding region in global coordinates: */ pixman_region32_t repaint; - /* regions of surface to draw opaque/blended in surface coordinates: */ - pixman_region32_t surface_opaque, surface_blend; + /* non-opaque region in surface coordinates: */ + pixman_region32_t surface_blend; GLint filter; int i; pixman_region32_init(&repaint); - pixman_region32_init(&surface_opaque); pixman_region32_init(&surface_blend); pixman_region32_intersect(&repaint, @@ -1305,20 +1304,13 @@ weston_surface_draw(struct weston_surface *es, struct weston_output *output, &ec->primary_plane.damage, &repaint); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - if (1 || es->alpha < 1.0) { - /* blended region is whole surface minus opaque region: */ - pixman_region32_init_rect(&surface_blend, 0, 0, - es->geometry.width, es->geometry.height); - pixman_region32_init(&surface_opaque); - pixman_region32_copy(&surface_opaque, &es->opaque); + + /* blended region is whole surface minus opaque region: */ + pixman_region32_init_rect(&surface_blend, 0, 0, + es->geometry.width, es->geometry.height); + if (es->alpha >= 1.0) pixman_region32_subtract(&surface_blend, &surface_blend, - &surface_opaque); - } else { - /* whole surface is opaque: */ - pixman_region32_init_rect(&surface_opaque, 0, 0, - es->geometry.width, es->geometry.height); - pixman_region32_init(&surface_blend); - } + &es->opaque); if (ec->current_shader != es->shader) { glUseProgram(es->shader->program); @@ -1343,9 +1335,9 @@ weston_surface_draw(struct weston_surface *es, struct weston_output *output, glTexParameteri(es->target, GL_TEXTURE_MAG_FILTER, filter); } - if (pixman_region32_not_empty(&surface_opaque)) { + if (pixman_region32_not_empty(&es->opaque) && es->alpha >= 1.0) { glDisable(GL_BLEND); - repaint_region(es, &repaint, &surface_opaque); + repaint_region(es, &repaint, &es->opaque); } if (pixman_region32_not_empty(&surface_blend)) { @@ -1355,7 +1347,6 @@ weston_surface_draw(struct weston_surface *es, struct weston_output *output, out: pixman_region32_fini(&repaint); - pixman_region32_fini(&surface_opaque); pixman_region32_fini(&surface_blend); }