From: Benoit Parrot <bparrot@ti.com> To: Hans Verkuil <hverkuil@xs4all.nl>, Prabhakar Lad <prabhakar.csengg@gmail.com>, Kyungmin Park <kyungmin.park@samsung.com>, Kukjin Kim <kgene@kernel.org>, Sylwester Nawrocki <s.nawrocki@samsung.com>, Krzysztof Kozlowski <krzk@kernel.org>, Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>, Jacek Anaszewski <jacek.anaszewski@gmail.com> Cc: <linux-media@vger.kernel.org>, <linux-kernel@vger.kernel.org>, Benoit Parrot <bparrot@ti.com> Subject: [Patch 1/2] media: v4l2-rect.h: add enclosed rectangle helper Date: Thu, 28 May 2020 08:26:04 -0500 Message-ID: <20200528132605.18339-2-bparrot@ti.com> (raw) In-Reply-To: <20200528132605.18339-1-bparrot@ti.com> Add a helper function to check if one rectangle is enclosed inside another. Signed-off-by: Benoit Parrot <bparrot@ti.com> --- include/media/v4l2-rect.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/media/v4l2-rect.h b/include/media/v4l2-rect.h index 8800a640c224..bd587d0c0dc3 100644 --- a/include/media/v4l2-rect.h +++ b/include/media/v4l2-rect.h @@ -184,4 +184,24 @@ static inline bool v4l2_rect_overlap(const struct v4l2_rect *r1, return true; } +/** + * v4l2_rect_enclosed() - is r1 enclosed in r2? + * @r1: rectangle. + * @r2: rectangle. + * + * Returns true if @r1 is enclosed in @r2. + */ +static inline bool v4l2_rect_enclosed(struct v4l2_rect *r1, + struct v4l2_rect *r2) +{ + if (r1->left < r2->left || r1->top < r2->top) + return false; + if (r1->left + r1->width > r2->left + r2->width) + return false; + if (r1->top + r1->height > r2->top + r2->height) + return false; + + return true; +} + #endif -- 2.17.1
next prev parent reply other threads:[~2020-05-28 13:26 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-05-28 13:26 [Patch 0/2] " Benoit Parrot 2020-05-28 13:26 ` Benoit Parrot [this message] 2020-05-29 11:57 ` [Patch 1/2] " Andrzej Pietrasiewicz 2020-05-30 11:51 ` Lad, Prabhakar 2020-05-28 13:26 ` [Patch 2/2] media: use v4l2_rect_enclosed helper Benoit Parrot 2020-05-29 11:59 ` Andrzej Pietrasiewicz 2020-05-30 11:53 ` Lad, Prabhakar
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200528132605.18339-2-bparrot@ti.com \ --to=bparrot@ti.com \ --cc=andrzejtp2010@gmail.com \ --cc=hverkuil@xs4all.nl \ --cc=jacek.anaszewski@gmail.com \ --cc=kgene@kernel.org \ --cc=krzk@kernel.org \ --cc=kyungmin.park@samsung.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-media@vger.kernel.org \ --cc=prabhakar.csengg@gmail.com \ --cc=s.nawrocki@samsung.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Unnamed repository; edit this file 'description' to name the repository. This inbox may be cloned and mirrored by anyone: git clone --mirror http://archive.lwn.net:8080/linux-media/0 linux-media/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 linux-media linux-media/ http://archive.lwn.net:8080/linux-media \ linux-media@vger.kernel.org lwn-linux-media@archive.lwn.net public-inbox-index linux-media Example config snippet for mirrors. Newsgroup available over NNTP: nntp://archive.lwn.net/lwn.kernel.linux-media AGPL code for this site: git clone https://public-inbox.org/public-inbox.git