diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2025-08-08 16:14:02 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-08 16:14:02 +0200 |
| commit | 00da4450db9bab1abfda169eefec8dab98f63a0b (patch) | |
| tree | 6edce234e81a003464f5e0f34bfa0b08565a0e77 /src/render/Renderer.cpp | |
| parent | afbd8796859775a50687daacb254cdd1ba22328f (diff) | |
renderer: minor fixups to uv calcs (#11375)
Fixes #11374
Diffstat (limited to 'src/render/Renderer.cpp')
| -rw-r--r-- | src/render/Renderer.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index cb6bd264..94a362de 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -1118,7 +1118,7 @@ void CHyprRenderer::calculateUVForSurface(PHLWINDOW pWindow, SP<CWLSurfaceResour if (!SCALE_UNAWARE && (EXPECTED_SIZE.x < projSize.x || EXPECTED_SIZE.y < projSize.y)) { // this will not work with shm AFAIK, idk why. // NOTE: this math is wrong if we have a source... or geom updates later, but I don't think we can do much - const auto FIX = projSize / EXPECTED_SIZE; + const auto FIX = (projSize / EXPECTED_SIZE).clamp(Vector2D{1, 1}, Vector2D{1000000, 1000000}); uvBR = uvBR * FIX; } } @@ -1137,26 +1137,29 @@ void CHyprRenderer::calculateUVForSurface(PHLWINDOW pWindow, SP<CWLSurfaceResour CBox geom = pWindow->m_xdgSurface->m_current.geometry; - // ignore X and Y, adjust uv - if (geom.x != 0 || geom.y != 0 || geom.width > projSizeUnscaled.x || geom.height > projSizeUnscaled.y) { + // Adjust UV based on the xdg_surface geometry + if (geom.x != 0 || geom.y != 0 || geom.w != 0 || geom.h != 0) { const auto XPERC = (double)geom.x / (double)pSurface->m_current.size.x; const auto YPERC = (double)geom.y / (double)pSurface->m_current.size.y; - const auto WPERC = (double)(geom.x + geom.width) / (double)pSurface->m_current.size.x; - const auto HPERC = (double)(geom.y + geom.height) / (double)pSurface->m_current.size.y; + const auto WPERC = (double)(geom.x + geom.w ? geom.w : pSurface->m_current.size.x) / (double)pSurface->m_current.size.x; + const auto HPERC = (double)(geom.y + geom.h ? geom.h : pSurface->m_current.size.y) / (double)pSurface->m_current.size.y; const auto TOADDTL = Vector2D(XPERC * (uvBR.x - uvTL.x), YPERC * (uvBR.y - uvTL.y)); uvBR = uvBR - Vector2D((1.0 - WPERC) * (uvBR.x - uvTL.x), (1.0 - HPERC) * (uvBR.y - uvTL.y)); uvTL = uvTL + TOADDTL; + } + // Adjust UV based on our animation progress + if (pSurface->m_current.size.x > projSizeUnscaled.x || pSurface->m_current.size.y > projSizeUnscaled.y) { auto maxSize = projSizeUnscaled; if (pWindow->m_wlSurface->small() && !pWindow->m_wlSurface->m_fillIgnoreSmall) maxSize = pWindow->m_wlSurface->getViewporterCorrectedSize(); - if (geom.width > maxSize.x) - uvBR.x = uvBR.x * (maxSize.x / geom.width); - if (geom.height > maxSize.y) - uvBR.y = uvBR.y * (maxSize.y / geom.height); + if (pSurface->m_current.size.x > maxSize.x) + uvBR.x = uvBR.x * (maxSize.x / pSurface->m_current.size.x); + if (pSurface->m_current.size.y > maxSize.y) + uvBR.y = uvBR.y * (maxSize.y / pSurface->m_current.size.y); } g_pHyprOpenGL->m_renderData.primarySurfaceUVTopLeft = uvTL; |
