diff mbox

[05/22,media] v4l2-rect.h: add position and equal helpers

Message ID 20180628162054.25613-6-m.felsch@pengutronix.de (mailing list archive)
State New, archived
Headers show

Commit Message

Marco Felsch June 28, 2018, 4:20 p.m. UTC
Add two helper functions to check if two rectangles have the same
position (top/left) and if two rectangles equals (same size and
same position).

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 include/media/v4l2-rect.h | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

Comments

Sakari Ailus June 29, 2018, 2:12 p.m. UTC | #1
On Thu, Jun 28, 2018 at 06:20:37PM +0200, Marco Felsch wrote:
> Add two helper functions to check if two rectangles have the same
> position (top/left) and if two rectangles equals (same size and
> same position).
> 
> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
diff mbox

Patch

diff --git a/include/media/v4l2-rect.h b/include/media/v4l2-rect.h
index 595c3ba05f23..1ae25f599a6f 100644
--- a/include/media/v4l2-rect.h
+++ b/include/media/v4l2-rect.h
@@ -82,6 +82,33 @@  static inline bool v4l2_rect_same_size(const struct v4l2_rect *r1,
 	return r1->width == r2->width && r1->height == r2->height;
 }
 
+/**
+ * v4l2_rect_same_position() - return true if r1 has the same position as r2
+ * @r1: rectangle.
+ * @r2: rectangle.
+ *
+ * Return true if both rectangles have the same position
+ */
+static inline bool v4l2_rect_same_position(const struct v4l2_rect *r1,
+					   const struct v4l2_rect *r2)
+{
+	return r1->top == r2->top && r1->left == r2->left;
+
+}
+
+/**
+ * v4l2_rect_equal() - return true if r1 equals r2
+ * @r1: rectangle.
+ * @r2: rectangle.
+ *
+ * Return true if both rectangles have the same size and position.
+ */
+static inline bool v4l2_rect_equal(const struct v4l2_rect *r1,
+				   const struct v4l2_rect *r2)
+{
+	return v4l2_rect_same_size(r1, r2) && v4l2_rect_same_position(r1, r2);
+}
+
 /**
  * v4l2_rect_intersect() - calculate the intersection of two rects.
  * @r: intersection of @r1 and @r2.