mirror of
https://github.com/hyprwm/hyprutils.git
synced 2025-12-20 07:00:10 +01:00
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:
parent
a8229739cf
commit
f255b216a0
1 changed files with 8 additions and 0 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue