Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::canvas::RectangleList Class Reference

List of non-overlapping rectangles — used for clip regions and dirty tracking. More...

#include <rectangle_list.hpp>

Public Member Functions

 RectangleList ()=default
void add (const Rect2D &rect)
 Add a rectangle to the list (may overlap existing).
void clear ()
 Clear all rectangles.
bool empty () const
 Whether the list is empty.
int size () const
 Number of rectangles.
const Rect2D & operator[] (int i) const
 Get a rectangle by index.
bool contains (float px, float py) const
 Whether a point is contained in any rectangle.
bool intersects (const Rect2D &rect) const
 Whether any rectangle intersects the given rect.
Rect2D bounding_box () const
 Compute the bounding box of all rectangles.
float total_area () const
 Total area (may double-count overlapping regions).
RectangleList clipped (const Rect2D &clip) const
 Clip this list against a rectangle (keep only the intersection).
void subtract (const Rect2D &sub)
 Subtract a rectangle from all rectangles in the list.
auto begin () const
 Iterator support.
auto end () const
void union_aa (const Rect2D &rect, float aa_tolerance=1.0f/256.0f)
 Antialiased union — appends rect, then merges any pieces that share an edge to within aa_tolerance.
void subtract_aa (const Rect2D &sub, float aa_tolerance=1.0f/256.0f)
 Antialiased subtract — splits intersecting rectangles into non-overlapping pieces.
void intersect_aa (const Rect2D &clip, float aa_tolerance=1.0f/256.0f)
 Antialiased intersect — keep only the intersection with clip, in-place.
void coalesce_aa (float aa_tolerance=1.0f/256.0f)
 Coalesce adjacent rectangles that share a full edge (within aa_tolerance).

Static Public Member Functions

static constexpr const char * aa_backend ()
 Reports the implementation backend in use.

Detailed Description

List of non-overlapping rectangles — used for clip regions and dirty tracking.

Constructor & Destructor Documentation

◆ RectangleList()

pulp::canvas::RectangleList::RectangleList ( )
default

Member Function Documentation

◆ aa_backend()

constexpr const char * pulp::canvas::RectangleList::aa_backend ( )
inlinestaticconstexpr

Reports the implementation backend in use.

Today this is always "cpu"; a future build with PULP_HAS_SKIA may report "skia" for the integer-aligned fast path. Tests and callers can branch on this to skip Skia-only checks on cross-platform CI lanes.

◆ add()

void pulp::canvas::RectangleList::add ( const Rect2D & rect)
inline

Add a rectangle to the list (may overlap existing).

◆ begin()

auto pulp::canvas::RectangleList::begin ( ) const
inline

Iterator support.

◆ bounding_box()

Rect2D pulp::canvas::RectangleList::bounding_box ( ) const
inline

Compute the bounding box of all rectangles.

◆ clear()

void pulp::canvas::RectangleList::clear ( )
inline

Clear all rectangles.

◆ clipped()

RectangleList pulp::canvas::RectangleList::clipped ( const Rect2D & clip) const
inline

Clip this list against a rectangle (keep only the intersection).

◆ coalesce_aa()

void pulp::canvas::RectangleList::coalesce_aa ( float aa_tolerance = 1.0f / 256.0f)
inline

Coalesce adjacent rectangles that share a full edge (within aa_tolerance).

The result is not guaranteed minimal — a true minimal cover requires a scanline merge — but this pass is cheap and handles the common "two abutting halves" case.

◆ contains()

bool pulp::canvas::RectangleList::contains ( float px,
float py ) const
inline

Whether a point is contained in any rectangle.

◆ empty()

bool pulp::canvas::RectangleList::empty ( ) const
inline

Whether the list is empty.

◆ end()

auto pulp::canvas::RectangleList::end ( ) const
inline

◆ intersect_aa()

void pulp::canvas::RectangleList::intersect_aa ( const Rect2D & clip,
float aa_tolerance = 1.0f / 256.0f )
inline

Antialiased intersect — keep only the intersection with clip, in-place.

Edges within aa_tolerance of clip's edges are treated as coincident.

◆ intersects()

bool pulp::canvas::RectangleList::intersects ( const Rect2D & rect) const
inline

Whether any rectangle intersects the given rect.

◆ operator[]()

const Rect2D & pulp::canvas::RectangleList::operator[] ( int i) const
inline

Get a rectangle by index.

◆ size()

int pulp::canvas::RectangleList::size ( ) const
inline

Number of rectangles.

◆ subtract()

void pulp::canvas::RectangleList::subtract ( const Rect2D & sub)
inline

Subtract a rectangle from all rectangles in the list.

◆ subtract_aa()

void pulp::canvas::RectangleList::subtract_aa ( const Rect2D & sub,
float aa_tolerance = 1.0f / 256.0f )
inline

Antialiased subtract — splits intersecting rectangles into non-overlapping pieces.

Edges within aa_tolerance of sub's edges are treated as coincident so a 1.001px wide sliver doesn't survive as a stray rectangle.

◆ total_area()

float pulp::canvas::RectangleList::total_area ( ) const
inline

Total area (may double-count overlapping regions).

◆ union_aa()

void pulp::canvas::RectangleList::union_aa ( const Rect2D & rect,
float aa_tolerance = 1.0f / 256.0f )
inline

Antialiased union — appends rect, then merges any pieces that share an edge to within aa_tolerance.

Behaviorally equivalent to add() followed by a coalesce pass.

NOT RT-safe — std::vector::push_back may reallocate.


The documentation for this class was generated from the following file: