Message ID | 20200528132605.18339-2-bparrot@ti.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | media: v4l2-rect.h: add enclosed rectangle helper | expand |
Hi Benoit, Thank you for the patch, W dniu 28.05.2020 o 15:26, Benoit Parrot pisze: > Add a helper function to check if one rectangle is enclosed inside > another. > > Signed-off-by: Benoit Parrot <bparrot@ti.com> Acked-by: Andrzej Pietrasiewicz <andrzejtp2010@gmail.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 >
Hi Benoit, Thank you for the patch. On Thu, May 28, 2020 at 2:26 PM Benoit Parrot <bparrot@ti.com> wrote: > > 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(+) > Reviewed-by: Lad Prabhakar <prabhakar.csengg@gmail.com> Cheers, --Prabhakar > 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 >
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
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(+)