1 /* EINA - EFL data type library
2  * Copyright (C) 2007-2008 Jorge Luis Zapata Muga
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library;
16  * if not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef EINA_RECTANGLE_H_
20 #define EINA_RECTANGLE_H_
21 
22 #include "eina_types.h"
23 
24 /**
25  * @addtogroup Eina_Rectangle_Group Rectangle
26  *
27  * @brief These functions provide rectangle management.
28  */
29 
30 /**
31  * @addtogroup Eina_Tools_Group Tools
32  *
33  * @{
34  */
35 
36 /**
37  * @defgroup Eina_Rectangle_Group Rectangle
38  *
39  * @{
40  */
41 
42 /** A zero-size rectangle. */
43 #define EINA_RECTANGLE_INIT { 0, 0, 0, 0}
44 /** A format string useful for printf-like functions. */
45 #define EINA_RECTANGLE_FORMAT "dx%d - %dx%d"
46 /** Separates the components of the rectangle structure into a comma-separated list,
47  * so they can be used as parameters. */
48 #define EINA_RECTANGLE_ARGS(r) (r)->x, (r)->y, (r)->w, (r)->h
49 
50 /** Creates an instance of an #Eina_Rect */
51 #define EINA_RECT(x, y, w, h) ((Eina_Rect) { { (x), (y), (w), (h) } })
52 /** A zero-size rectangle that can be used to initialize #Eina_Rect structures. */
53 #define EINA_RECT_ZERO() { EINA_RECTANGLE_INIT }
54 /** A zero-size rectangle that can be used to initialize #Eina_Rect structures. */
55 #define EINA_RECT_EMPTY() ((Eina_Rect) EINA_RECT_ZERO())
56 
57 /** Creates an instance of an #Eina_Position2D */
58 #define EINA_POSITION2D(x, y) ((Eina_Position2D) { (x), (y) })
59 /** Creates an instance of an #Eina_Size2D */
60 #define EINA_SIZE2D(x, y) ((Eina_Size2D) { (x), (y) })
61 
62 /** @brief A 2D position in pixel coordinates */
63 typedef struct _Eina_Position2D
64 {
65    int x, y;
66 } Eina_Position2D;
67 
68 /** @brief A 2D size in pixel coordinates */
69 typedef struct _Eina_Size2D
70 {
71    int w, h;
72 } Eina_Size2D;
73 
74 
75 /**
76  * @brief convenience macro for comparing two Eina_Size2D structs
77  * @param[in] a An Eina_Size2D
78  * @param[in] b An Eina_Size2D
79  * @return 1 if the structs are equal, 0 if they are not
80  * @since 1.24
81  */
82 #define EINA_SIZE2D_EQ(a, b) \
83   (((a).w == (b).w) && ((a).h == (b).h))
84 
85 /**
86  * @brief convenience macro for comparing two Eina_Position2D structs
87  * @param[in] a An Eina_Position2D
88  * @param[in] b An Eina_Position2D
89  * @return 1 if the structs are equal, 0 if they are not
90  * @since 1.24
91  */
92 #define EINA_POSITION2D_EQ(a, b) \
93   (((a).x == (b).x) && ((a).y == (b).y))
94 /**
95  * @brief Convenience macro for getting the distance from one point to another
96  * @param[in] a An Eina_Position2D
97  * @param[in] b An Eina_Position2D
98  * @return The distance between the two points.
99  * @since 1.24
100  */
101 #define EINA_POSITION2D_DISTANCE(a, b) \
102   sqrt((a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y))
103 
104 /**
105  * @typedef Eina_Rectangle
106  * Simple rectangle structure.
107  */
108 typedef struct _Eina_Rectangle
109 {
110    int x; /**< top-left x coordinate of rectangle */
111    int y; /**< top-left y coordinate of rectangle */
112    int w; /**< width of rectangle */
113    int h; /**< height of rectangle */
114 } Eina_Rectangle;
115 
116 /**
117  * @typedef Eina_Rect
118  * A convenient rectangle structure which can be accessed in different ways.
119  */
120 typedef union _Eina_Rect
121 {
122    Eina_Rectangle rect; /**< Embedded simple rectangle structure */
123    struct {
124       Eina_Position2D pos; /**< Top-left corner in pixels */
125       Eina_Size2D size; /**< Size in pixels */
126    };
127    struct {
128       int x; /**< Top-left x coordinate of rectangle */
129       int y; /**< Top-left y coordinate of rectangle */
130       int w; /**< Width of rectangle */
131       int h; /**< Height of rectangle */
132    };
133 } Eina_Rect;
134 
135 /**
136  * @typedef Eina_Rectangle_Pool
137  * Type for an opaque pool of rectangles.
138  */
139 typedef struct _Eina_Rectangle_Pool Eina_Rectangle_Pool;
140 
141 /**
142  * @typedef Eina_Rectangle_Packing
143  * Type for an Eina Pool based on a packing algorithm.
144  * @since 1.11
145  */
146 typedef enum {
147   Eina_Packing_Descending,            /**< Current */
148   Eina_Packing_Ascending,             /**< sorting in ascending order */
149   Eina_Packing_Bottom_Left,           /**< sorting in bottom left fashion */
150   Eina_Packing_Bottom_Left_Skyline,   /**< bottom left skyline  */
151   Eina_Packing_Bottom_Left_Skyline_Improved   /**< optimized bottom left skyline  */
152 } Eina_Rectangle_Packing;
153 
154 /**
155  * @typedef Eina_Rectangle_Outside
156  * Enumeration of the positions around a rectangle.
157  * @since 1.19
158  */
159 typedef enum {
160     EINA_RECTANGLE_OUTSIDE_TOP = 1,    /**< Position is over the rectangle */
161     EINA_RECTANGLE_OUTSIDE_LEFT = 2,   /**< Position is to the left of the rectangle */
162     EINA_RECTANGLE_OUTSIDE_BOTTOM = 4, /**< Position is below the rectangle */
163     EINA_RECTANGLE_OUTSIDE_RIGHT = 8   /**< Position is to the right of the rectangle */
164 } Eina_Rectangle_Outside;
165 
166 
167 /**
168  * @brief Checks if the given spans intersect.
169  *
170  * @param[in] c1 The column of the first span.
171  * @param[in] l1 The length of the first span.
172  * @param[in] c2 The column of the second span.
173  * @param[in] l2 The length of the second span.
174  * @return #EINA_TRUE if the given spans intersect, #EINA_FALSE otherwise.
175  */
176 static inline int         eina_spans_intersect(int c1, int l1, int c2, int l2) EINA_WARN_UNUSED_RESULT;
177 
178 /**
179  * @brief Checks if the given rectangle is empty.
180  *
181  * @param[in] rect The rectangle to check.
182  * @return #EINA_TRUE if the rectangle @p r is empty, #EINA_FALSE
183  * otherwise.
184  *
185  * No check is done on @p r, so it must be a valid rectangle.
186  */
187 static inline Eina_Bool   eina_rectangle_is_empty(const Eina_Rectangle *rect) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
188 
189 /**
190  * @brief Sets the coordinates and size of a rectangle.
191  *
192  * @param[out] rect The rectangle.
193  * @param[in] x The X coordinate of the rectangle's top-left corner.
194  * @param[in] y The Y coordinate of the rectangle's top-left corner.
195  * @param[in] w The width of the rectangle.
196  * @param[in] h The height of the rectangle.
197  *
198  * This function sets its top-left X coordinate to @p x, its top-left
199  * Y coordinate to @p y, its width to @p w and its height to @p h.
200  *
201  * No check is done on @p r, so it must be a valid rectangle.
202  */
203 static inline void        eina_rectangle_coords_from(Eina_Rectangle *rect, int x, int y, int w, int h) EINA_ARG_NONNULL(1);
204 
205 /**
206  * @brief Checks if two rectangles intersect.
207  *
208  * @param[in] rect1 The first rectangle.
209  * @param[in] rect2 The second rectangle.
210  * @return #EINA_TRUE if the rectangles @p rect1 and @p rect2 intersect,
211  * #EINA_FALSE otherwise.
212  *
213  * No check is done on @p rect1 and @p rect2, so they must be valid
214  * rectangles.
215  */
216 static inline Eina_Bool   eina_rectangles_intersect(const Eina_Rectangle *rect1, const Eina_Rectangle *rect2) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
217 
218 /**
219  * @brief Checks if the given X-coordinate is in the rectangle.
220  *
221  * @param[in] rect The rectangle.
222  * @param[in] x The X coordinate.
223  * @return #EINA_TRUE if @p x is between the rectangle's left and right
224  * edges, #EINA_FALSE otherwise.
225  *
226  * No check is done on @p r, so it must be a valid rectangle.
227  */
228 static inline Eina_Bool   eina_rectangle_xcoord_inside(const Eina_Rectangle *rect, int x) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
229 
230 /**
231  * @brief Checks if the given Y-coordinate is in the rectangle.
232  *
233  * @param[in] rect The rectangle.
234  * @param[in] y The Y coordinate.
235  * @return #EINA_TRUE if @p y is between the rectangle's top and bottom
236  * edges, #EINA_FALSE otherwise.
237  *
238  * No check is done on @p r, so it must be a valid rectangle.
239  */
240 static inline Eina_Bool   eina_rectangle_ycoord_inside(const Eina_Rectangle *rect, int y) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
241 
242 /**
243  * @brief Checks if the given point is inside the rectangle.
244  *
245  * @param[in] rect The rectangle.
246  * @param[in] x The x coordinate of the point.
247  * @param[in] y The y coordinate of the point.
248  * @return #EINA_TRUE if the point (@p x, @p y) is within the edges of
249  * @p r, #EINA_FALSE otherwise.
250  *
251  * No check is done on @p r, so it must be a valid rectangle.
252  */
253 static inline Eina_Bool   eina_rectangle_coords_inside(const Eina_Rectangle *rect, int x, int y) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
254 
255 /**
256  * @brief Gets the union of two rectangles.
257  *
258  * @param[in,out] dst The first rectangle.
259  * @param[in] src The second rectangle.
260  *
261  * Changes @p dst to be the bounding box of both rectangles @p dst and
262  * @p src.
263  *
264  * No check is done on @p dst or @p src, so they must be valid
265  * rectangles.
266  */
267 static inline void        eina_rectangle_union(Eina_Rectangle *dst, const Eina_Rectangle *src) EINA_ARG_NONNULL(1, 2);
268 
269 /**
270  * @brief Gets the intersection of two rectangles.
271  *
272  * @param[in,out] dst The first rectangle.
273  * @param[in] src The second rectangle.
274  * @return #EINA_TRUE if the rectangles intersect, #EINA_FALSE
275  * otherwise.
276  *
277  * Changes @p dst to be the rectangle represented by the intersection of
278  * @p dst and @p src. @p dst is unchanged if the two rectangles do not
279  * intersect.
280  *
281  * No check is done on @p dst or @p src, so they must be valid
282  * rectangles.
283  */
284 static inline Eina_Bool   eina_rectangle_intersection(Eina_Rectangle *dst, const Eina_Rectangle *src) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
285 
286 /**
287  * @brief FIXME I am useless and used by no one
288  *
289  * @param in The inner rectangle.
290  * @param out The outer rectangle.
291  * @param res The resulting rectangle.
292  *
293  */
294 static inline void        eina_rectangle_rescale_in(const Eina_Rectangle *out, const Eina_Rectangle *in, Eina_Rectangle *res) EINA_ARG_NONNULL(1, 2, 3);
295 
296 /**
297  * @brief FIXME I am useless and used by no one
298  *
299  * @param in The inner rectangle.
300  * @param out The outer rectangle.
301  * @param res The resulting rectangle.
302  *
303  */
304 static inline void        eina_rectangle_rescale_out(const Eina_Rectangle *out, const Eina_Rectangle *in, Eina_Rectangle *res) EINA_ARG_NONNULL(1, 2, 3);
305 
306 /**
307  * @brief Tells whether a rectangle is valid.
308  *
309  * @param[in] rect The rectangle.
310  * @return #EINA_TRUE if the rectangle is valid, #EINA_FALSE otherwise.
311  *
312  * This function checks if both width and height attributes of the rectangle are
313  * positive integers. If so, the rectangle is considered valid, else the
314  * rectangle is invalid.
315  */
316 static inline Eina_Bool   eina_rectangle_is_valid(const Eina_Rectangle *rect) EINA_ARG_NONNULL(1);
317 
318 /**
319  * @brief Gets the rectangle's maximum X coordinate.
320  *
321  * @param[in] rect The rectangle.
322  * @return The maximum X coordinate.
323  *
324  * This function calculates the maximum X coordinate of the rectangle by summing
325  * the @p width with the current @p x coordinate of the rectangle.
326  */
327 static inline int         eina_rectangle_max_x(Eina_Rectangle *rect) EINA_ARG_NONNULL(1);
328 
329 /**
330  * @brief Gets the rectangle maximum Y coordinate.
331  *
332  * @param[in] rect The rectangle.
333  * @return The maximum Y coordinate.
334  *
335  * This function calculates the maximum Y coordinate of the rectangle by summing
336  * the @p height with the current @p y coordinate of the rectangle.
337  */
338 static inline int         eina_rectangle_max_y(Eina_Rectangle *rect) EINA_ARG_NONNULL(1);
339 
340 /**
341  * @brief Slices a rectangle vertically into two subrectangles.
342  *
343  * @param[in] rect The rectangle to slice.
344  * @param[out] slice The sliced part of the rectangle.
345  * @param[out] remainder The left over part of the rectangle after slicing.
346  * @param[in] amount The slice location's horizontal distance from the left.
347  * @return #EINA_TRUE if the cut succeeds, #EINA_FALSE otherwise.
348  *
349  * Cut a rectangle vertically at a distance @p amount from the
350  * rectangle's left edge.  If the @p amount value is greater than the
351  * rectangle's width, no cut is performed and #EINA_FALSE is returned.
352  */
353 static inline Eina_Bool   eina_rectangle_x_cut(Eina_Rectangle *rect, Eina_Rectangle *slice, Eina_Rectangle *remainder, int amount) EINA_ARG_NONNULL(1);
354 
355 /**
356  * @brief Slices a rectangle horizontally into two subrectangles.
357  *
358  * @param[in] rect The rectangle to slice.
359  * @param[out] slice The sliced part of the rectangle.
360  * @param[out] remainder The left over part of the rectangle after slicing.
361  * @param[in] amount The slice location's vertical distance from the bottom.
362  * @return #EINA_TRUE if the cut succeeds, #EINA_FALSE otherwise
363  *
364  * Cut a rectangle horizontally at a distance @p amount from the
365  * rectangle's bottom edge. If the @p amount value is greater than the
366  * rectangle's height, no cut is performed and #EINA_FALSE is returned.
367  */
368 static inline Eina_Bool   eina_rectangle_y_cut(Eina_Rectangle *rect, Eina_Rectangle *slice, Eina_Rectangle *remainder, int amount) EINA_ARG_NONNULL(1);
369 
370 /**
371  * @brief Slices a rectangle vertically starting from right edge.
372  *
373  * @param[in] rect The rectangle to slice.
374  * @param[out] slice The sliced part of the rectangle.
375  * @param[out] remainder The left over part of the rectangle after slicing.
376  * @param[in] amount The slice location's horizontal distance from the right.
377  * @return #EINA_TRUE if the cut succeeds, #EINA_FALSE otherwise
378  *
379  * Cut a rectangle vertically at a distance @p amount from the
380  * rectangle's right edge.  If the @p amount value is greater than the
381  * rectangle's width, no cut is performed and #EINA_FALSE is returned.
382  */
383 static inline Eina_Bool   eina_rectangle_width_cut(Eina_Rectangle *rect, Eina_Rectangle *slice, Eina_Rectangle *remainder, int amount) EINA_ARG_NONNULL(1);
384 
385 /**
386  * @brief Slices a rectangle horizontally starting from top edge.
387  *
388  * @param[in] rect The rectangle to slice.
389  * @param[out] slice The sliced part of the rectangle.
390  * @param[out] remainder The left over part of the rectangle after slicing.
391  * @param[in] amount The slice location's vertical distance from the top.
392  * @return #EINA_TRUE if the cut succeeds, #EINA_FALSE otherwise.
393  *
394  * Cut a rectangle horizontally at a distance @p amount from the
395  * rectangle's top edge.  If the @p amount value is greater than the
396  * rectangle width, no cut is performed and #EINA_FALSE is returned.
397  */
398 static inline Eina_Bool   eina_rectangle_height_cut(Eina_Rectangle *rect, Eina_Rectangle *slice, Eina_Rectangle *remainder, int amount) EINA_ARG_NONNULL(1);
399 
400 /**
401  * @brief Subtracts two rectangles and returns the differences.
402  *
403  * @param[in] rect The minuend rectangle.
404  * @param[in] other The subtrahend rectangle.
405  * @param[out] out An array of differences between the two rectangles.
406  * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
407  *
408  * This function subtracts two rectangles and stores the resulting
409  * differences into the @p out array.  There will be at most four
410  * differences; use eina_rectangle_is_valid to confirm the exact number.
411  */
412 static inline Eina_Bool   eina_rectangle_subtract(Eina_Rectangle *rect, Eina_Rectangle *other, Eina_Rectangle out[4]) EINA_ARG_NONNULL(1);
413 
414 /**
415  * @brief Adds a rectangle in a new pool.
416  *
417  * @param[in] w The width of the rectangle.
418  * @param[in] h The height of the rectangle.
419  * @return A newly allocated pool on success, @c NULL otherwise.
420  *
421  * This function adds the rectangle of size (@p width, @p height) to a
422  * new pool. If the pool can not be created, @c NULL is
423  * returned. Otherwise the newly allocated pool is returned.
424  */
425 EAPI Eina_Rectangle_Pool *eina_rectangle_pool_new(int w, int h) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
426 
427 /**
428  * @brief Returns the pool of the given rectangle.
429  *
430  * @param[in] rect The rectangle.
431  * @return The pool of the given rectangle.
432  *
433  * This function returns the pool in which @p rect is. If  @p rect is
434  * @c NULL, @c NULL is returned.
435  */
436 EAPI Eina_Rectangle_Pool *eina_rectangle_pool_get(Eina_Rectangle *rect) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
437 
438 /**
439  * @brief Returns the width and height of the given pool.
440  *
441  * @param[in] pool The pool.
442  * @param[out] w The returned width.
443  * @param[out] h The returned height.
444  * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
445  *
446  * This function returns the width and height of @p pool and store
447  * them in respectively @p w and @p h if they are not @c NULL. If
448  * @p pool is @c NULL, #EINA_FALSE is returned. Otherwise #EINA_TRUE is
449  * returned.
450  */
451 EAPI Eina_Bool            eina_rectangle_pool_geometry_get(Eina_Rectangle_Pool *pool, int *w, int *h) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
452 
453 /**
454  * @brief Gets the data from the given pool.
455  *
456  * @param[in] pool The pool.
457  * @return The returned data.
458  *
459  * This function gets the data from @p pool set by
460  * eina_rectangle_pool_data_set(). If @p pool is @c NULL, this
461  * function returns @c NULL.
462  */
463 EAPI void                *eina_rectangle_pool_data_get(Eina_Rectangle_Pool *pool) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
464 
465 /**
466  * @brief Sets the data to the given pool.
467  *
468  * @param[in,out] pool The pool.
469  * @param[in] data The data to set.
470  *
471  * This function sets @p data to @p pool. If @p pool is @c NULL, this
472  * function does nothing.
473  */
474 EAPI void                 eina_rectangle_pool_data_set(Eina_Rectangle_Pool *pool, const void *data) EINA_ARG_NONNULL(1);
475 
476 /**
477  * @brief Frees the given pool.
478  *
479  * @param[in] pool The pool to free.
480  *
481  * This function frees the allocated data of @p pool. If @p pool is
482  * @c NULL, this function returned immediately.
483  */
484 EAPI void                 eina_rectangle_pool_free(Eina_Rectangle_Pool *pool) EINA_ARG_NONNULL(1);
485 
486 /**
487  * @brief Returns the number of rectangles in the given pool.
488  *
489  * @param[in] pool The pool.
490  * @return The number of rectangles in the pool.
491  *
492  * This function returns the number of rectangles in @p pool.
493  */
494 EAPI int                  eina_rectangle_pool_count(Eina_Rectangle_Pool *pool) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
495 
496 /**
497  * @brief Requests a rectangle of given size in the given pool.
498  *
499  * @param[in,out] pool The pool.
500  * @param[in] w The width of the rectangle to request.
501  * @param[in] h The height of the rectangle to request.
502  * @return The requested rectangle on success, @c NULL otherwise.
503  *
504  * This function retrieves from @p pool the rectangle of width @p w and
505  * height @p h. If @p pool is @c NULL, or @p w or @p h are non-positive,
506  * the function returns @c NULL. If @p w or @p h are greater than the
507  * pool size, the function returns @c NULL. On success, the function
508  * returns the rectangle which matches the size (@p w, @p h).
509  * Otherwise it returns @c NULL.
510  */
511 EAPI Eina_Rectangle      *eina_rectangle_pool_request(Eina_Rectangle_Pool *pool, int w, int h) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
512 
513 /**
514  * @brief Removes the given rectangle from the pool.
515  *
516  * @param[in,out] rect The rectangle to remove from the pool.
517  *
518  * This function removes @p rect from the pool. If @p rect is
519  * @c NULL, the function returns immediately. Otherwise it removes @p
520  * rect from the pool.
521  */
522 EAPI void                 eina_rectangle_pool_release(Eina_Rectangle *rect) EINA_ARG_NONNULL(1);
523 
524 /**
525  * @def EINA_RECTANGLE_SET
526  * @brief Definition for the macro to set the values of a #Eina_Rectangle.
527  *
528  * @param[out] Rectangle The rectangle.
529  * @param[in] X The X coordinate of the top left corner of the rectangle.
530  * @param[in] Y The Y coordinate of the top left corner of the rectangle.
531  * @param[in] W The width of the rectangle.
532  * @param[in] H The height of the rectangle.
533  *
534  * This macro set the values of @p Rectangle. @p X and @p Y are the
535  * coordinates of the top left corner of @p Rectangle, @p W is its
536  * width and @p H is its height.
537  */
538 #define EINA_RECTANGLE_SET(Rectangle, X, Y, W, H) \
539     {						  \
540       (Rectangle)->x = X;			  \
541       (Rectangle)->y = Y;			  \
542       (Rectangle)->w = W;			  \
543       (Rectangle)->h = H;			  \
544     }
545 
546 /**
547  * @def EINA_RECT_SET
548  * Functionally equivalent to #EINA_RECTANGLE_SET
549  */
550 #define EINA_RECT_SET(rect, x, y, w, h) do { EINA_RECTANGLE_SET((&rect), x, y, w, h) } while (0)
551 
552 
553 /**
554  * @brief Creates a new rectangle.
555  *
556  * @param[in] x The X coordinate of the top left corner of the rectangle.
557  * @param[in] y The Y coordinate of the top left corner of the rectangle.
558  * @param[in] w The width of the rectangle.
559  * @param[in] h The height of the rectangle.
560  * @return The new rectangle on success, @ NULL otherwise.
561  *
562  * This function creates a rectangle whose top left corner has the
563  * coordinates (@p x, @p y), with height @p w and height @p h and adds
564  * it to the rectangles pool.
565  *
566  * No check is done on @p w and @p h.
567  */
568 EAPI Eina_Rectangle *eina_rectangle_new(int x, int y, int w, int h) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
569 
570 /**
571  * @brief Frees the given rectangle.
572  *
573  * @param[in] rect The rectangle to free.
574  *
575  * This function removes @p rect from the rectangles pool.
576  */
577 EAPI void            eina_rectangle_free(Eina_Rectangle *rect) EINA_ARG_NONNULL(1);
578 
579 /**
580  * @brief Sets the type of given rectangle pool.
581  *
582  * @param[in,out] pool The rectangle pool for which type is to be set.
583  * @param[in] type Type of Eina Pool based on packing algorithm.
584  *
585  * This function sets @p type of @p pool.
586  * @see Eina_Rectangle_Packing
587  * @since 1.11
588  */
589 EAPI void            eina_rectangle_pool_packing_set(Eina_Rectangle_Pool *pool,Eina_Rectangle_Packing type) EINA_ARG_NONNULL(1);
590 
591 /**
592  * @brief calculates where rect2 is outside of rect1.
593  *
594  * @param[in] rect1 The rect to use as anchor
595  * @param[in] rect2 The rect to look for outside positions
596  *
597  * @return An OR'd map of Eina_Rectangle_Outside values
598  * @since 1.19
599  */
600 EAPI Eina_Rectangle_Outside eina_rectangle_outside_position(Eina_Rectangle *rect1, Eina_Rectangle *rect2);
601 
602 /**
603  * @brief Compares two rectangles for equality
604  *
605  * @param[in] rect1 First rectangle. Must not be NULL.
606  * @param[in] rect2 Second rectangle. Must not be NULL.
607  * @return EINA_TRUE if the rectangles are equal (x, y, w and h are all equal).
608  *
609  * No check is made on the rectangles, so they should be valid and non
610  * NULL for this function to be meaningful.
611  *
612  * @since 1.21
613  */
614 static inline Eina_Bool eina_rectangle_equal(const Eina_Rectangle *rect1, const Eina_Rectangle *rect2) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
615 
616 #include "eina_inline_rectangle.x"
617 
618 /**
619  * @}
620  */
621 
622 /**
623  * @}
624  */
625 
626 #endif /*_EINA_RECTANGLE_H_*/
627