Blame gegl/gegl-utils.h

Packit Service 2781ba
/* This file is part of GEGL
Packit Service 2781ba
 *
Packit Service 2781ba
 * GEGL is free software; you can redistribute it and/or
Packit Service 2781ba
 * modify it under the terms of the GNU Lesser General Public
Packit Service 2781ba
 * License as published by the Free Software Foundation; either
Packit Service 2781ba
 * version 3 of the License, or (at your option) any later version.
Packit Service 2781ba
 *
Packit Service 2781ba
 * GEGL is distributed in the hope that it will be useful,
Packit Service 2781ba
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 2781ba
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 2781ba
 * Lesser General Public License for more details.
Packit Service 2781ba
 *
Packit Service 2781ba
 * You should have received a copy of the GNU Lesser General Public
Packit Service 2781ba
 * License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
Packit Service 2781ba
 *
Packit Service 2781ba
 * Copyright 2003 Calvin Williamson
Packit Service 2781ba
 */
Packit Service 2781ba
Packit Service 2781ba
Packit Service 2781ba
#ifndef __GEGL_UTILS_H__
Packit Service 2781ba
#define __GEGL_UTILS_H__
Packit Service 2781ba
Packit Service 2781ba
G_BEGIN_DECLS
Packit Service 2781ba
Packit Service 2781ba
/***
Packit Service 2781ba
 * GeglRectangle:
Packit Service 2781ba
 *
Packit Service 2781ba
 * GeglRectangles are used in #gegl_node_get_bounding_box and #gegl_node_blit
Packit Service 2781ba
 * for specifying rectangles.
Packit Service 2781ba
 *
Packit Service 2781ba
 * 

struct GeglRectangle
Packit Service 2781ba
 * {
Packit Service 2781ba
 *   gint x;
Packit Service 2781ba
 *   gint y;
Packit Service 2781ba
 *   gint width;
Packit Service 2781ba
 *   gint height;
Packit Service 2781ba
 * };

Packit Service 2781ba
 *
Packit Service 2781ba
 */
Packit Service 2781ba
Packit Service 2781ba
/**
Packit Service 2781ba
 * gegl_rectangle_set:
Packit Service 2781ba
 * @rectangle: a #GeglRectangle
Packit Service 2781ba
 * @x: upper left x coordinate
Packit Service 2781ba
 * @y: upper left y coordinate
Packit Service 2781ba
 * @width: width in pixels.
Packit Service 2781ba
 * @height: height in pixels.
Packit Service 2781ba
 *
Packit Service 2781ba
 * Sets the @x, @y, @width and @height on @rectangle.
Packit Service 2781ba
 */
Packit Service 2781ba
void        gegl_rectangle_set           (GeglRectangle       *rectangle,
Packit Service 2781ba
                                          gint                 x,
Packit Service 2781ba
                                          gint                 y,
Packit Service 2781ba
                                          guint                width,
Packit Service 2781ba
                                          guint                height);
Packit Service 2781ba
Packit Service 2781ba
/**
Packit Service 2781ba
 * gegl_rectangle_equal:
Packit Service 2781ba
 * @rectangle1: a #GeglRectangle
Packit Service 2781ba
 * @rectangle2: a #GeglRectangle
Packit Service 2781ba
 *
Packit Service 2781ba
 * Check if two #GeglRectangles are equal.
Packit Service 2781ba
 *
Packit Service 2781ba
 * Returns TRUE if @rectangle and @rectangle2 are equal.
Packit Service 2781ba
 */
Packit Service 2781ba
gboolean    gegl_rectangle_equal         (const GeglRectangle *rectangle1,
Packit Service 2781ba
                                          const GeglRectangle *rectangle2);
Packit Service 2781ba
Packit Service 2781ba
/**
Packit Service 2781ba
 * gegl_rectangle_equal_coords:
Packit Service 2781ba
 * @rectangle: a #GeglRectangle
Packit Service 2781ba
 * @x: X coordinate
Packit Service 2781ba
 * @y: Y coordinate
Packit Service 2781ba
 * @width: width of rectangle
Packit Service 2781ba
 * @height: height of rectangle
Packit Service 2781ba
 *
Packit Service 2781ba
 * Check if a rectangle is equal to a set of parameters.
Packit Service 2781ba
 *
Packit Service 2781ba
 * Returns TRUE if @rectangle and @x,@y @width x @height are equal.
Packit Service 2781ba
 */
Packit Service 2781ba
gboolean    gegl_rectangle_equal_coords  (const GeglRectangle *rectangle,
Packit Service 2781ba
                                          gint                 x,
Packit Service 2781ba
                                          gint                 y,
Packit Service 2781ba
                                          gint                 width,
Packit Service 2781ba
                                          gint                 height);
Packit Service 2781ba
Packit Service 2781ba
/**
Packit Service 2781ba
 * gegl_rectangle_is_empty:
Packit Service 2781ba
 * @rectangle: a #GeglRectangle
Packit Service 2781ba
 *
Packit Service 2781ba
 * Check if a rectangle has zero area.
Packit Service 2781ba
 *
Packit Service 2781ba
 * Returns TRUE if @rectangle height and width are both zero.
Packit Service 2781ba
 */
Packit Service 2781ba
gboolean    gegl_rectangle_is_empty     (const GeglRectangle *rectangle);
Packit Service 2781ba
Packit Service 2781ba
/**
Packit Service 2781ba
 * gegl_rectangle_copy:
Packit Service 2781ba
 * @destination: a #GeglRectangle
Packit Service 2781ba
 * @source: a #GeglRectangle
Packit Service 2781ba
 *
Packit Service 2781ba
 * Copies the rectangle information stored in @source over the information in
Packit Service 2781ba
 * @destination.
Packit Service 2781ba
 */
Packit Service 2781ba
void        gegl_rectangle_copy          (GeglRectangle       *destination,
Packit Service 2781ba
                                          const GeglRectangle *source);
Packit Service 2781ba
Packit Service 2781ba
/**
Packit Service 2781ba
 * gegl_rectangle_bounding_box:
Packit Service 2781ba
 * @destination: a #GeglRectangle
Packit Service 2781ba
 * @source1: a #GeglRectangle
Packit Service 2781ba
 * @source2: a #GeglRectangle
Packit Service 2781ba
 *
Packit Service 2781ba
 * Computes the bounding box of the rectangles @source1 and @source2 and stores the
Packit Service 2781ba
 * resulting bounding box in @destination.
Packit Service 2781ba
 */
Packit Service 2781ba
void        gegl_rectangle_bounding_box  (GeglRectangle       *destination,
Packit Service 2781ba
                                          const GeglRectangle *source1,
Packit Service 2781ba
                                          const GeglRectangle *source2);
Packit Service 2781ba
Packit Service 2781ba
/**
Packit Service 2781ba
 * gegl_rectangle_intersect:
Packit Service 2781ba
 * @dest: return location for the intersection of @src1 and @src2, or NULL.
Packit Service 2781ba
 * @src1: a #GeglRectangle
Packit Service 2781ba
 * @src2: a #GeglRectangle
Packit Service 2781ba
 *
Packit Service 2781ba
 * Calculates the intersection of two rectangles. It is allows for dest to be the same
Packit Service 2781ba
 * as either @src1 or @src2. If the rectangles do not intersect, dest's width and height
Packit Service 2781ba
 * are set to 0 and its x and y values are undefined.
Packit Service 2781ba
 *
Packit Service 2781ba
 * Returns TRUE if the rectangles intersect.
Packit Service 2781ba
 */
Packit Service 2781ba
gboolean    gegl_rectangle_intersect     (GeglRectangle       *dest,
Packit Service 2781ba
                                          const GeglRectangle *src1,
Packit Service 2781ba
                                          const GeglRectangle *src2);
Packit Service 2781ba
Packit Service 2781ba
/**
Packit Service 2781ba
 * gegl_rectangle_contains:
Packit Service 2781ba
 * @parent: a #GeglRectangle
Packit Service 2781ba
 * @child: a #GeglRectangle
Packit Service 2781ba
 *
Packit Service 2781ba
 * Checks if the #GeglRectangle @child is fully contained within @parent.
Packit Service 2781ba
 *
Packit Service 2781ba
 * Returns TRUE if the @child is fully contained in @parent.
Packit Service 2781ba
 */
Packit Service 2781ba
gboolean    gegl_rectangle_contains      (const GeglRectangle *parent,
Packit Service 2781ba
                                          const GeglRectangle *child);
Packit Service 2781ba
Packit Service 2781ba
/**
Packit Service 2781ba
 * gegl_rectangle_infinite_plane:
Packit Service 2781ba
 *
Packit Service 2781ba
 * Returns a GeglRectangle that represents an infininte plane.
Packit Service 2781ba
 */
Packit Service 2781ba
GeglRectangle gegl_rectangle_infinite_plane (void);
Packit Service 2781ba
Packit Service 2781ba
/**
Packit Service 2781ba
 * gegl_rectangle_is_infinite_plane:
Packit Service 2781ba
 * @rectangle: A GeglRectangle.
Packit Service 2781ba
 *
Packit Service 2781ba
 * Returns TRUE if the GeglRectangle represents an infininte plane,
Packit Service 2781ba
 * FALSE otherwise.
Packit Service 2781ba
 */
Packit Service 2781ba
gboolean gegl_rectangle_is_infinite_plane (const GeglRectangle *rectangle);
Packit Service 2781ba
Packit Service 2781ba
/**
Packit Service 2781ba
 * gegl_rectangle_dump:
Packit Service 2781ba
 * @rectangle: A GeglRectangle.
Packit Service 2781ba
 *
Packit Service 2781ba
 * For debugging purposes, not stable API.
Packit Service 2781ba
 */
Packit Service 2781ba
void     gegl_rectangle_dump              (const GeglRectangle *rectangle);
Packit Service 2781ba
Packit Service 2781ba
Packit Service 2781ba
/***
Packit Service 2781ba
 * Aligned memory:
Packit Service 2781ba
 *
Packit Service 2781ba
 * GEGL provides functions to allocate and free buffers that are guaranteed to
Packit Service 2781ba
 * be on 16 byte aligned memory addresses.
Packit Service 2781ba
 */
Packit Service 2781ba
Packit Service 2781ba
/**
Packit Service 2781ba
 * gegl_malloc: (skip)
Packit Service 2781ba
 * @n_bytes: the number of bytes to allocte.
Packit Service 2781ba
 *
Packit Service 2781ba
 * Allocates @n_bytes of memory. If n_bytes is 0 it returns NULL.
Packit Service 2781ba
 *
Packit Service 2781ba
 * Returns a pointer to the allocated memory.
Packit Service 2781ba
 */
Packit Service 2781ba
gpointer gegl_malloc                  (gsize    n_bytes);
Packit Service 2781ba
Packit Service 2781ba
/**
Packit Service 2781ba
 * gegl_free:
Packit Service 2781ba
 * @mem: the memory to free.
Packit Service 2781ba
 *
Packit Service 2781ba
 * Frees the memory pointed to by @mem, if @mem is NULL it will warn and abort.
Packit Service 2781ba
 */
Packit Service 2781ba
void     gegl_free                    (gpointer mem);
Packit Service 2781ba
Packit Service 2781ba
Packit Service 2781ba
#define GEGL_FLOAT_EPSILON            (1e-5)
Packit Service 2781ba
#define GEGL_FLOAT_IS_ZERO(value)     (_gegl_float_epsilon_zero ((value)))
Packit Service 2781ba
#define GEGL_FLOAT_EQUAL(v1, v2)      (_gegl_float_epsilon_equal ((v1), (v2)))
Packit Service 2781ba
Packit Service 2781ba
#define INT_MULT(a,b,t)  ((t) = (a) * (b) + 0x80, ((((t) >> 8) + (t)) >> 8))
Packit Service 2781ba
Packit Service 2781ba
/***
Packit Service 2781ba
 */
Packit Service 2781ba
inline gint _gegl_float_epsilon_zero  (float     value);
Packit Service 2781ba
gint        _gegl_float_epsilon_equal (float     v1,
Packit Service 2781ba
                                       float     v2);
Packit Service 2781ba
Packit Service 2781ba
G_END_DECLS
Packit Service 2781ba
Packit Service 2781ba
#endif /* __GEGL_UTILS_H__ */