eina: Add convenience eina_rectangle_equal
authorJean-Philippe Andre <jp.andre@samsung.com>
Wed, 30 Aug 2017 04:55:47 +0000 (13:55 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Wed, 30 Aug 2017 08:29:52 +0000 (17:29 +0900)
@feature

src/lib/eina/eina_inline_rectangle.x
src/lib/eina/eina_rectangle.h

index af25749..a6a07a4 100644 (file)
@@ -48,6 +48,13 @@ eina_rectangle_coords_from(Eina_Rectangle *r, int x, int y, int w, int h)
 }
 
 static inline Eina_Bool
+eina_rectangle_equal(const Eina_Rectangle *rect1, const Eina_Rectangle *rect2)
+{
+   return ((rect1->x == rect2->x) && (rect1->y == rect2->y) &&
+           (rect1->w == rect2->w) && (rect1->h == rect2->h));
+}
+
+static inline Eina_Bool
 eina_rectangles_intersect(const Eina_Rectangle *r1, const Eina_Rectangle *r2)
 {
        return (eina_spans_intersect(r1->x, r1->w, r2->x, r2->w) && eina_spans_intersect(r1->y, r1->h, r2->y, r2->h)) ? EINA_TRUE : EINA_FALSE;
index 6934201..e32dfcb 100644 (file)
@@ -531,6 +531,20 @@ EAPI void            eina_rectangle_pool_packing_set(Eina_Rectangle_Pool *pool,E
  */
 EAPI Eina_Rectangle_Outside eina_rectangle_outside_position(Eina_Rectangle *rect1, Eina_Rectangle *rect2);
 
+/**
+ * @brief Compares two rectangles for equality
+ *
+ * @param rect1 First rectangle. Must not be NULL.
+ * @param rect2 Second rectangle. Must not be NULL.
+ *
+ * @return EINA_TRUE if the rectangles are equal (x, y, w and h are all equal).
+ * No safety check is made on the rectangles, so they should be valid and non
+ * NULL for this function to be meaningful.
+ *
+ * @since 1.21
+ */
+static inline Eina_Bool eina_rectangle_equal(const Eina_Rectangle *rect1, const Eina_Rectangle *rect2) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+
 #include "eina_inline_rectangle.x"
 
 /**