renderer: workspace rendering improvements

This commit is contained in:
vaxerski 2023-04-12 13:05:57 +01:00
parent f00e11d457
commit 293df75b97
2 changed files with 23 additions and 20 deletions

View file

@ -59,28 +59,29 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) {
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D(-1, -1); g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D(-1, -1);
} }
bool CHyprRenderer::shouldRenderWindow(CWindow* pWindow, CMonitor* pMonitor) { bool CHyprRenderer::shouldRenderWindow(CWindow* pWindow, CMonitor* pMonitor, CWorkspace* pWorkspace) {
wlr_box geometry = pWindow->getFullWindowBoundingBox(); wlr_box geometry = pWindow->getFullWindowBoundingBox();
if (!wlr_output_layout_intersects(g_pCompositor->m_sWLROutputLayout, pMonitor->output, &geometry)) if (!wlr_output_layout_intersects(g_pCompositor->m_sWLROutputLayout, pMonitor->output, &geometry))
return false; return false;
if (pWindow->m_iWorkspaceID == -1)
return false;
if (pWindow->m_bPinned) if (pWindow->m_bPinned)
return true; return true;
// now check if it has the same workspace // now check if it has the same workspace
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID); if (pWorkspace && pWorkspace->m_iMonitorID == pMonitor->ID) {
if (pWorkspace->m_vRenderOffset.isBeingAnimated() || pWorkspace->m_fAlpha.isBeingAnimated() || pWorkspace->m_bForceRendering) {
if (PWORKSPACE && PWORKSPACE->m_iMonitorID == pMonitor->ID) {
if (PWORKSPACE->m_vRenderOffset.isBeingAnimated() || PWORKSPACE->m_fAlpha.isBeingAnimated() || PWORKSPACE->m_bForceRendering) {
return true; return true;
} else { } else {
if (!(!PWORKSPACE->m_bHasFullscreenWindow || pWindow->m_bIsFullscreen || (pWindow->m_bIsFloating && pWindow->m_bCreatedOverFullscreen))) if (!(!pWorkspace->m_bHasFullscreenWindow || pWindow->m_bIsFullscreen || (pWindow->m_bIsFloating && pWindow->m_bCreatedOverFullscreen)))
return false; return false;
} }
} }
if (pWindow->m_iWorkspaceID == pMonitor->activeWorkspace) if (pWindow->m_iWorkspaceID == pWorkspace->m_iID)
return true; return true;
// if not, check if it maybe is active on a different monitor. // if not, check if it maybe is active on a different monitor.
@ -100,6 +101,9 @@ bool CHyprRenderer::shouldRenderWindow(CWindow* pWindow) {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID); const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
if (pWindow->m_iWorkspaceID == -1)
return false;
if (pWindow->m_bPinned || PWORKSPACE->m_bForceRendering) if (pWindow->m_bPinned || PWORKSPACE->m_bForceRendering)
return true; return true;
@ -190,7 +194,7 @@ void CHyprRenderer::renderWorkspaceWithFullscreenWindow(CMonitor* pMonitor, CWor
if (w->m_iWorkspaceID != pMonitor->specialWorkspaceID) if (w->m_iWorkspaceID != pMonitor->specialWorkspaceID)
continue; continue;
if (!shouldRenderWindow(w.get(), pMonitor)) if (!shouldRenderWindow(w.get(), pMonitor, pWorkspace))
continue; continue;
// render the bad boy // render the bad boy
@ -411,7 +415,7 @@ void CHyprRenderer::renderSessionLockSurface(SSessionLockSurface* pSurface, CMon
wlr_surface_for_each_surface(pSurface->pWlrLockSurface->surface, renderSurface, &renderdata); wlr_surface_for_each_surface(pSurface->pWlrLockSurface->surface, renderSurface, &renderdata);
} }
void CHyprRenderer::renderAllClientsForMonitor(CMonitor* pMonitor, timespec* time, const Vector2D& translate, const float& scale) { void CHyprRenderer::renderAllClientsForWorkspace(CMonitor* pMonitor, CWorkspace* pWorkspace, timespec* time, const Vector2D& translate, const float& scale) {
static auto* const PDIMSPECIAL = &g_pConfigManager->getConfigValuePtr("decoration:dim_special")->floatValue; static auto* const PDIMSPECIAL = &g_pConfigManager->getConfigValuePtr("decoration:dim_special")->floatValue;
const SRenderModifData RENDERMODIFDATA = {translate, scale}; const SRenderModifData RENDERMODIFDATA = {translate, scale};
@ -444,10 +448,9 @@ void CHyprRenderer::renderAllClientsForMonitor(CMonitor* pMonitor, timespec* tim
// if there is a fullscreen window, render it and then do not render anymore. // if there is a fullscreen window, render it and then do not render anymore.
// fullscreen window will hide other windows and top layers // fullscreen window will hide other windows and top layers
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pMonitor->activeWorkspace);
if (PWORKSPACE->m_bHasFullscreenWindow) { if (pWorkspace->m_bHasFullscreenWindow) {
renderWorkspaceWithFullscreenWindow(pMonitor, PWORKSPACE, time); renderWorkspaceWithFullscreenWindow(pMonitor, pWorkspace, time);
g_pHyprOpenGL->m_RenderData.renderModif = {}; g_pHyprOpenGL->m_RenderData.renderModif = {};
return; return;
} }
@ -465,7 +468,7 @@ void CHyprRenderer::renderAllClientsForMonitor(CMonitor* pMonitor, timespec* tim
if (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID)) if (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID))
continue; // special are in the third pass continue; // special are in the third pass
if (!shouldRenderWindow(w.get(), pMonitor)) if (!shouldRenderWindow(w.get(), pMonitor, pWorkspace))
continue; continue;
// render active window after all others of this pass // render active window after all others of this pass
@ -492,7 +495,7 @@ void CHyprRenderer::renderAllClientsForMonitor(CMonitor* pMonitor, timespec* tim
if (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID)) if (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID))
continue; // special are in the third pass continue; // special are in the third pass
if (!shouldRenderWindow(w.get(), pMonitor)) if (!shouldRenderWindow(w.get(), pMonitor, pWorkspace))
continue; continue;
// render the bad boy // render the bad boy
@ -510,7 +513,7 @@ void CHyprRenderer::renderAllClientsForMonitor(CMonitor* pMonitor, timespec* tim
if (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID)) if (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID))
continue; continue;
if (!shouldRenderWindow(w.get(), pMonitor)) if (!shouldRenderWindow(w.get(), pMonitor, pWorkspace))
continue; continue;
// render the bad boy // render the bad boy
@ -528,7 +531,7 @@ void CHyprRenderer::renderAllClientsForMonitor(CMonitor* pMonitor, timespec* tim
if (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID)) if (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID))
continue; continue;
if (!shouldRenderWindow(w.get(), pMonitor)) if (!shouldRenderWindow(w.get(), pMonitor, pWorkspace))
continue; continue;
// render the bad boy // render the bad boy
@ -544,7 +547,7 @@ void CHyprRenderer::renderAllClientsForMonitor(CMonitor* pMonitor, timespec* tim
if (!g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID)) if (!g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID))
continue; continue;
if (!shouldRenderWindow(w.get(), pMonitor)) if (!shouldRenderWindow(w.get(), pMonitor, pWorkspace))
continue; continue;
if (!renderedSpecialBG) { if (!renderedSpecialBG) {
@ -1006,7 +1009,7 @@ void CHyprRenderer::renderWorkspace(CMonitor* pMonitor, CWorkspace* pWorkspace,
translate = Vector2D{}; translate = Vector2D{};
} }
renderAllClientsForMonitor(pMonitor, now, translate, scale); renderAllClientsForWorkspace(pMonitor, pWorkspace, now, translate, scale);
} }
void CHyprRenderer::setWindowScanoutMode(CWindow* pWindow) { void CHyprRenderer::setWindowScanoutMode(CWindow* pWindow) {

View file

@ -42,7 +42,7 @@ class CHyprRenderer {
void damageMonitor(CMonitor*); void damageMonitor(CMonitor*);
void damageMirrorsWith(CMonitor*, pixman_region32_t*); void damageMirrorsWith(CMonitor*, pixman_region32_t*);
bool applyMonitorRule(CMonitor*, SMonitorRule*, bool force = false); bool applyMonitorRule(CMonitor*, SMonitorRule*, bool force = false);
bool shouldRenderWindow(CWindow*, CMonitor*); bool shouldRenderWindow(CWindow*, CMonitor*, CWorkspace*);
bool shouldRenderWindow(CWindow*); bool shouldRenderWindow(CWindow*);
void ensureCursorRenderingMode(); void ensureCursorRenderingMode();
bool shouldRenderCursor(); bool shouldRenderCursor();
@ -77,7 +77,7 @@ class CHyprRenderer {
void renderDragIcon(CMonitor*, timespec*); void renderDragIcon(CMonitor*, timespec*);
void renderIMEPopup(SIMEPopup*, CMonitor*, timespec*); void renderIMEPopup(SIMEPopup*, CMonitor*, timespec*);
void renderWorkspace(CMonitor* pMonitor, CWorkspace* pWorkspace, timespec* now, const wlr_box& geometry); void renderWorkspace(CMonitor* pMonitor, CWorkspace* pWorkspace, timespec* now, const wlr_box& geometry);
void renderAllClientsForMonitor(CMonitor* pMonitor, timespec* now, const Vector2D& translate = {0, 0}, const float& scale = 1.f); void renderAllClientsForWorkspace(CMonitor* pMonitor, CWorkspace* pWorkspace, timespec* now, const Vector2D& translate = {0, 0}, const float& scale = 1.f);
bool m_bHasARenderedCursor = true; bool m_bHasARenderedCursor = true;