Louvre  v1.2.1-2
C++ library for Wayland compositors
List of all members | Public Member Functions
LRegion Class Reference

#include <LRegion.h>

Collection of non-overlapping rectangles. More...

Detailed Description

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.

Public Member Functions

 LRegion ()
 Constructor for creating an empty LRegion. More...
 
 LRegion (const LRect &rect)
 Initialize the region with a rect. More...
 
 ~LRegion ()
 Destructor for freeing resources associated with LRegion. More...
 
 LRegion (const LRegion &other)
 Copy constructor for creating an LRegion by copying another LRegion. More...
 
LRegionoperator= (const LRegion &other)
 Assignment operator for assigning the content of one LRegion to another. More...
 
void clear ()
 Clears the LRegion, deleting all rectangles. More...
 
void addRect (const LRect &rect)
 Adds a rectangle to the LRegion (union operation). More...
 
void addRect (const LPoint &pos, const LSize &size)
 Adds a rectangle to the LRegion (union operation). More...
 
void addRect (Int32 x, Int32 y, const LSize &size)
 Adds a rectangle to the LRegion (union operation). More...
 
void addRect (const LPoint &pos, Int32 w, Int32 h)
 Adds a rectangle to the LRegion (union operation). More...
 
void addRect (Int32 x, Int32 y, Int32 w, Int32 h)
 Adds a rectangle to the LRegion (union operation). More...
 
void addRegion (const LRegion &region)
 Adds the content of another LRegion to this LRegion (union operation). More...
 
void subtractRect (const LRect &rect)
 Subtracts a rectangle from the LRegion. More...
 
void subtractRect (const LPoint &pos, const LSize &size)
 Subtracts a rectangle from the LRegion. More...
 
void subtractRect (const LPoint &pos, Int32 w, Int32 h)
 Subtracts a rectangle from the LRegion. More...
 
void subtractRect (Int32 x, Int32 y, const LSize &size)
 Subtracts a rectangle from the LRegion. More...
 
void subtractRect (Int32 x, Int32 y, Int32 w, Int32 h)
 Subtracts a rectangle from the LRegion. More...
 
void subtractRegion (const LRegion &region)
 Subtracts another LRegion from this LRegion. More...
 
void intersectRegion (const LRegion &region)
 Intersects this LRegion with another LRegion. More...
 
void multiply (Float32 factor)
 Multiplies the components of each rectangle in the LRegion by the given factor. More...
 
void multiply (Float32 xFactor, Float32 yFactor)
 Multiplies the components of each rectangle in the LRegion by the given factor. More...
 
bool containsPoint (const LPoint &point) const
 Check if the LRegion contains a specific point. More...
 
void offset (const LPoint &offset)
 Translate each rectangle in the LRegion by the specified offset. More...
 
void offset (Int32 x, Int32 y)
 Translate each rectangle in the LRegion by the specified offset. More...
 
void inverse (const LRect &rect)
 Invert the region contained within the specified rectangle. More...
 
bool empty () const
 Check if the LRegion is empty (contains no rectangles). More...
 
void clip (const LRect &rect)
 Clips the LRegion to the area defined by the specified rectangle. More...
 
void clip (const LPoint &pos, const LSize &size)
 Clips the LRegion to the area defined by the specified rectangle. More...
 
void clip (Int32 x, Int32 y, Int32 w, Int32 h)
 Clips the LRegion to the area defined by the specified rectangle. More...
 
const LBoxextents () const
 Get the extents of the LRegion. More...
 
LBoxboxes (Int32 *n) const
 Retrieves the list of rectangles that form the LRegion. More...
 
void transform (const LSize &size, LFramebuffer::Transform transform)
 Applies a specified transforma to all rectangles within the given size. More...
 

Constructor & Destructor Documentation

◆ LRegion() [1/3]

LRegion ( )

Constructor for creating an empty LRegion.

◆ LRegion() [2/3]

LRegion ( const LRect rect)

Initialize the region with a rect.

◆ ~LRegion()

~LRegion ( )

Destructor for freeing resources associated with LRegion.

◆ LRegion() [3/3]

LRegion ( const LRegion other)

Copy constructor for creating an LRegion by copying another LRegion.

Parameters
otherThe LRegion to copy from.

Member Function Documentation

◆ operator=()

Louvre::LRegion & operator= ( const LRegion other)

Assignment operator for assigning the content of one LRegion to another.

Parameters
otherThe LRegion to assign from.
Returns
A reference to the modified LRegion.

◆ clear()

void clear ( )

Clears the LRegion, deleting all rectangles.

◆ addRect() [1/5]

void addRect ( const LRect rect)

Adds a rectangle to the LRegion (union operation).

Parameters
rectThe rectangle to add.

◆ addRect() [2/5]

void addRect ( const LPoint pos,
const LSize size 
)

Adds a rectangle to the LRegion (union operation).

Parameters
posThe rectangle's top-left corner.
sizeThe rectangle's size.

◆ addRect() [3/5]

void addRect ( Int32  x,
Int32  y,
const LSize size 
)

Adds a rectangle to the LRegion (union operation).

Parameters
xThe x-coordinate of the rectangle's top-left corner.
yThe y-coordinate of the rectangle's top-left corner.
sizeThe rectangle's size.

◆ addRect() [4/5]

void addRect ( const LPoint pos,
Int32  w,
Int32  h 
)

Adds a rectangle to the LRegion (union operation).

Parameters
posThe rectangle's top-left corner.
wThe width of the rectangle.
hThe height of the rectangle.

◆ addRect() [5/5]

void addRect ( Int32  x,
Int32  y,
Int32  w,
Int32  h 
)

Adds a rectangle to the LRegion (union operation).

Parameters
xThe x-coordinate of the rectangle's top-left corner.
yThe y-coordinate of the rectangle's top-left corner.
wThe width of the rectangle.
hThe height of the rectangle.

◆ addRegion()

void addRegion ( const LRegion region)

Adds the content of another LRegion to this LRegion (union operation).

Parameters
regionThe LRegion to add.

◆ subtractRect() [1/5]

void subtractRect ( const LRect rect)

Subtracts a rectangle from the LRegion.

Parameters
rectThe rectangle to subtract.

◆ subtractRect() [2/5]

void subtractRect ( const LPoint pos,
const LSize size 
)

Subtracts a rectangle from the LRegion.

Parameters
posThe rectangle's top-left corner.
sizeThe rectangle's size.

◆ subtractRect() [3/5]

void subtractRect ( const LPoint pos,
Int32  w,
Int32  h 
)

Subtracts a rectangle from the LRegion.

Parameters
posThe rectangle's top-left corner.
wThe width of the rectangle.
hThe height of the rectangle.

◆ subtractRect() [4/5]

void subtractRect ( Int32  x,
Int32  y,
const LSize size 
)

Subtracts a rectangle from the LRegion.

Parameters
xThe x-coordinate of the rectangle's top-left corner.
yThe y-coordinate of the rectangle's top-left corner.
sizeThe rectangle's size.

◆ subtractRect() [5/5]

void subtractRect ( Int32  x,
Int32  y,
Int32  w,
Int32  h 
)

Subtracts a rectangle from the LRegion.

Parameters
xThe x-coordinate of the rectangle's top-left corner.
yThe y-coordinate of the rectangle's top-left corner.
wThe width of the rectangle.
hThe height of the rectangle.

◆ subtractRegion()

void subtractRegion ( const LRegion region)

Subtracts another LRegion from this LRegion.

Parameters
regionThe LRegion to subtract.

◆ intersectRegion()

void intersectRegion ( const LRegion region)

Intersects this LRegion with another LRegion.

Parameters
regionThe LRegion to intersect with.

◆ multiply() [1/2]

void multiply ( Float32  factor)

Multiplies the components of each rectangle in the LRegion by the given factor.

Parameters
factorThe factor to multiply by.

◆ multiply() [2/2]

void multiply ( Float32  xFactor,
Float32  yFactor 
)

Multiplies the components of each rectangle in the LRegion by the given factor.

Parameters
xFactorThe x-axis factor to multiply by.
yFactorThe y-axis factor to multiply by.

◆ containsPoint()

bool containsPoint ( const LPoint point) const

Check if the LRegion contains a specific point.

Parameters
pointThe point to check.
Returns
true if the region contains the point, false otherwise.

◆ offset() [1/2]

void offset ( const LPoint offset)

Translate each rectangle in the LRegion by the specified offset.

Parameters
offsetThe offset to apply.

◆ offset() [2/2]

void offset ( Int32  x,
Int32  y 
)

Translate each rectangle in the LRegion by the specified offset.

Parameters
xThe x offset to apply.
yThe y offset to apply.

◆ inverse()

void inverse ( const LRect rect)

Invert the region contained within the specified rectangle.

Parameters
rectThe rectangle to define the area of inversion.

◆ empty()

bool empty ( ) const

Check if the LRegion is empty (contains no rectangles).

Returns
true if the region is empty, false otherwise.

◆ clip() [1/3]

void clip ( const LRect rect)

Clips the LRegion to the area defined by the specified rectangle.

Parameters
rectThe rectangle used for clipping.

◆ clip() [2/3]

void clip ( const LPoint pos,
const LSize size 
)

Clips the LRegion to the area defined by the specified rectangle.

◆ clip() [3/3]

void clip ( Int32  x,
Int32  y,
Int32  w,
Int32  h 
)

Clips the LRegion to the area defined by the specified rectangle.

◆ extents()

const LBox & extents ( ) const

Get the extents of the LRegion.

This method returns a pointer to an LBox that represents the bounding box of the LRegion. The LBox contains the minimum and maximum coordinates that enclose the LRegion.

Returns
A pointer to the extents of the LRegion as an LBox.

◆ boxes()

LBox * boxes ( Int32 n) const

Retrieves the list of rectangles that form the LRegion.

Parameters
nA pointer to an integer that will be set to the number of rectangles.
Returns
A pointer to an array of LBox objects representing the rectangles.
Note
This variant allows you to access the rectangles using the native Pixman method, which is considerably faster.

◆ transform()

void transform ( const LSize size,
LFramebuffer::Transform  transform 
)

Applies a specified transforma to all rectangles within the given size.

This function clips the rectangles within the specified size and applies the specified transform.

Parameters
sizeThe size used for clipping and transformation.
transformThe transform to be applied to the rectangles.