diff options
author | vaxerski <[email protected]> | 2023-12-31 13:11:20 +0100 |
---|---|---|
committer | vaxerski <[email protected]> | 2023-12-31 13:11:26 +0100 |
commit | b5b025a1ed6cfa2b94ad0eff38a247223edd95bb (patch) | |
tree | 4b421f763b6cb8eba82e708d7fffa8bb486769e8 | |
parent | 94d6b2d2c12663efe90f6d0410528b0d7bcc671e (diff) | |
download | Hyprland-b5b025a1ed6cfa2b94ad0eff38a247223edd95bb.tar.gz Hyprland-b5b025a1ed6cfa2b94ad0eff38a247223edd95bb.zip |
renderer: use nearest_neighbor for misaligned fractional-scale surfaces
ref #4225
-rw-r--r-- | src/render/Renderer.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 6a4a0460..a6d58866 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -53,8 +53,9 @@ static void renderSurface(struct wlr_surface* surface, int x, int y, void* data) static auto* const PBLURPOPUPS = &g_pConfigManager->getConfigValuePtr("decoration:blur:popups")->intValue; static auto* const PBLURPOPUPSIGNOREALPHA = &g_pConfigManager->getConfigValuePtr("decoration:blur:popups_ignorealpha")->floatValue; - const auto TEXTURE = wlr_surface_get_texture(surface); - const auto RDATA = (SRenderData*)data; + const auto TEXTURE = wlr_surface_get_texture(surface); + const auto RDATA = (SRenderData*)data; + const auto INTERACTIVERESIZEINPROGRESS = RDATA->pWindow && g_pInputManager->currentlyDraggedWindow == RDATA->pWindow && g_pInputManager->dragMode == MBIND_RESIZE; if (!TEXTURE) return; @@ -72,9 +73,8 @@ static void renderSurface(struct wlr_surface* surface, int x, int y, void* data) auto* const PSURFACE = CWLSurface::surfaceFromWlr(surface); if (PSURFACE && !PSURFACE->m_bFillIgnoreSmall && PSURFACE->small() /* guarantees m_pOwner */) { - const auto CORRECT = PSURFACE->correctSmallVec(); - const auto SIZE = PSURFACE->getViewporterCorrectedSize(); - const auto INTERACTIVERESIZEINPROGRESS = g_pInputManager->currentlyDraggedWindow == PSURFACE->m_pOwner && g_pInputManager->dragMode == MBIND_RESIZE; + const auto CORRECT = PSURFACE->correctSmallVec(); + const auto SIZE = PSURFACE->getViewporterCorrectedSize(); if (!INTERACTIVERESIZEINPROGRESS) { windowBox.x += CORRECT.x; @@ -112,6 +112,15 @@ static void renderSurface(struct wlr_surface* surface, int x, int y, void* data) windowBox.scale(RDATA->pMonitor->scale); windowBox.round(); + // check for fractional scale surfaces misaligning the buffer size + // in those cases it's better to just force nearest neighbor + // as long as the window is not animated. During those it'd look weird + const auto NEARESTNEIGHBORSET = g_pHyprOpenGL->m_RenderData.useNearestNeighbor; + if (std::floor(RDATA->pMonitor->scale) != RDATA->pMonitor->scale /* Fractional */ && surface->current.scale == 1 /* fs protocol */ && + windowBox.size() != Vector2D{surface->current.buffer_width, surface->current.buffer_height} /* misaligned */ && + (!RDATA->pWindow || (!RDATA->pWindow->m_vRealSize.isBeingAnimated() && !INTERACTIVERESIZEINPROGRESS)) /* not window or not animated/resizing */) + g_pHyprOpenGL->m_RenderData.useNearestNeighbor = true; + float rounding = RDATA->rounding; rounding -= 1; // to fix a border issue @@ -157,9 +166,10 @@ static void renderSurface(struct wlr_surface* surface, int x, int y, void* data) g_pHyprOpenGL->blend(true); - // reset the UV, we might've set it above + // reset props g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(-1, -1); g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D(-1, -1); + g_pHyprOpenGL->m_RenderData.useNearestNeighbor = NEARESTNEIGHBORSET; } bool CHyprRenderer::shouldRenderWindow(CWindow* pWindow, CMonitor* pMonitor, CWorkspace* pWorkspace) { |