From nobody Thu Dec 18 19:25:17 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 144E8181B95 for ; Wed, 17 Jul 2024 14:27:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721226435; cv=none; b=Y7hrBV4LO+HRKVgvNoEF93FcbVGaZOCIB9c7SE9hV7H73Gk/tMZ1Z7IWPL69ryn7vqULmiUEWHw1vVFhpp8J06CLm/3aGCEPgJV3M9CFGQiGI196IMnZE235C9S7WYGkY2BGnEn/qH3+e8PlNpKFltWomI11qVKLBoHKkKvJSb8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721226435; c=relaxed/simple; bh=XVcUh0+MXIkykzzJdBkRXQND1hZn+yZrPY9taHCPTJM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tkIb+p2Cs1rE1HlADGWlsQI9IR1l8KG878ilB1smOIk5i0AS//dzqiYd+aEdvImfClA2ywoVZV8S5PT2gDEOAHNfu738UW6ebEI4whGuDnE6hW+ypEHvRB+4pshNUNZtB02TRcBgqJWrugCqQl2aTYyL0M5HIUCX0sSBvB/tHy0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=bWcc/03D; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bWcc/03D" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721226433; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b/dXCS3ej2UQPDS9/FGrIg3C+WoRDbCH1/YcKbJTkek=; b=bWcc/03DCey8j7DlA4UhPzoWO9tdey4LTHPVlmiqFwg2ImqxcergbQ4Oi1urKfqYeTQg87 dszvsgKPqhwxq8Hq9j9bS0KmZN52k3x4hK0DG7S4ipw9eh5VI7LpZCaSINvBS+z+jL1Udk bVPzSXv8qvu8rcQzUSY7bvxQ60f3ptg= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-352-ADfkqruVM0eAs5fVhVzbjw-1; Wed, 17 Jul 2024 10:27:07 -0400 X-MC-Unique: ADfkqruVM0eAs5fVhVzbjw-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3E8BE1955BF7; Wed, 17 Jul 2024 14:27:05 +0000 (UTC) Received: from hydra.redhat.com (unknown [10.39.194.18]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 173701955D42; Wed, 17 Jul 2024 14:26:59 +0000 (UTC) From: Jocelyn Falempe To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , "Bjorn Roy Baron" , Benno Lossin , Andreas Hindborg , Alice Ryhl , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, rust-for-linux@vger.kernel.org, Danilo Krummrich Cc: Jocelyn Falempe Subject: [PATCH v4 2/4] drm/rect: Add drm_rect_overlap() Date: Wed, 17 Jul 2024 16:24:49 +0200 Message-ID: <20240717142644.1106060-3-jfalempe@redhat.com> In-Reply-To: <20240717142644.1106060-1-jfalempe@redhat.com> References: <20240717142644.1106060-1-jfalempe@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 Content-Type: text/plain; charset="utf-8" Check if two rectangles overlap. It's a bit similar to drm_rect_intersect() but this won't modify the rectangle. Simplifies a bit drm_panic. Signed-off-by: Jocelyn Falempe --- drivers/gpu/drm/drm_panic.c | 3 +-- include/drm/drm_rect.h | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_panic.c b/drivers/gpu/drm/drm_panic.c index fa147542d801..1693348b19a6 100644 --- a/drivers/gpu/drm/drm_panic.c +++ b/drivers/gpu/drm/drm_panic.c @@ -522,8 +522,7 @@ static void draw_panic_static_user(struct drm_scanout_b= uffer *sb) /* Fill with the background color, and draw text on top */ drm_panic_fill(sb, &r_screen, bg_color); =20 - if ((r_msg.x1 >=3D logo_width || r_msg.y1 >=3D logo_height) && - logo_width <=3D sb->width && logo_height <=3D sb->height) { + if (!drm_rect_overlap(&r_logo, &r_msg)) { if (logo_mono) drm_panic_blit(sb, &r_logo, logo_mono->data, DIV_ROUND_UP(logo_width, 8= ), fg_color); diff --git a/include/drm/drm_rect.h b/include/drm/drm_rect.h index 73fcb899a01d..7bafde747d56 100644 --- a/include/drm/drm_rect.h +++ b/include/drm/drm_rect.h @@ -238,6 +238,21 @@ static inline void drm_rect_fp_to_int(struct drm_rect = *dst, drm_rect_height(src) >> 16); } =20 +/** + * drm_rect_overlap - Check if two rectangles overlap + * @r1: first rectangle + * @r2: second rectangle + * + * RETURNS: + * %true if the rectangles overlap, %false otherwise. + */ +static inline bool drm_rect_overlap(const struct drm_rect *r1, + const struct drm_rect *r2) +{ + return (r1->x2 > r2->x1 && r2->x2 > r1->x1 && + r1->y2 > r2->y1 && r2->y2 > r1->y1); +} + bool drm_rect_intersect(struct drm_rect *r, const struct drm_rect *clip); bool drm_rect_clip_scaled(struct drm_rect *src, struct drm_rect *dst, const struct drm_rect *clip); --=20 2.45.2