From 36a8b2226f42c28092cb8f2d65c0a5ff0da4414f Mon Sep 17 00:00:00 2001 From: Tom Englund Date: Wed, 30 Jul 2025 11:54:09 +0200 Subject: renderer: use CRegion foreach over getRects (#10980) instead of allocating and returning a vector, use forEach to directly call a function on the rects. --- src/render/Texture.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/render/Texture.cpp') diff --git a/src/render/Texture.cpp b/src/render/Texture.cpp index a6e29eaf..b9797751 100644 --- a/src/render/Texture.cpp +++ b/src/render/Texture.cpp @@ -118,14 +118,12 @@ void CTexture::update(uint32_t drmFormat, uint8_t* pixels, uint32_t stride, cons bind(); - auto rects = damage.copy().intersect(CBox{{}, m_size}).getRects(); - if (format->flipRB) { setTexParameter(GL_TEXTURE_SWIZZLE_R, GL_BLUE); setTexParameter(GL_TEXTURE_SWIZZLE_B, GL_RED); } - for (auto const& rect : rects) { + damage.copy().intersect(CBox{{}, m_size}).forEachRect([&format, &stride, &pixels](const auto& rect) { GLCALL(glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, stride / format->bytesPerBlock)); GLCALL(glPixelStorei(GL_UNPACK_SKIP_PIXELS_EXT, rect.x1)); GLCALL(glPixelStorei(GL_UNPACK_SKIP_ROWS_EXT, rect.y1)); @@ -133,7 +131,7 @@ void CTexture::update(uint32_t drmFormat, uint8_t* pixels, uint32_t stride, cons int width = rect.x2 - rect.x1; int height = rect.y2 - rect.y1; GLCALL(glTexSubImage2D(GL_TEXTURE_2D, 0, rect.x1, rect.y1, width, height, format->glFormat, format->glType, pixels)); - } + }); GLCALL(glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, 0)); GLCALL(glPixelStorei(GL_UNPACK_SKIP_PIXELS_EXT, 0)); -- cgit v1.2.3