renderer: use CRegion foreach over getRects (#10980)

instead of allocating and returning a vector, use forEach to directly
call a function on the rects.
This commit is contained in:
Tom Englund 2025-07-30 11:54:09 +02:00 committed by GitHub
parent 43966cc787
commit 36a8b2226f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 37 additions and 41 deletions

View file

@ -606,14 +606,14 @@ void CWLSurfaceResource::updateCursorShm(CRegion damage) {
if (const auto RECTS = damage.getRects(); RECTS.size() == 1 && RECTS.at(0).x2 == buf->size.x && RECTS.at(0).y2 == buf->size.y)
memcpy(shmData.data(), pixelData, bufLen);
else {
for (auto& box : damage.getRects()) {
damage.forEachRect([&pixelData, &shmData](const auto& box) {
for (auto y = box.y1; y < box.y2; ++y) {
// bpp is 32 INSALLAH
auto begin = 4 * box.y1 * (box.x2 - box.x1) + box.x1;
auto len = 4 * (box.x2 - box.x1);
memcpy((uint8_t*)shmData.data() + begin, (uint8_t*)pixelData + begin, len);
}
}
});
}
}