summaryrefslogtreecommitdiff
path: root/src/render/Renderer.cpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2025-09-21 19:27:56 +0200
committerGitHub <noreply@github.com>2025-09-21 19:27:56 +0200
commit26cbc67385d95ba621fe0a125a5b121ffdd09335 (patch)
tree2aa7c05ce78ab4ea55e8df81f1c99553509b37b1 /src/render/Renderer.cpp
parent41dad381770300fe1015ad8cdd1f370a8fd4e5d5 (diff)
renderer: fix uv calculations once and for all (#11770)
fixes synchronization of ackd sizes, fixes wrong xdg stuff
Diffstat (limited to 'src/render/Renderer.cpp')
-rw-r--r--src/render/Renderer.cpp63
1 files changed, 31 insertions, 32 deletions
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index 32b571b1..af983926 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -1126,15 +1126,25 @@ void CHyprRenderer::calculateUVForSurface(PHLWINDOW pWindow, SP<CWLSurfaceResour
if (*PEXPANDEDGES) {
const auto MONITOR_WL_SCALE = std::ceil(pMonitor->m_scale);
const bool SCALE_UNAWARE = MONITOR_WL_SCALE != pSurface->m_current.scale && !pSurface->m_current.viewport.hasDestination;
- const auto EXPECTED_SIZE =
- ((pSurface->m_current.viewport.hasDestination ? pSurface->m_current.viewport.destination : pSurface->m_current.bufferSize / pSurface->m_current.scale) *
- pMonitor->m_scale)
- .round();
- 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).clamp(Vector2D{1, 1}, Vector2D{1000000, 1000000});
- uvBR = uvBR * FIX;
+ const auto EXPECTED_SIZE = ((pSurface->m_current.viewport.hasDestination ?
+ pSurface->m_current.viewport.destination :
+ (pSurface->m_current.viewport.hasSource ? pSurface->m_current.viewport.source.size() / pSurface->m_current.scale : projSize)) *
+ pMonitor->m_scale)
+ .round();
+
+ const auto RATIO = projSize / EXPECTED_SIZE;
+ if (!SCALE_UNAWARE) {
+ if (*PEXPANDEDGES && !SCALE_UNAWARE && (RATIO.x > 1 || RATIO.y > 1)) {
+ const auto FIX = RATIO.clamp(Vector2D{1, 1}, Vector2D{1000000, 1000000});
+ uvBR = uvBR * FIX;
+ }
+
+ // FIXME: probably do this for in anims on all views...
+ const auto SHOULD_SKIP = !pWindow || pWindow->m_animatingIn;
+ if (!SHOULD_SKIP && (RATIO.x < 1 || RATIO.y < 1)) {
+ const auto FIX = RATIO.clamp(Vector2D{0.0001, 0.0001}, Vector2D{1, 1});
+ uvBR = uvBR * FIX;
+ }
}
}
@@ -1150,32 +1160,21 @@ void CHyprRenderer::calculateUVForSurface(PHLWINDOW pWindow, SP<CWLSurfaceResour
if (!main || !pWindow)
return;
- CBox geom = pWindow->m_xdgSurface->m_current.geometry;
+ // FIXME: this doesn't work. We always set MAXIMIZED anyways, so this doesn't need to work, but it's problematic.
- // Adjust UV based on the xdg_surface geometry
- if (geom.x != 0 || geom.y != 0 || geom.w != 0 || geom.h != 0) {
- const auto XPERC = geom.x / pSurface->m_current.size.x;
- const auto YPERC = geom.y / pSurface->m_current.size.y;
- const auto WPERC = (geom.x + geom.w ? geom.w : pSurface->m_current.size.x) / pSurface->m_current.size.x;
- const auto HPERC = (geom.y + geom.h ? geom.h : pSurface->m_current.size.y) / pSurface->m_current.size.y;
+ // CBox geom = pWindow->m_xdgSurface->m_current.geometry;
- 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 the xdg_surface geometry
+ // if (geom.x != 0 || geom.y != 0 || geom.w != 0 || geom.h != 0) {
+ // const auto XPERC = geom.x / pSurface->m_current.size.x;
+ // const auto YPERC = geom.y / pSurface->m_current.size.y;
+ // const auto WPERC = (geom.x + geom.w ? geom.w : pSurface->m_current.size.x) / pSurface->m_current.size.x;
+ // const auto HPERC = (geom.y + geom.h ? geom.h : pSurface->m_current.size.y) / pSurface->m_current.size.y;
- // 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 (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);
- }
+ // 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;
+ // }
g_pHyprOpenGL->m_renderData.primarySurfaceUVTopLeft = uvTL;
g_pHyprOpenGL->m_renderData.primarySurfaceUVBottomRight = uvBR;