From 4a6b52465df25a671f6298650182900e2f1407da Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Wed, 30 Aug 2017 13:55:47 +0900 Subject: [PATCH] eina: Add convenience eina_rectangle_equal @feature --- src/lib/eina/eina_inline_rectangle.x | 7 +++++++ src/lib/eina/eina_rectangle.h | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/lib/eina/eina_inline_rectangle.x b/src/lib/eina/eina_inline_rectangle.x index af257495eb..a6a07a43ed 100644 --- a/src/lib/eina/eina_inline_rectangle.x +++ b/src/lib/eina/eina_inline_rectangle.x @@ -47,6 +47,13 @@ eina_rectangle_coords_from(Eina_Rectangle *r, int x, int y, int w, int h) r->h = 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) { diff --git a/src/lib/eina/eina_rectangle.h b/src/lib/eina/eina_rectangle.h index 6934201cbc..e32dfcba5d 100644 --- a/src/lib/eina/eina_rectangle.h +++ b/src/lib/eina/eina_rectangle.h @@ -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" /**