hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/include/media/v4l2-rect.h
....@@ -83,6 +83,32 @@
8383 }
8484
8585 /**
86
+ * v4l2_rect_same_position() - return true if r1 has the same position as r2
87
+ * @r1: rectangle.
88
+ * @r2: rectangle.
89
+ *
90
+ * Return true if both rectangles have the same position
91
+ */
92
+static inline bool v4l2_rect_same_position(const struct v4l2_rect *r1,
93
+ const struct v4l2_rect *r2)
94
+{
95
+ return r1->top == r2->top && r1->left == r2->left;
96
+}
97
+
98
+/**
99
+ * v4l2_rect_equal() - return true if r1 equals r2
100
+ * @r1: rectangle.
101
+ * @r2: rectangle.
102
+ *
103
+ * Return true if both rectangles have the same size and position.
104
+ */
105
+static inline bool v4l2_rect_equal(const struct v4l2_rect *r1,
106
+ const struct v4l2_rect *r2)
107
+{
108
+ return v4l2_rect_same_size(r1, r2) && v4l2_rect_same_position(r1, r2);
109
+}
110
+
111
+/**
86112 * v4l2_rect_intersect() - calculate the intersection of two rects.
87113 * @r: intersection of @r1 and @r2.
88114 * @r1: rectangle.
....@@ -158,4 +184,24 @@
158184 return true;
159185 }
160186
187
+/**
188
+ * v4l2_rect_enclosed() - is r1 enclosed in r2?
189
+ * @r1: rectangle.
190
+ * @r2: rectangle.
191
+ *
192
+ * Returns true if @r1 is enclosed in @r2.
193
+ */
194
+static inline bool v4l2_rect_enclosed(struct v4l2_rect *r1,
195
+ struct v4l2_rect *r2)
196
+{
197
+ if (r1->left < r2->left || r1->top < r2->top)
198
+ return false;
199
+ if (r1->left + r1->width > r2->left + r2->width)
200
+ return false;
201
+ if (r1->top + r1->height > r2->top + r2->height)
202
+ return false;
203
+
204
+ return true;
205
+}
206
+
161207 #endif