From patchwork Thu Aug 9 19:18:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 10660 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 E310223E57 for ; Thu, 9 Aug 2012 19:18:56 +0000 (UTC) Received: from mail-gh0-f180.google.com (mail-gh0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id 9C3BFA181B7 for ; Thu, 9 Aug 2012 19:18:56 +0000 (UTC) Received: by ghbg10 with SMTP id g10so840230ghb.11 for ; Thu, 09 Aug 2012 12:18:56 -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=mDjWxuq8vgqohgFkwBnUFjTaay1z4N3uAbHTgSOGjRU=; b=NT1edLRbx/cEIsVA0TxJiInrv1fdxmxIBy4TcdFJkhC4eQLksEl5/HzEPRwrlZA+T/ 75twwkFr5GIyfBST2zuwrK+VUMV4Jcr18s5ylzNcywCdcBqtwlR4ThPehMBvMIXF1vhN E5LXJrfP/SIZP9j5Z8f6uKOVFKOBHLejJD1hziGmi0ifWVJioLk0XpZ5ZiOKoyYxlhk8 gebrhaN3nu8Ywgo9QCjrkxk6r50fFZr9VaRLZT0xsSoKzlqbkjMpZRmqekAhPM//6+Ct Aa2XcQ58PR5Ob+4+aMK1L7Lav1jarIiGrK+CtJbTL/D6qtRzGJjHFB38F4JdF8jS+3nX jFGA== Received: by 10.42.86.138 with SMTP id u10mr316221icl.32.1344539935957; Thu, 09 Aug 2012 12:18:55 -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.200 with SMTP id ew8csp24802igc; Thu, 9 Aug 2012 12:18:55 -0700 (PDT) Received: by 10.60.24.35 with SMTP id r3mr446446oef.67.1344539935485; Thu, 09 Aug 2012 12:18:55 -0700 (PDT) Received: from mail-ob0-f178.google.com (mail-ob0-f178.google.com [209.85.214.178]) by mx.google.com with ESMTPS id r4si2264251obz.102.2012.08.09.12.18.55 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 09 Aug 2012 12:18:55 -0700 (PDT) Received-SPF: pass (google.com: domain of robdclark@gmail.com designates 209.85.214.178 as permitted sender) client-ip=209.85.214.178; Authentication-Results: mx.google.com; spf=pass (google.com: domain of robdclark@gmail.com designates 209.85.214.178 as permitted sender) smtp.mail=robdclark@gmail.com; dkim=pass header.i=@gmail.com Received: by obbwd20 with SMTP id wd20so1345812obb.37 for ; Thu, 09 Aug 2012 12:18:55 -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=mDjWxuq8vgqohgFkwBnUFjTaay1z4N3uAbHTgSOGjRU=; b=xxfqz4mFGzqShMySg1/Trl2A1XJl1Y2CfSKvHT1kQjHDbV1SFDLZ9uo6+hnrTtqBX5 cxT08pOdGtiwGKpZeEH6XwskpF5ic0usQAsuZsG7GKZOvH6UQ+WLZd19SoAw3DV+bRyI x5suQHnUY9HTa8IxbCUvH/4prpAAeWhHIDNoqkk0HwUo9DRIk/pOnvL4ay69KPV4qWLA WpskmCNSULQBuzhlICnGJIBRVGFauYyw15OKrzPyhAOX3Dp8CauEORCd6qm9SlV0DQsI yUMMYMog4K9rm+AinHcn7aVd9gWni594sgK7PkwCYgBNDILXL1fInXR2TtE3AVMnNs+O kJ9w== Received: by 10.60.18.168 with SMTP id x8mr650939oed.18.1344539935138; Thu, 09 Aug 2012 12:18:55 -0700 (PDT) Received: from localhost (ppp-70-129-143-140.dsl.rcsntx.swbell.net. [70.129.143.140]) by mx.google.com with ESMTPS id bp7sm1530547obc.12.2012.08.09.12.18.54 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 09 Aug 2012 12:18:54 -0700 (PDT) Sender: Rob Clark From: Rob Clark To: wayland-devel@lists.freedesktop.org Cc: patches@linaro.org, Rob Clark Subject: [PATCH weston 2/2] compositor-drm: don't attempt sprite for out of bounds dimensions Date: Thu, 9 Aug 2012 14:18:28 -0500 Message-Id: <1344539908-12065-2-git-send-email-rob.clark@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1344539908-12065-1-git-send-email-rob.clark@linaro.org> References: <1344539908-12065-1-git-send-email-rob.clark@linaro.org> X-Gm-Message-State: ALoCoQnt8ubIHsystRHxLN7qQedhfRP0Mhg3yD9xW2dVPig4x0ICTXgf6gxnpgf9MNn0Vt7s5ZJb From: Rob Clark The drmModeAddFB2() call will fail anyways, and cause us to unnecessarily set sprites_are_broken. Signed-off-by: Rob Clark --- src/compositor-drm.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/compositor-drm.c b/src/compositor-drm.c index d6e6c98..9132206 100644 --- a/src/compositor-drm.c +++ b/src/compositor-drm.c @@ -74,6 +74,13 @@ struct drm_compositor { struct gbm_surface *dummy_surface; EGLSurface dummy_egl_surface; + /* we need these parameters in order to not fail drmModeAddFB2() + * due to out of bounds dimensions, and then mistakenly set + * sprites_are_broken: + */ + uint32_t min_width, max_width; + uint32_t min_height, max_height; + struct wl_list sprite_list; int sprites_are_broken; @@ -556,6 +563,7 @@ drm_output_prepare_overlay_surface(struct weston_output *output_base, pixman_box32_t *box; uint32_t format; wl_fixed_t sx1, sy1, sx2, sy2; + int32_t width, height; if (c->sprites_are_broken) return -1; @@ -603,11 +611,21 @@ drm_output_prepare_overlay_surface(struct weston_output *output_base, if (!handle) return -1; + width = es->geometry.width; + height = es->geometry.height; + + /* if geometry is out of bounds, don't even bother trying because + * we know the AddFB2() call will fail: + */ + if ((c->min_width > width) || (width > c->max_width) || + (c->min_height > height) || (height > c->max_height)) + return -1; + handles[0] = handle; pitches[0] = stride; offsets[0] = 0; - ret = drmModeAddFB2(c->drm.fd, es->geometry.width, es->geometry.height, + ret = drmModeAddFB2(c->drm.fd, width, height, format, handles, pitches, offsets, &fb_id, 0); if (ret) { @@ -1527,6 +1545,11 @@ create_outputs(struct drm_compositor *ec, uint32_t option_connector, return -1; } + ec->min_width = resources->min_width; + ec->max_width = resources->max_width; + ec->min_height = resources->min_height; + ec->max_height = resources->max_height; + ec->num_crtcs = resources->count_crtcs; memcpy(ec->crtcs, resources->crtcs, sizeof(uint32_t) * ec->num_crtcs);