CRegion: introduce forEachRect

makes us able to directly call a function on each rect instead of using
getRects() allocating a vector every single time, especially when its
used in hot paths like the renderer.
This commit is contained in:
Tom Englund 2025-07-09 18:57:50 +02:00
parent a8229739cf
commit f255b216a0

View file

@ -58,6 +58,14 @@ namespace Hyprutils {
CRegion copy() const;
std::vector<pixman_box32_t> getRects() const;
template <typename T>
void forEachRect(T&& cb) const {
int rectsNum = 0;
const auto* rects = pixman_region32_rectangles(&m_rRegion, &rectsNum);
for (int i = 0; i < rectsNum; ++i) {
std::forward<T>(cb)(rects[i]);
}
}
//
pixman_region32_t* pixman() {