These functions provide rectangle management. More...

Data Structures

struct  _Eina_Rectangle
 

Macros

#define EINA_RECTANGLE_INIT   { 0, 0, 0, 0}
 
#define EINA_RECTANGLE_FORMAT   "dx%d - %dx%d"
 
#define EINA_RECTANGLE_ARGS(r)   (r)->x, (r)->y, (r)->w, (r)->h
 
#define EINA_RECTANGLE_SET(Rectangle, X, Y, W, H)
 Macro to set the values of a Eina_Rectangle. More...
 

Typedefs

typedef struct _Eina_Rectangle Eina_Rectangle
 Simple rectangle structure.
 
typedef struct _Eina_Rectangle_Pool Eina_Rectangle_Pool
 Type for an opaque pool of rectangle.
 

Functions

static int eina_spans_intersect (int c1, int l1, int c2, int l2) EINA_WARN_UNUSED_RESULT
 
static Eina_Bool eina_rectangle_is_empty (const Eina_Rectangle *r) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT
 
static void eina_rectangle_coords_from (Eina_Rectangle *r, int x, int y, int w, int h) EINA_ARG_NONNULL(1)
 
static Eina_Bool eina_rectangles_intersect (const Eina_Rectangle *r1, const Eina_Rectangle *r2) EINA_ARG_NONNULL(1
 
static Eina_Bool eina_rectangle_xcoord_inside (const Eina_Rectangle *r, int x) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT
 
static Eina_Bool eina_rectangle_ycoord_inside (const Eina_Rectangle *r, int y) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT
 
static Eina_Bool eina_rectangle_coords_inside (const Eina_Rectangle *r, int x, int y) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT
 
static void eina_rectangle_union (Eina_Rectangle *dst, const Eina_Rectangle *src) EINA_ARG_NONNULL(1
 
static void static Eina_Bool eina_rectangle_intersection (Eina_Rectangle *dst, const Eina_Rectangle *src) EINA_ARG_NONNULL(1
 
static void eina_rectangle_rescale_in (const Eina_Rectangle *out, const Eina_Rectangle *in, Eina_Rectangle *res) EINA_ARG_NONNULL(1
 
static void static void eina_rectangle_rescale_out (const Eina_Rectangle *out, const Eina_Rectangle *in, Eina_Rectangle *res) EINA_ARG_NONNULL(1
 
static void static void static Eina_Bool eina_rectangle_is_valid (const Eina_Rectangle *r) EINA_ARG_NONNULL(1)
 
static Eina_Bool eina_rectangle_x_cut (Eina_Rectangle *thiz, Eina_Rectangle *slice, Eina_Rectangle *remainder, int amount) EINA_ARG_NONNULL(1)
 
static Eina_Bool eina_rectangle_y_cut (Eina_Rectangle *thiz, Eina_Rectangle *slice, Eina_Rectangle *remainder, int amount) EINA_ARG_NONNULL(1)
 
static Eina_Bool eina_rectangle_width_cut (Eina_Rectangle *thiz, Eina_Rectangle *slice, Eina_Rectangle *remainder, int amount) EINA_ARG_NONNULL(1)
 
static Eina_Bool eina_rectangle_height_cut (Eina_Rectangle *thiz, Eina_Rectangle *slice, Eina_Rectangle *remainder, int amount) EINA_ARG_NONNULL(1)
 
static Eina_Bool eina_rectangle_subtract (Eina_Rectangle *thiz, Eina_Rectangle *other, Eina_Rectangle out[4]) EINA_ARG_NONNULL(1)
 
EAPI Eina_Rectangle_Pooleina_rectangle_pool_new (int w, int h) EINA_MALLOC EINA_WARN_UNUSED_RESULT
 Add a rectangle in a new pool. More...
 
EAPI Eina_Rectangle_Pooleina_rectangle_pool_get (Eina_Rectangle *rect) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1)
 Return the pool of the given rectangle. More...
 
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
 Return the width and height of the given pool. More...
 
EAPI void * eina_rectangle_pool_data_get (Eina_Rectangle_Pool *pool) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1)
 Get the data from the given pool. More...
 
EAPI void eina_rectangle_pool_data_set (Eina_Rectangle_Pool *pool, const void *data) EINA_ARG_NONNULL(1)
 Set the data to the given pool. More...
 
EAPI void eina_rectangle_pool_free (Eina_Rectangle_Pool *pool) EINA_ARG_NONNULL(1)
 Free the given pool. More...
 
EAPI int eina_rectangle_pool_count (Eina_Rectangle_Pool *pool) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT
 Return the number of rectangles in the given pool. More...
 
EAPI Eina_Rectangleeina_rectangle_pool_request (Eina_Rectangle_Pool *pool, int w, int h) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1)
 Request a rectangle of given size in the given pool. More...
 
EAPI void eina_rectangle_pool_release (Eina_Rectangle *rect) EINA_ARG_NONNULL(1)
 Remove the given rectangle from the pool. More...
 
EAPI Eina_Rectangleeina_rectangle_new (int x, int y, int w, int h) EINA_MALLOC EINA_WARN_UNUSED_RESULT
 Create a new rectangle. More...
 
EAPI void eina_rectangle_free (Eina_Rectangle *rect) EINA_ARG_NONNULL(1)
 Free the given rectangle. More...
 

Variables

static Eina_Bool EINA_WARN_UNUSED_RESULT
 

Detailed Description

These functions provide rectangle management.

Macro Definition Documentation

§ EINA_RECTANGLE_SET

#define EINA_RECTANGLE_SET (   Rectangle,
  X,
  Y,
  W,
 
)
Value:
{ \
(Rectangle)->x = X; \
(Rectangle)->y = Y; \
(Rectangle)->w = W; \
(Rectangle)->h = H; \
}

Macro to set the values of a Eina_Rectangle.

Parameters
RectangleThe rectangle to set the values.
XThe X coordinate of the top left corner of the rectangle.
YThe Y coordinate of the top left corner of the rectangle.
WThe width of the rectangle.
HThe height of the rectangle.

This macro set the values of Rectangle. (X, Y) is the coordinates of the top left corner of Rectangle, W is its width and H is its height.

Function Documentation

§ eina_rectangle_pool_new()

EAPI Eina_Rectangle_Pool* eina_rectangle_pool_new ( int  w,
int  h 
)

Add a rectangle in a new pool.

Parameters
wThe width of the rectangle.
hThe height of the rectangle.
Returns
A newly allocated pool on success, NULL otherwise.

This function adds the rectangle of size (width, height) to a new pool. If the pool can not be created, NULL is returned. Otherwise the newly allocated pool is returned.

References EINA_FALSE, eina_list_append(), EINA_MAGIC_SET, and eina_rectangle_new().

§ eina_rectangle_pool_get()

EAPI Eina_Rectangle_Pool* eina_rectangle_pool_get ( Eina_Rectangle rect)

Return the pool of the given rectangle.

Parameters
rectThe rectangle.
Returns
The pool of the given rectangle.

This function returns the pool in which rect is. If rect is NULL, NULL is returned.

§ eina_rectangle_pool_geometry_get()

EAPI Eina_Bool eina_rectangle_pool_geometry_get ( Eina_Rectangle_Pool pool,
int *  w,
int *  h 
)

Return the width and height of the given pool.

Parameters
poolThe pool.
wThe returned width.
hThe returned height.
Returns
EINA_TRUE on success, EINA_FALSE otherwise.

This function returns the width and height of pool and store them in respectively w and h if they are not NULL. If pool is NULL, EINA_FALSE is returned. Otherwise EINA_TRUE is returned.

References EINA_FALSE.

§ eina_rectangle_pool_data_get()

EAPI void* eina_rectangle_pool_data_get ( Eina_Rectangle_Pool pool)

Get the data from the given pool.

Parameters
poolThe pool.
Returns
The returned data.

This function gets the data from pool set by eina_rectangle_pool_data_set(). If pool is NULL, this function returns NULL.

§ eina_rectangle_pool_data_set()

EAPI void eina_rectangle_pool_data_set ( Eina_Rectangle_Pool pool,
const void *  data 
)

Set the data to the given pool.

Parameters
poolThe pool.
dataThe data to set.

This function sets data to pool. If pool is NULL, this function does nothing.

§ eina_rectangle_pool_free()

EAPI void eina_rectangle_pool_free ( Eina_Rectangle_Pool pool)

Free the given pool.

Parameters
poolThe pool to free.

This function frees the allocated data of pool. If pool is NULL, this function returned immediately.

§ eina_rectangle_pool_count()

EAPI int eina_rectangle_pool_count ( Eina_Rectangle_Pool pool)

Return the number of rectangles in the given pool.

Parameters
poolThe pool.
Returns
The number of rectangles in the pool.

This function returns the number of rectangles in pool.

§ eina_rectangle_pool_request()

EAPI Eina_Rectangle* eina_rectangle_pool_request ( Eina_Rectangle_Pool pool,
int  w,
int  h 
)

Request a rectangle of given size in the given pool.

Parameters
poolThe pool.
wThe width of the rectangle to request.
hThe height of the rectangle to request.
Returns
The requested rectangle on success, NULL otherwise.

This function retrieve from pool the rectangle of width w and height h. If pool is NULL, or w or h are non-positive, the function returns NULL. If w or h are greater than the pool size, the function returns NULL. On success, the function returns the rectangle which matches the size (w, h). Otherwise it returns NULL.

§ eina_rectangle_pool_release()

EAPI void eina_rectangle_pool_release ( Eina_Rectangle rect)

Remove the given rectangle from the pool.

Parameters
rectThe rectangle to remove from the pool.

This function removes rect from the pool. If rect is NULL, the function returns immediately. Otherwise it removes rect from the pool.

§ eina_rectangle_new()

EAPI Eina_Rectangle* eina_rectangle_new ( int  x,
int  y,
int  w,
int  h 
)

Create a new rectangle.

Parameters
xThe X coordinate of the top left corner of the rectangle.
yThe Y coordinate of the top left corner of the rectangle.
wThe width of the rectangle.
hThe height of the rectangle.
Returns
The new rectangle on success, @ NULL otherwise.

This function creates a rectangle which top left corner has the coordinates (x, y), with height w and height h and adds it to the rectangles pool. No check is done on w and h. This function returns a new rectangle on success, NULL otherwhise.

Referenced by eina_rectangle_pool_new().

§ eina_rectangle_free()

EAPI void eina_rectangle_free ( Eina_Rectangle rect)

Free the given rectangle.

Parameters
rectThe rectangle to free.

This function removes rect from the rectangles pool.

Referenced by evas_object_image_data_update_add(), evas_obscured_clear(), and evas_render_updates_free().