aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorvaxerski <[email protected]>2023-07-20 14:11:05 +0200
committervaxerski <[email protected]>2023-07-20 14:11:05 +0200
commit948855a98442a2d04665b0ac34d0651c013d4b37 (patch)
tree5b4e9f32f05979ab29ef7a0ce0d53b0e695795c9
parent547305c7ed02c37b68773b2ccb6fb7f702898f0a (diff)
downloadHyprland-948855a98442a2d04665b0ac34d0651c013d4b37.tar.gz
Hyprland-948855a98442a2d04665b0ac34d0651c013d4b37.zip
renderer: add canSkipBackBufferClear
-rw-r--r--src/render/Renderer.cpp26
-rw-r--r--src/render/Renderer.hpp1
2 files changed, 23 insertions, 4 deletions
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index f3656fc7..6bf783af 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -995,10 +995,12 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
EMIT_HOOK_EVENT("render", RENDER_POST_MIRROR);
} else {
g_pHyprOpenGL->blend(false);
- if (*PRENDERTEX /* inverted cfg flag */)
- g_pHyprOpenGL->clear(CColor(17.0 / 255.0, 17.0 / 255.0, 17.0 / 255.0, 1.0));
- else
- g_pHyprOpenGL->clearWithTex(); // will apply the hypr "wallpaper"
+ if (!canSkipBackBufferClear(pMonitor)) {
+ if (*PRENDERTEX /* inverted cfg flag */)
+ g_pHyprOpenGL->clear(CColor(17.0 / 255.0, 17.0 / 255.0, 17.0 / 255.0, 1.0));
+ else
+ g_pHyprOpenGL->clearWithTex(); // will apply the hypr "wallpaper"
+ }
g_pHyprOpenGL->blend(true);
wlr_box renderBox = {0, 0, (int)pMonitor->vecPixelSize.x, (int)pMonitor->vecPixelSize.y};
@@ -2000,3 +2002,19 @@ void CHyprRenderer::setOccludedForBackLayers(CRegion& region, CWorkspace* pWorks
region.subtract(rg);
}
+
+bool CHyprRenderer::canSkipBackBufferClear(CMonitor* pMonitor) {
+ for (auto& ls : pMonitor->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND]) {
+ if (!ls->layerSurface)
+ continue;
+
+ if (!ls->layerSurface->surface->opaque || !(ls->alpha.fl() >= 1.f))
+ continue;
+
+ if (ls->geometry.x == pMonitor->vecPosition.x && ls->geometry.y == pMonitor->vecPosition.y && ls->geometry.width == pMonitor->vecSize.x &&
+ ls->geometry.height == pMonitor->vecSize.y)
+ return true;
+ }
+
+ return false;
+}
diff --git a/src/render/Renderer.hpp b/src/render/Renderer.hpp
index 77f063e7..badd4a45 100644
--- a/src/render/Renderer.hpp
+++ b/src/render/Renderer.hpp
@@ -52,6 +52,7 @@ class CHyprRenderer {
std::tuple<float, float, float> getRenderTimes(CMonitor* pMonitor); // avg max min
void renderLockscreen(CMonitor* pMonitor, timespec* now);
void setOccludedForBackLayers(CRegion& region, CWorkspace* pWorkspace);
+ bool canSkipBackBufferClear(CMonitor* pMonitor);
bool m_bWindowRequestedCursorHide = false;
bool m_bBlockSurfaceFeedback = false;