Louvre v2.14.0-1
C++ library for Wayland compositors
|
Collection of non-overlapping rectangles. More...
#include <LRegion.h>
Public Member Functions | |
LRegion () noexcept | |
Constructor for creating an empty LRegion. | |
LRegion (const LRect &rect) noexcept | |
Initialize the region with a rect. | |
~LRegion () noexcept | |
Destructor for freeing resources associated with LRegion. | |
LRegion (const LRegion &other) noexcept | |
Copy constructor. | |
LRegion (LRegion &&other) noexcept | |
Move constructor. | |
LRegion & | operator= (const LRegion &other) noexcept |
Copy assignment operator. | |
LRegion & | operator= (LRegion &&other) noexcept |
Move assignment operator. | |
void | clear () noexcept |
Clears the LRegion, deleting all rectangles. | |
void | addRect (const LRect &rect) noexcept |
Adds a rectangle to the LRegion (union operation). | |
void | addRect (const LPoint &pos, const LSize &size) noexcept |
Adds a rectangle to the LRegion (union operation). | |
void | addRect (Int32 x, Int32 y, const LSize &size) noexcept |
Adds a rectangle to the LRegion (union operation). | |
void | addRect (const LPoint &pos, Int32 w, Int32 h) noexcept |
Adds a rectangle to the LRegion (union operation). | |
void | addRect (Int32 x, Int32 y, Int32 w, Int32 h) noexcept |
Adds a rectangle to the LRegion (union operation). | |
void | addRegion (const LRegion ®ion) noexcept |
Adds the content of another LRegion to this LRegion (union operation). | |
void | subtractRect (const LRect &rect) noexcept |
Subtracts a rectangle from the LRegion. | |
void | subtractRect (const LPoint &pos, const LSize &size) noexcept |
Subtracts a rectangle from the LRegion. | |
void | subtractRect (const LPoint &pos, Int32 w, Int32 h) noexcept |
Subtracts a rectangle from the LRegion. | |
void | subtractRect (Int32 x, Int32 y, const LSize &size) noexcept |
Subtracts a rectangle from the LRegion. | |
void | subtractRect (Int32 x, Int32 y, Int32 w, Int32 h) noexcept |
Subtracts a rectangle from the LRegion. | |
void | subtractRegion (const LRegion ®ion) noexcept |
Subtracts another LRegion from this LRegion. | |
void | intersectRegion (const LRegion ®ion) noexcept |
Intersects this LRegion with another LRegion. | |
void | multiply (Float32 factor) noexcept |
Multiplies the components of each rectangle in the LRegion by the given factor. | |
void | multiply (Float32 xFactor, Float32 yFactor) noexcept |
Multiplies the components of each rectangle in the LRegion by the given factor. | |
bool | containsPoint (const LPoint &point) const noexcept |
Check if the LRegion contains a specific point. | |
void | offset (const LPoint &offset) noexcept |
Translate each rectangle in the LRegion by the specified offset. | |
void | offset (Int32 x, Int32 y) noexcept |
Translate each rectangle in the LRegion by the specified offset. | |
void | inverse (const LRect &rect) noexcept |
Invert the region contained within the specified rectangle. | |
bool | empty () const noexcept |
Check if the LRegion is empty (contains no rectangles). | |
void | clip (const LRect &rect) noexcept |
Clips the LRegion to the area defined by the specified rectangle. | |
void | clip (const LPoint &pos, const LSize &size) noexcept |
Clips the LRegion to the area defined by the specified rectangle. | |
void | clip (Int32 x, Int32 y, Int32 w, Int32 h) noexcept |
Clips the LRegion to the area defined by the specified rectangle. | |
const LBox & | extents () const noexcept |
Gets the extents of the LRegion. | |
const LBox * | boxes (Int32 *n) const noexcept |
Retrieves the list of rectangles that form the LRegion. | |
void | transform (const LSize &size, LTransform transform) noexcept |
Applies the specified transform to all rectangles within the given size. | |
LPointF | closestPointFrom (const LPointF &point, Float32 padding=0.f) const noexcept |
Returns the point within the region closest to the given point. | |
void | simplifyToExtents (Int32 threshold) noexcept |
Replace the rectangles with a single enclosing one if the number is >= threshold. | |
Static Public Member Functions | |
static const LRegion & | EmptyRegion () noexcept |
Const reference to an empty region. | |
Collection of non-overlapping rectangles.
The LRegion class provides an efficient mechanism for creating sets of rectangles that do not overlap in their geometries. It offers methods for performing operations such as additions, subtractions, intersections, and more on rectangles. This class is extensively used by the library for tasks like calculating surface damage, defining opaque, translucent, and input regions, among others. Internally, LRegion employs the algorithm and functions from the Pixman library.
Copy constructor.
other | The LRegion to copy from. |
Adds a rectangle to the LRegion (union operation).
rect | The rectangle to add. |
Adds a rectangle to the LRegion (union operation).
pos | The rectangle's top-left corner. |
size | The rectangle's size. |
Adds a rectangle to the LRegion (union operation).
x | The x-coordinate of the rectangle's top-left corner. |
y | The y-coordinate of the rectangle's top-left corner. |
size | The rectangle's size. |
Adds a rectangle to the LRegion (union operation).
pos | The rectangle's top-left corner. |
w | The width of the rectangle. |
h | The height of the rectangle. |
Adds a rectangle to the LRegion (union operation).
x | The x-coordinate of the rectangle's top-left corner. |
y | The y-coordinate of the rectangle's top-left corner. |
w | The width of the rectangle. |
h | The height of the rectangle. |
Subtracts a rectangle from the LRegion.
rect | The rectangle to subtract. |
Subtracts a rectangle from the LRegion.
pos | The rectangle's top-left corner. |
size | The rectangle's size. |
Subtracts a rectangle from the LRegion.
pos | The rectangle's top-left corner. |
w | The width of the rectangle. |
h | The height of the rectangle. |
Subtracts a rectangle from the LRegion.
x | The x-coordinate of the rectangle's top-left corner. |
y | The y-coordinate of the rectangle's top-left corner. |
size | The rectangle's size. |
Subtracts a rectangle from the LRegion.
x | The x-coordinate of the rectangle's top-left corner. |
y | The y-coordinate of the rectangle's top-left corner. |
w | The width of the rectangle. |
h | The height of the rectangle. |
Multiplies the components of each rectangle in the LRegion by the given factor.
factor | The factor to multiply by. |
Multiplies the components of each rectangle in the LRegion by the given factor.
xFactor | The x-axis factor to multiply by. |
yFactor | The y-axis factor to multiply by. |
Check if the LRegion contains a specific point.
point | The point to check. |
Translate each rectangle in the LRegion by the specified offset.
offset | The offset to apply. |
Translate each rectangle in the LRegion by the specified offset.
x | The x offset to apply. |
y | The y offset to apply. |
Invert the region contained within the specified rectangle.
rect | The rectangle to define the area of inversion. |
|
inlinenoexcept |
Check if the LRegion is empty (contains no rectangles).
Clips the LRegion to the area defined by the specified rectangle.
rect | The rectangle used for clipping. |
Clips the LRegion to the area defined by the specified rectangle.
Clips the LRegion to the area defined by the specified rectangle.
Retrieves the list of rectangles that form the LRegion.
n | A pointer to an integer that will be set to the number of rectangles. |
|
noexcept |
Applies the specified transform to all rectangles within the given size.
This function clips the rectangles within the specified size and applies the specified transform.
size | The size used for clipping and transformation. |
transform | The transform to be applied to the rectangles. |
Returns the point within the region closest to the given point.
If the point is inside the region or the region is empty, the same point is returned.
point | The point to find the closest point within the region. |
padding | Optional padding applied to each of the region boxes. |
Replace the rectangles with a single enclosing one if the number is >= threshold.
threshold | The threshold value. If the number of rectangles is greater than or equal to this value, the rectangles will be simplified to a single enclosing rectangle. |