From e9510115039e7ae9fcf2778e8455e7beed3424ea Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sun, 26 Jan 2025 15:05:34 +0000 Subject: [PATCH] renderer/internal: stop using box pointers in favor of const refs --- src/debug/HyprDebugOverlay.cpp | 4 +- src/debug/HyprNotificationOverlay.cpp | 6 +- src/desktop/LayerSurface.cpp | 10 +- src/desktop/Popup.cpp | 10 +- src/desktop/Subsurface.cpp | 10 +- src/events/Windows.cpp | 5 +- src/helpers/Monitor.cpp | 8 +- src/helpers/Monitor.hpp | 4 +- src/hyprerror/HyprError.cpp | 4 +- src/layout/IHyprLayout.cpp | 8 +- src/managers/AnimationManager.cpp | 8 +- src/managers/PointerManager.cpp | 6 +- src/managers/XWaylandManager.cpp | 24 ++- src/managers/XWaylandManager.hpp | 2 +- src/managers/input/InputMethodPopup.cpp | 2 +- src/protocols/AlphaModifier.cpp | 2 +- src/protocols/HyprlandSurface.cpp | 2 +- src/protocols/Screencopy.cpp | 4 +- src/protocols/core/DataDevice.cpp | 2 +- src/render/OpenGL.cpp | 182 ++++++++---------- src/render/OpenGL.hpp | 130 ++++++------- src/render/Renderer.cpp | 25 ++- src/render/Renderer.hpp | 2 +- .../decorations/CHyprDropShadowDecoration.cpp | 16 +- .../decorations/CHyprDropShadowDecoration.hpp | 2 +- .../decorations/CHyprGroupBarDecoration.cpp | 2 +- src/render/pass/BorderPassElement.cpp | 4 +- src/render/pass/Pass.cpp | 14 +- src/render/pass/RectPassElement.cpp | 4 +- src/render/pass/SurfacePassElement.cpp | 8 +- src/render/pass/TexPassElement.cpp | 2 +- src/render/pass/TextureMatteElement.cpp | 4 +- 32 files changed, 252 insertions(+), 264 deletions(-) diff --git a/src/debug/HyprDebugOverlay.cpp b/src/debug/HyprDebugOverlay.cpp index 6e7a0407..9ea7f1bc 100644 --- a/src/debug/HyprDebugOverlay.cpp +++ b/src/debug/HyprDebugOverlay.cpp @@ -198,10 +198,10 @@ int CHyprMonitorDebugOverlay::draw(int offset) { double posX = 0, posY = 0; cairo_get_current_point(cr, &posX, &posY); - g_pHyprRenderer->damageBox(&m_wbLastDrawnBox); + g_pHyprRenderer->damageBox(m_wbLastDrawnBox); m_wbLastDrawnBox = {(int)g_pCompositor->m_vMonitors.front()->vecPosition.x + MARGIN_LEFT - 1, (int)g_pCompositor->m_vMonitors.front()->vecPosition.y + offset + MARGIN_TOP - 1, (int)maxTextW + 2, posY - offset - MARGIN_TOP + 2}; - g_pHyprRenderer->damageBox(&m_wbLastDrawnBox); + g_pHyprRenderer->damageBox(m_wbLastDrawnBox); return posY - offset; } diff --git a/src/debug/HyprNotificationOverlay.cpp b/src/debug/HyprNotificationOverlay.cpp index 66c68d08..4081af84 100644 --- a/src/debug/HyprNotificationOverlay.cpp +++ b/src/debug/HyprNotificationOverlay.cpp @@ -26,7 +26,7 @@ CHyprNotificationOverlay::CHyprNotificationOverlay() { if (m_vNotifications.size() == 0) return; - g_pHyprRenderer->damageBox(&m_bLastDamage); + g_pHyprRenderer->damageBox(m_bLastDamage); }); m_pTexture = makeShared(); @@ -225,8 +225,8 @@ void CHyprNotificationOverlay::draw(PHLMONITOR pMonitor) { CBox damage = drawNotifications(pMonitor); - g_pHyprRenderer->damageBox(&damage); - g_pHyprRenderer->damageBox(&m_bLastDamage); + g_pHyprRenderer->damageBox(damage); + g_pHyprRenderer->damageBox(m_bLastDamage); g_pCompositor->scheduleFrameForMonitor(pMonitor); diff --git a/src/desktop/LayerSurface.cpp b/src/desktop/LayerSurface.cpp index c2b07c5d..e2d0177b 100644 --- a/src/desktop/LayerSurface.cpp +++ b/src/desktop/LayerSurface.cpp @@ -115,7 +115,7 @@ void CLayerSurface::onDestroy() { // and damage CBox geomFixed = {geometry.x + PMONITOR->vecPosition.x, geometry.y + PMONITOR->vecPosition.y, geometry.width, geometry.height}; - g_pHyprRenderer->damageBox(&geomFixed); + g_pHyprRenderer->damageBox(geomFixed); } readyToDelete = true; @@ -179,7 +179,7 @@ void CLayerSurface::onMap() { position = Vector2D(geometry.x, geometry.y); CBox geomFixed = {geometry.x + PMONITOR->vecPosition.x, geometry.y + PMONITOR->vecPosition.y, geometry.width, geometry.height}; - g_pHyprRenderer->damageBox(&geomFixed); + g_pHyprRenderer->damageBox(geomFixed); const bool FULLSCREEN = PMONITOR->activeWorkspace && PMONITOR->activeWorkspace->m_bHasFullscreenWindow && PMONITOR->activeWorkspace->m_efFullscreenMode == FSMODE_FULLSCREEN; startAnimation(!(layer == ZWLR_LAYER_SHELL_V1_LAYER_TOP && FULLSCREEN && !GRABSFOCUS)); @@ -240,11 +240,11 @@ void CLayerSurface::onUnmap() { g_pSeatManager->setKeyboardFocus(g_pCompositor->m_pLastFocus.lock()); CBox geomFixed = {geometry.x + PMONITOR->vecPosition.x, geometry.y + PMONITOR->vecPosition.y, geometry.width, geometry.height}; - g_pHyprRenderer->damageBox(&geomFixed); + g_pHyprRenderer->damageBox(geomFixed); geomFixed = {geometry.x + (int)PMONITOR->vecPosition.x, geometry.y + (int)PMONITOR->vecPosition.y, (int)layerSurface->surface->current.size.x, (int)layerSurface->surface->current.size.y}; - g_pHyprRenderer->damageBox(&geomFixed); + g_pHyprRenderer->damageBox(geomFixed); g_pInputManager->simulateMouseMovement(); @@ -275,7 +275,7 @@ void CLayerSurface::onCommit() { g_pHyprOpenGL->markBlurDirtyForMonitor(PMONITOR); // so that blur is recalc'd CBox geomFixed = {geometry.x, geometry.y, geometry.width, geometry.height}; - g_pHyprRenderer->damageBox(&geomFixed); + g_pHyprRenderer->damageBox(geomFixed); if (layerSurface->current.committed != 0) { if (layerSurface->current.committed & CLayerShellResource::eCommittedState::STATE_LAYER) { diff --git a/src/desktop/Popup.cpp b/src/desktop/Popup.cpp index 0c7c72a4..93a810ff 100644 --- a/src/desktop/Popup.cpp +++ b/src/desktop/Popup.cpp @@ -85,7 +85,7 @@ void CPopup::onMap() { CBox box = m_pWLSurface->resource()->extends(); box.translate(COORDS).expand(4); - g_pHyprRenderer->damageBox(&box); + g_pHyprRenderer->damageBox(box); m_vLastPos = coordsRelativeToParent(); @@ -120,7 +120,7 @@ void CPopup::onUnmap() { CBox box = m_pWLSurface->resource()->extends(); box.translate(COORDS).expand(4); - g_pHyprRenderer->damageBox(&box); + g_pHyprRenderer->damageBox(box); m_pSubsurfaceHead.reset(); @@ -134,7 +134,7 @@ void CPopup::onUnmap() { return; auto box = CBox{p->coordsGlobal(), p->size()}; - g_pHyprRenderer->damageBox(&box); + g_pHyprRenderer->damageBox(box); }, nullptr); @@ -173,10 +173,10 @@ void CPopup::onCommit(bool ignoreSiblings) { if (m_vLastSize != m_pResource->surface->surface->current.size || m_bRequestedReposition || m_vLastPos != COORDSLOCAL) { CBox box = {localToGlobal(m_vLastPos), m_vLastSize}; - g_pHyprRenderer->damageBox(&box); + g_pHyprRenderer->damageBox(box); m_vLastSize = m_pResource->surface->surface->current.size; box = {COORDS, m_vLastSize}; - g_pHyprRenderer->damageBox(&box); + g_pHyprRenderer->damageBox(box); m_vLastPos = COORDSLOCAL; } diff --git a/src/desktop/Subsurface.cpp b/src/desktop/Subsurface.cpp index 5657cb39..a68cf8f3 100644 --- a/src/desktop/Subsurface.cpp +++ b/src/desktop/Subsurface.cpp @@ -103,10 +103,10 @@ void CSubsurface::onCommit() { if (m_vLastSize != m_pWLSurface->resource()->current.size) { // TODO: fix this // CBox box{COORDS, m_vLastSize}; - // g_pHyprRenderer->damageBox(&box); + // g_pHyprRenderer->damageBox(box); // m_vLastSize = m_pWLSurface->resource()->current.size; // box = {COORDS, m_vLastSize}; - // g_pHyprRenderer->damageBox(&box); + // g_pHyprRenderer->damageBox(box); CBox box; if (m_pPopupParent) @@ -114,7 +114,7 @@ void CSubsurface::onCommit() { else if (m_pWindowParent) box = m_pWindowParent->getWindowMainSurfaceBox(); - g_pHyprRenderer->damageBox(&box); + g_pHyprRenderer->damageBox(box); } } @@ -152,7 +152,7 @@ void CSubsurface::onMap() { const auto COORDS = coordsGlobal(); CBox box{COORDS, m_vLastSize}; box.expand(4); - g_pHyprRenderer->damageBox(&box); + g_pHyprRenderer->damageBox(box); if (!m_pWindowParent.expired()) m_pWindowParent->updateSurfaceScaleTransformDetails(); @@ -162,7 +162,7 @@ void CSubsurface::onUnmap() { const auto COORDS = coordsGlobal(); CBox box{COORDS, m_vLastSize}; box.expand(4); - g_pHyprRenderer->damageBox(&box); + g_pHyprRenderer->damageBox(box); if (m_pWLSurface->resource() == g_pCompositor->m_pLastFocus) g_pInputManager->releaseAllMouseButtons(); diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 9ecf3652..f6ef9ced 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -376,9 +376,8 @@ void Events::listener_mapWindow(void* owner, void* data) { if (PWORKSPACE->m_bDefaultPseudo) { PWINDOW->m_bIsPseudotiled = true; - CBox desiredGeometry = {0}; - g_pXWaylandManager->getGeometryForWindow(PWINDOW, &desiredGeometry); - PWINDOW->m_vPseudoSize = Vector2D(desiredGeometry.width, desiredGeometry.height); + CBox desiredGeometry = g_pXWaylandManager->getGeometryForWindow(PWINDOW); + PWINDOW->m_vPseudoSize = Vector2D(desiredGeometry.width, desiredGeometry.height); } PWINDOW->updateWindowData(); diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index 6fcaeeee..19d68a56 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -766,18 +766,18 @@ void CMonitor::addDamage(const pixman_region32_t* rg) { g_pCompositor->scheduleFrameForMonitor(self.lock(), Aquamarine::IOutput::AQ_SCHEDULE_DAMAGE); } -void CMonitor::addDamage(const CRegion* rg) { - addDamage(const_cast(rg)->pixman()); +void CMonitor::addDamage(const CRegion& rg) { + addDamage(const_cast(&rg)->pixman()); } -void CMonitor::addDamage(const CBox* box) { +void CMonitor::addDamage(const CBox& box) { static auto PZOOMFACTOR = CConfigValue("cursor:zoom_factor"); if (*PZOOMFACTOR != 1.f && g_pCompositor->getMonitorFromCursor() == self) { damage.damageEntire(); g_pCompositor->scheduleFrameForMonitor(self.lock(), Aquamarine::IOutput::AQ_SCHEDULE_DAMAGE); } - if (damage.damage(*box)) + if (damage.damage(box)) g_pCompositor->scheduleFrameForMonitor(self.lock(), Aquamarine::IOutput::AQ_SCHEDULE_DAMAGE); } diff --git a/src/helpers/Monitor.hpp b/src/helpers/Monitor.hpp index e07d62c6..7c19b57c 100644 --- a/src/helpers/Monitor.hpp +++ b/src/helpers/Monitor.hpp @@ -166,8 +166,8 @@ class CMonitor { void onDisconnect(bool destroy = false); bool applyMonitorRule(SMonitorRule* pMonitorRule, bool force = false); void addDamage(const pixman_region32_t* rg); - void addDamage(const CRegion* rg); - void addDamage(const CBox* box); + void addDamage(const CRegion& rg); + void addDamage(const CBox& box); bool shouldSkipScheduleFrameOnMouseEvent(); void setMirror(const std::string&); bool isMirror(); diff --git a/src/hyprerror/HyprError.cpp b/src/hyprerror/HyprError.cpp index d14173bf..4076ed3a 100644 --- a/src/hyprerror/HyprError.cpp +++ b/src/hyprerror/HyprError.cpp @@ -26,7 +26,7 @@ CHyprError::CHyprError() { return; if (m_fFadeOpacity->isBeingAnimated() || m_bMonitorChanged) - g_pHyprRenderer->damageBox(&m_bDamageBox); + g_pHyprRenderer->damageBox(m_bDamageBox); }); m_pTexture = makeShared(); @@ -203,7 +203,7 @@ void CHyprError::draw() { m_bDamageBox.y = (int)PMONITOR->vecPosition.y; if (m_fFadeOpacity->isBeingAnimated() || m_bMonitorChanged) - g_pHyprRenderer->damageBox(&m_bDamageBox); + g_pHyprRenderer->damageBox(m_bDamageBox); m_bMonitorChanged = false; diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp index 81392be9..5e5669b8 100644 --- a/src/layout/IHyprLayout.cpp +++ b/src/layout/IHyprLayout.cpp @@ -14,8 +14,7 @@ #include "../managers/HookSystemManager.hpp" void IHyprLayout::onWindowCreated(PHLWINDOW pWindow, eDirection direction) { - CBox desiredGeometry = {}; - g_pXWaylandManager->getGeometryForWindow(pWindow, &desiredGeometry); + CBox desiredGeometry = g_pXWaylandManager->getGeometryForWindow(pWindow); if (desiredGeometry.width <= 5 || desiredGeometry.height <= 5) { const auto PMONITOR = pWindow->m_pMonitor.lock(); @@ -91,9 +90,8 @@ void IHyprLayout::onWindowRemovedFloating(PHLWINDOW pWindow) { void IHyprLayout::onWindowCreatedFloating(PHLWINDOW pWindow) { - CBox desiredGeometry = {0}; - g_pXWaylandManager->getGeometryForWindow(pWindow, &desiredGeometry); - const auto PMONITOR = pWindow->m_pMonitor.lock(); + CBox desiredGeometry = g_pXWaylandManager->getGeometryForWindow(pWindow); + const auto PMONITOR = pWindow->m_pMonitor.lock(); if (pWindow->m_bIsX11) { Vector2D xy = {desiredGeometry.x, desiredGeometry.y}; diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp index 964f7cfa..5be7aa33 100644 --- a/src/managers/AnimationManager.cpp +++ b/src/managers/AnimationManager.cpp @@ -41,7 +41,7 @@ CHyprAnimationManager::CHyprAnimationManager() { } template -void updateVariable(CAnimatedVariable& av, const float POINTY, bool warp = false) { +static void updateVariable(CAnimatedVariable& av, const float POINTY, bool warp = false) { if (warp || av.value() == av.goal()) { av.warp(); return; @@ -51,7 +51,7 @@ void updateVariable(CAnimatedVariable& av, const float POINTY, bool war av.value() = av.begun() + DELTA * POINTY; } -void updateColorVariable(CAnimatedVariable& av, const float POINTY, bool warp) { +static void updateColorVariable(CAnimatedVariable& av, const float POINTY, bool warp) { if (warp || av.value() == av.goal()) { av.warp(); return; @@ -137,7 +137,7 @@ static void handleUpdate(CAnimatedVariable& av, bool warp) { // "some fucking layers miss 1 pixel???" -- vaxry CBox expandBox = CBox{PLAYER->realPosition->value(), PLAYER->realSize->value()}; expandBox.expand(5); - g_pHyprRenderer->damageBox(&expandBox); + g_pHyprRenderer->damageBox(expandBox); PMONITOR = g_pCompositor->getMonitorFromVector(PLAYER->realPosition->goal() + PLAYER->realSize->goal() / 2.F); if (!PMONITOR) @@ -180,7 +180,7 @@ static void handleUpdate(CAnimatedVariable& av, bool warp) { // some fucking layers miss 1 pixel??? CBox expandBox = CBox{PLAYER->realPosition->value(), PLAYER->realSize->value()}; expandBox.expand(5); - g_pHyprRenderer->damageBox(&expandBox); + g_pHyprRenderer->damageBox(expandBox); } break; } diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp index 5fdfa553..48ef5e16 100644 --- a/src/managers/PointerManager.cpp +++ b/src/managers/PointerManager.cpp @@ -566,7 +566,7 @@ SP CPointerManager::renderHWCursorBuffer(SPmonitor->szName, currentCursorImage.size, cursorSize, currentCursorImage.scale, state->monitor->scale, xbox.size()); - g_pHyprOpenGL->renderTexture(texture, &xbox, 1.F); + g_pHyprOpenGL->renderTexture(texture, xbox, 1.F); g_pHyprOpenGL->end(); glFlush(); @@ -730,7 +730,7 @@ void CPointerManager::damageIfSoftware() { continue; if ((mw->softwareLocks > 0 || mw->hardwareFailed || g_pConfigManager->shouldUseSoftwareCursors()) && b.overlaps({mw->monitor->vecPosition, mw->monitor->vecSize})) { - g_pHyprRenderer->damageBox(&b, mw->monitor->shouldSkipScheduleFrameOnMouseEvent()); + g_pHyprRenderer->damageBox(b, mw->monitor->shouldSkipScheduleFrameOnMouseEvent()); break; } } @@ -1143,7 +1143,7 @@ void CPointerManager::damageCursor(PHLMONITOR pMonitor) { if (b.empty()) return; - g_pHyprRenderer->damageBox(&b); + g_pHyprRenderer->damageBox(b); return; } diff --git a/src/managers/XWaylandManager.cpp b/src/managers/XWaylandManager.cpp index ea2a47ea..f103266d 100644 --- a/src/managers/XWaylandManager.cpp +++ b/src/managers/XWaylandManager.cpp @@ -76,9 +76,11 @@ void CHyprXWaylandManager::activateWindow(PHLWINDOW pWindow, bool activate) { pWindow->m_pWorkspace->m_pLastFocusedWindow = pWindow; } -void CHyprXWaylandManager::getGeometryForWindow(PHLWINDOW pWindow, CBox* pbox) { +CBox CHyprXWaylandManager::getGeometryForWindow(PHLWINDOW pWindow) { if (!pWindow) - return; + return {}; + + CBox box; if (pWindow->m_bIsX11) { const auto SIZEHINTS = pWindow->m_pXWaylandSurface->sizeHints.get(); @@ -86,24 +88,26 @@ void CHyprXWaylandManager::getGeometryForWindow(PHLWINDOW pWindow, CBox* pbox) { if (SIZEHINTS && !pWindow->isX11OverrideRedirect()) { // WM_SIZE_HINTS' x,y,w,h is deprecated it seems. // Source: https://x.org/releases/X11R7.6/doc/xorg-docs/specs/ICCCM/icccm.html#wm_normal_hints_property - pbox->x = pWindow->m_pXWaylandSurface->geometry.x; - pbox->y = pWindow->m_pXWaylandSurface->geometry.y; + box.x = pWindow->m_pXWaylandSurface->geometry.x; + box.y = pWindow->m_pXWaylandSurface->geometry.y; constexpr int ICCCM_USSize = 0x2; constexpr int ICCCM_PSize = 0x8; if ((SIZEHINTS->flags & ICCCM_USSize) || (SIZEHINTS->flags & ICCCM_PSize)) { - pbox->w = SIZEHINTS->base_width; - pbox->h = SIZEHINTS->base_height; + box.w = SIZEHINTS->base_width; + box.h = SIZEHINTS->base_height; } else { - pbox->w = pWindow->m_pXWaylandSurface->geometry.w; - pbox->h = pWindow->m_pXWaylandSurface->geometry.h; + box.w = pWindow->m_pXWaylandSurface->geometry.w; + box.h = pWindow->m_pXWaylandSurface->geometry.h; } } else - *pbox = pWindow->m_pXWaylandSurface->geometry; + box = pWindow->m_pXWaylandSurface->geometry; } else if (pWindow->m_pXDGSurface) - *pbox = pWindow->m_pXDGSurface->current.geometry; + box = pWindow->m_pXDGSurface->current.geometry; + + return box; } void CHyprXWaylandManager::sendCloseWindow(PHLWINDOW pWindow) { diff --git a/src/managers/XWaylandManager.hpp b/src/managers/XWaylandManager.hpp index edbdd243..e4f1e17a 100644 --- a/src/managers/XWaylandManager.hpp +++ b/src/managers/XWaylandManager.hpp @@ -15,7 +15,7 @@ class CHyprXWaylandManager { SP getWindowSurface(PHLWINDOW); void activateSurface(SP, bool); void activateWindow(PHLWINDOW, bool); - void getGeometryForWindow(PHLWINDOW, CBox*); + CBox getGeometryForWindow(PHLWINDOW); void sendCloseWindow(PHLWINDOW); void setWindowFullscreen(PHLWINDOW, bool); bool shouldBeFloated(PHLWINDOW, bool pending = false); diff --git a/src/managers/input/InputMethodPopup.cpp b/src/managers/input/InputMethodPopup.cpp index 8c55416b..db08c026 100644 --- a/src/managers/input/InputMethodPopup.cpp +++ b/src/managers/input/InputMethodPopup.cpp @@ -61,7 +61,7 @@ void CInputPopup::damageEntire() { return; } CBox box = globalBox(); - g_pHyprRenderer->damageBox(&box); + g_pHyprRenderer->damageBox(box); } void CInputPopup::damageSurface() { diff --git a/src/protocols/AlphaModifier.cpp b/src/protocols/AlphaModifier.cpp index e8766405..60037632 100644 --- a/src/protocols/AlphaModifier.cpp +++ b/src/protocols/AlphaModifier.cpp @@ -38,7 +38,7 @@ void CAlphaModifier::setResource(SP resource) { auto box = surface->getSurfaceBoxGlobal(); if (box.has_value()) - g_pHyprRenderer->damageBox(&*box); + g_pHyprRenderer->damageBox(*box); if (!m_pResource) PROTO::alphaModifier->destroyAlphaModifier(this); diff --git a/src/protocols/HyprlandSurface.cpp b/src/protocols/HyprlandSurface.cpp index e3716f10..8b65f0fa 100644 --- a/src/protocols/HyprlandSurface.cpp +++ b/src/protocols/HyprlandSurface.cpp @@ -60,7 +60,7 @@ void CHyprlandSurface::setResource(SP resource) { auto box = surface->getSurfaceBoxGlobal(); if (box.has_value()) - g_pHyprRenderer->damageBox(&*box); + g_pHyprRenderer->damageBox(*box); if (!m_pResource) PROTO::hyprlandSurface->destroySurface(this); diff --git a/src/protocols/Screencopy.cpp b/src/protocols/Screencopy.cpp index e0e3a559..e086cc76 100644 --- a/src/protocols/Screencopy.cpp +++ b/src/protocols/Screencopy.cpp @@ -214,7 +214,7 @@ bool CScreencopyFrame::copyDmabuf() { .transform(wlTransformToHyprutils(invertTransform(pMonitor->transform)), pMonitor->vecPixelSize.x, pMonitor->vecPixelSize.y); g_pHyprOpenGL->setMonitorTransformEnabled(true); g_pHyprOpenGL->setRenderModifEnabled(false); - g_pHyprOpenGL->renderTexture(TEXTURE, &monbox, 1); + g_pHyprOpenGL->renderTexture(TEXTURE, monbox, 1); g_pHyprOpenGL->setRenderModifEnabled(true); g_pHyprOpenGL->setMonitorTransformEnabled(false); @@ -247,7 +247,7 @@ bool CScreencopyFrame::copyShm() { CBox monbox = CBox{0, 0, pMonitor->vecTransformedSize.x, pMonitor->vecTransformedSize.y}.translate({-box.x, -box.y}); g_pHyprOpenGL->setMonitorTransformEnabled(true); g_pHyprOpenGL->setRenderModifEnabled(false); - g_pHyprOpenGL->renderTexture(TEXTURE, &monbox, 1); + g_pHyprOpenGL->renderTexture(TEXTURE, monbox, 1); g_pHyprOpenGL->setRenderModifEnabled(true); g_pHyprOpenGL->setMonitorTransformEnabled(false); diff --git a/src/protocols/core/DataDevice.cpp b/src/protocols/core/DataDevice.cpp index 36437dd4..e17b5612 100644 --- a/src/protocols/core/DataDevice.cpp +++ b/src/protocols/core/DataDevice.cpp @@ -806,7 +806,7 @@ void CWLDataDeviceProtocol::renderDND(PHLMONITOR pMonitor, timespec* when) { g_pHyprRenderer->m_sRenderPass.add(makeShared(data)); box = CBox{POS, dnd.dndSurface->current.size}.translate(g_pPointerManager->cursorSizeLogical() / 2.F).expand(5); - g_pHyprRenderer->damageBox(&box); + g_pHyprRenderer->damageBox(box); dnd.dndSurface->frame(when); } diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index 0fe9565f..f0b2f447 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -935,15 +935,15 @@ void CHyprOpenGLImpl::end() { // copy the damaged areas into the mirror buffer // we can't use the offloadFB for mirroring, as it contains artifacts from blurring if (!m_RenderData.pMonitor->mirrors.empty() && !m_bFakeFrame) - saveBufferForMirror(&monbox); + saveBufferForMirror(monbox); m_RenderData.outFB->bind(); blend(false); if (m_sFinalScreenShader.program < 1 && !g_pHyprRenderer->m_bCrashingInProgress) - renderTexturePrimitive(m_RenderData.pCurrentMonData->offloadFB.getTexture(), &monbox); + renderTexturePrimitive(m_RenderData.pCurrentMonData->offloadFB.getTexture(), monbox); else - renderTexture(m_RenderData.pCurrentMonData->offloadFB.getTexture(), &monbox, 1.f); + renderTexture(m_RenderData.pCurrentMonData->offloadFB.getTexture(), monbox, 1.f); blend(true); @@ -1214,7 +1214,7 @@ void CHyprOpenGLImpl::clear(const CHyprColor& color) { } } - scissor((CBox*)nullptr); + scissor(nullptr); } void CHyprOpenGLImpl::blend(bool enabled) { @@ -1227,22 +1227,19 @@ void CHyprOpenGLImpl::blend(bool enabled) { m_bBlend = enabled; } -void CHyprOpenGLImpl::scissor(const CBox* pBox, bool transform) { +void CHyprOpenGLImpl::scissor(const CBox& originalBox, bool transform) { RASSERT(m_RenderData.pMonitor, "Tried to scissor without begin()!"); - if (!pBox) { - glDisable(GL_SCISSOR_TEST); + if (transform) { + CBox box = originalBox; + const auto TR = wlTransformToHyprutils(invertTransform(m_RenderData.pMonitor->transform)); + box.transform(TR, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y); + glScissor(box.x, box.y, box.width, box.height); + glEnable(GL_SCISSOR_TEST); return; } - CBox newBox = *pBox; - - if (transform) { - const auto TR = wlTransformToHyprutils(invertTransform(m_RenderData.pMonitor->transform)); - newBox.transform(TR, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y); - } - - glScissor(newBox.x, newBox.y, newBox.width, newBox.height); + glScissor(originalBox.x, originalBox.y, originalBox.width, originalBox.height); glEnable(GL_SCISSOR_TEST); } @@ -1256,32 +1253,32 @@ void CHyprOpenGLImpl::scissor(const pixman_box32* pBox, bool transform) { CBox newBox = {pBox->x1, pBox->y1, pBox->x2 - pBox->x1, pBox->y2 - pBox->y1}; - scissor(&newBox, transform); + scissor(newBox, transform); } void CHyprOpenGLImpl::scissor(const int x, const int y, const int w, const int h, bool transform) { CBox box = {x, y, w, h}; - scissor(&box, transform); + scissor(box, transform); } -void CHyprOpenGLImpl::renderRect(CBox* box, const CHyprColor& col, int round, float roundingPower) { +void CHyprOpenGLImpl::renderRect(const CBox& box, const CHyprColor& col, int round, float roundingPower) { if (!m_RenderData.damage.empty()) renderRectWithDamage(box, col, m_RenderData.damage, round, roundingPower); } -void CHyprOpenGLImpl::renderRectWithBlur(CBox* box, const CHyprColor& col, int round, float roundingPower, float blurA, bool xray) { +void CHyprOpenGLImpl::renderRectWithBlur(const CBox& box, const CHyprColor& col, int round, float roundingPower, float blurA, bool xray) { if (m_RenderData.damage.empty()) return; CRegion damage{m_RenderData.damage}; - damage.intersect(*box); + damage.intersect(box); CFramebuffer* POUTFB = xray ? &m_RenderData.pCurrentMonData->blurFB : blurMainFramebufferWithDamage(blurA, &damage); m_RenderData.currentFB->bind(); // make a stencil for rounded corners to work with blur - scissor((CBox*)nullptr); // allow the entire window and stencil to render + scissor(nullptr); // allow the entire window and stencil to render glClearStencil(0); glClear(GL_STENCIL_BUFFER_BIT); @@ -1302,7 +1299,7 @@ void CHyprOpenGLImpl::renderRectWithBlur(CBox* box, const CHyprColor& col, int r m_bEndFrame = true; // fix transformed const auto SAVEDRENDERMODIF = m_RenderData.renderModif; m_RenderData.renderModif = {}; // fix shit - renderTextureInternalWithDamage(POUTFB->getTexture(), &MONITORBOX, blurA, damage, 0, 2.0f, false, false, false); + renderTextureInternalWithDamage(POUTFB->getTexture(), MONITORBOX, blurA, damage, 0, 2.0f, false, false, false); m_bEndFrame = false; m_RenderData.renderModif = SAVEDRENDERMODIF; @@ -1311,22 +1308,20 @@ void CHyprOpenGLImpl::renderRectWithBlur(CBox* box, const CHyprColor& col, int r glDisable(GL_STENCIL_TEST); glStencilMask(0xFF); glStencilFunc(GL_ALWAYS, 1, 0xFF); - scissor((CBox*)nullptr); + scissor(nullptr); renderRectWithDamage(box, col, m_RenderData.damage, round, roundingPower); } -void CHyprOpenGLImpl::renderRectWithDamage(CBox* box, const CHyprColor& col, const CRegion& damage, int round, float roundingPower) { - RASSERT((box->width > 0 && box->height > 0), "Tried to render rect with width/height < 0!"); +void CHyprOpenGLImpl::renderRectWithDamage(const CBox& box, const CHyprColor& col, const CRegion& damage, int round, float roundingPower) { + RASSERT((box.width > 0 && box.height > 0), "Tried to render rect with width/height < 0!"); RASSERT(m_RenderData.pMonitor, "Tried to render rect without begin()!"); TRACY_GPU_ZONE("RenderRectWithDamage"); - CBox newBox = *box; + CBox newBox = box; m_RenderData.renderModif.applyToBox(newBox); - box = &newBox; - Mat3x3 matrix = m_RenderData.monitorProjection.projectBox( newBox, wlTransformToHyprutils(invertTransform(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform)), newBox.rot); Mat3x3 glMatrix = m_RenderData.projection.copy().multiply(matrix); @@ -1343,7 +1338,7 @@ void CHyprOpenGLImpl::renderRectWithDamage(CBox* box, const CHyprColor& col, con // premultiply the color as well as we don't work with straight alpha glUniform4f(m_RenderData.pCurrentMonData->m_shQUAD.color, col.r * col.a, col.g * col.a, col.b * col.a, col.a); - CBox transformedBox = *box; + CBox transformedBox = box; transformedBox.transform(wlTransformToHyprutils(invertTransform(m_RenderData.pMonitor->transform)), m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y); @@ -1379,27 +1374,27 @@ void CHyprOpenGLImpl::renderRectWithDamage(CBox* box, const CHyprColor& col, con glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shQUAD.posAttrib); - scissor((CBox*)nullptr); + scissor(nullptr); } -void CHyprOpenGLImpl::renderTexture(SP tex, CBox* pBox, float alpha, int round, float roundingPower, bool discardActive, bool allowCustomUV) { +void CHyprOpenGLImpl::renderTexture(SP tex, const CBox& box, float alpha, int round, float roundingPower, bool discardActive, bool allowCustomUV) { RASSERT(m_RenderData.pMonitor, "Tried to render texture without begin()!"); - renderTextureInternalWithDamage(tex, pBox, alpha, m_RenderData.damage, round, roundingPower, discardActive, false, allowCustomUV, true); + renderTextureInternalWithDamage(tex, box, alpha, m_RenderData.damage, round, roundingPower, discardActive, false, allowCustomUV, true); - scissor((CBox*)nullptr); + scissor(nullptr); } -void CHyprOpenGLImpl::renderTextureWithDamage(SP tex, CBox* pBox, const CRegion& damage, float alpha, int round, float roundingPower, bool discardActive, +void CHyprOpenGLImpl::renderTextureWithDamage(SP tex, const CBox& box, const CRegion& damage, float alpha, int round, float roundingPower, bool discardActive, bool allowCustomUV, SP waitTimeline, uint64_t waitPoint) { RASSERT(m_RenderData.pMonitor, "Tried to render texture without begin()!"); - renderTextureInternalWithDamage(tex, pBox, alpha, damage, round, roundingPower, discardActive, false, allowCustomUV, true, waitTimeline, waitPoint); + renderTextureInternalWithDamage(tex, box, alpha, damage, round, roundingPower, discardActive, false, allowCustomUV, true, waitTimeline, waitPoint); - scissor((CBox*)nullptr); + scissor(nullptr); } -void CHyprOpenGLImpl::renderTextureInternalWithDamage(SP tex, CBox* pBox, float alpha, const CRegion& damage, int round, float roundingPower, bool discardActive, +void CHyprOpenGLImpl::renderTextureInternalWithDamage(SP tex, const CBox& box, float alpha, const CRegion& damage, int round, float roundingPower, bool discardActive, bool noAA, bool allowCustomUV, bool allowDim, SP waitTimeline, uint64_t waitPoint) { RASSERT(m_RenderData.pMonitor, "Tried to render texture without begin()!"); RASSERT((tex->m_iTexID > 0), "Attempted to draw nullptr texture!"); @@ -1411,7 +1406,7 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(SP tex, CBox* pB if (damage.empty()) return; - CBox newBox = *pBox; + CBox newBox = box; m_RenderData.renderModif.applyToBox(newBox); static auto PDT = CConfigValue("debug:damage_tracking"); @@ -1584,7 +1579,7 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(SP tex, CBox* pB glBindTexture(tex->m_iTarget, 0); } -void CHyprOpenGLImpl::renderTexturePrimitive(SP tex, CBox* pBox) { +void CHyprOpenGLImpl::renderTexturePrimitive(SP tex, const CBox& box) { RASSERT(m_RenderData.pMonitor, "Tried to render texture without begin()!"); RASSERT((tex->m_iTexID > 0), "Attempted to draw nullptr texture!"); @@ -1593,7 +1588,7 @@ void CHyprOpenGLImpl::renderTexturePrimitive(SP tex, CBox* pBox) { if (m_RenderData.damage.empty()) return; - CBox newBox = *pBox; + CBox newBox = box; m_RenderData.renderModif.applyToBox(newBox); // get transform @@ -1627,7 +1622,7 @@ void CHyprOpenGLImpl::renderTexturePrimitive(SP tex, CBox* pBox) { glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); } - scissor((CBox*)nullptr); + scissor(nullptr); glDisableVertexAttribArray(shader->posAttrib); glDisableVertexAttribArray(shader->texAttrib); @@ -1635,7 +1630,7 @@ void CHyprOpenGLImpl::renderTexturePrimitive(SP tex, CBox* pBox) { glBindTexture(tex->m_iTarget, 0); } -void CHyprOpenGLImpl::renderTextureMatte(SP tex, CBox* pBox, CFramebuffer& matte) { +void CHyprOpenGLImpl::renderTextureMatte(SP tex, const CBox& box, CFramebuffer& matte) { RASSERT(m_RenderData.pMonitor, "Tried to render texture without begin()!"); RASSERT((tex->m_iTexID > 0), "Attempted to draw nullptr texture!"); @@ -1644,7 +1639,7 @@ void CHyprOpenGLImpl::renderTextureMatte(SP tex, CBox* pBox, CFramebuf if (m_RenderData.damage.empty()) return; - CBox newBox = *pBox; + CBox newBox = box; m_RenderData.renderModif.applyToBox(newBox); // get transform @@ -1683,7 +1678,7 @@ void CHyprOpenGLImpl::renderTextureMatte(SP tex, CBox* pBox, CFramebuf glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); } - scissor((CBox*)nullptr); + scissor(nullptr); glDisableVertexAttribArray(shader->posAttrib); glDisableVertexAttribArray(shader->texAttrib); @@ -2013,8 +2008,7 @@ void CHyprOpenGLImpl::preBlurForCurrentMonitor() { // make the fake dmg CRegion fakeDamage{0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y}; - CBox wholeMonitor = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y}; - const auto POUTFB = blurMainFramebufferWithDamage(1, &fakeDamage); + const auto POUTFB = blurMainFramebufferWithDamage(1, &fakeDamage); // render onto blurFB m_RenderData.pCurrentMonData->blurFB.alloc(m_RenderData.pMonitor->vecPixelSize.x, m_RenderData.pMonitor->vecPixelSize.y, @@ -2024,7 +2018,8 @@ void CHyprOpenGLImpl::preBlurForCurrentMonitor() { clear(CHyprColor(0, 0, 0, 0)); m_bEndFrame = true; // fix transformed - renderTextureInternalWithDamage(POUTFB->getTexture(), &wholeMonitor, 1, fakeDamage, 0, 2.0f, false, true, false); + renderTextureInternalWithDamage(POUTFB->getTexture(), CBox{0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y}, 1, fakeDamage, 0, + 2.0f, false, true, false); m_bEndFrame = false; m_RenderData.currentFB->bind(); @@ -2072,7 +2067,7 @@ bool CHyprOpenGLImpl::shouldUseNewBlurOptimizations(PHLLS pLayer, PHLWINDOW pWin return false; } -void CHyprOpenGLImpl::renderTextureWithBlur(SP tex, CBox* pBox, float a, SP pSurface, int round, float roundingPower, bool blockBlurOptimization, +void CHyprOpenGLImpl::renderTextureWithBlur(SP tex, const CBox& box, float a, SP pSurface, int round, float roundingPower, bool blockBlurOptimization, float blurA, float overallA) { RASSERT(m_RenderData.pMonitor, "Tried to render texture with blur without begin()!"); @@ -2082,7 +2077,7 @@ void CHyprOpenGLImpl::renderTextureWithBlur(SP tex, CBox* pBox, float // make a damage region for this window CRegion texDamage{m_RenderData.damage}; - texDamage.intersect(pBox->x, pBox->y, pBox->width, pBox->height); + texDamage.intersect(box.x, box.y, box.width, box.height); // While renderTextureInternalWithDamage will clip the blur as well, // clipping texDamage here allows blur generation to be optimized. @@ -2095,24 +2090,23 @@ void CHyprOpenGLImpl::renderTextureWithBlur(SP tex, CBox* pBox, float m_RenderData.renderModif.applyToRegion(texDamage); if (*PNOBLUROVERSIZED && m_RenderData.primarySurfaceUVTopLeft != Vector2D(-1, -1)) { - renderTexture(tex, pBox, a, round, roundingPower, false, true); + renderTexture(tex, box, a, round, roundingPower, false, true); return; } // amazing hack: the surface has an opaque region! CRegion inverseOpaque; - if (a >= 1.f && std::round(pSurface->current.size.x * m_RenderData.pMonitor->scale) == pBox->w && - std::round(pSurface->current.size.y * m_RenderData.pMonitor->scale) == pBox->h) { + if (a >= 1.f && std::round(pSurface->current.size.x * m_RenderData.pMonitor->scale) == box.w && std::round(pSurface->current.size.y * m_RenderData.pMonitor->scale) == box.h) { pixman_box32_t surfbox = {0, 0, pSurface->current.size.x * pSurface->current.scale, pSurface->current.size.y * pSurface->current.scale}; inverseOpaque = pSurface->current.opaque; inverseOpaque.invert(&surfbox).intersect(0, 0, pSurface->current.size.x * pSurface->current.scale, pSurface->current.size.y * pSurface->current.scale); if (inverseOpaque.empty()) { - renderTexture(tex, pBox, a, round, roundingPower, false, true); + renderTexture(tex, box, a, round, roundingPower, false, true); return; } } else { - inverseOpaque = {0, 0, pBox->width, pBox->height}; + inverseOpaque = {0, 0, box.width, box.height}; } inverseOpaque.scale(m_RenderData.pMonitor->scale); @@ -2122,7 +2116,7 @@ void CHyprOpenGLImpl::renderTextureWithBlur(SP tex, CBox* pBox, float CFramebuffer* POUTFB = nullptr; if (!USENEWOPTIMIZE) { - inverseOpaque.translate({pBox->x, pBox->y}); + inverseOpaque.translate(box.pos()); m_RenderData.renderModif.applyToRegion(inverseOpaque); inverseOpaque.intersect(texDamage); @@ -2133,7 +2127,7 @@ void CHyprOpenGLImpl::renderTextureWithBlur(SP tex, CBox* pBox, float m_RenderData.currentFB->bind(); // make a stencil for rounded corners to work with blur - scissor((CBox*)nullptr); // allow the entire window and stencil to render + scissor(nullptr); // allow the entire window and stencil to render glClearStencil(0); glClear(GL_STENCIL_BUFFER_BIT); @@ -2144,9 +2138,9 @@ void CHyprOpenGLImpl::renderTextureWithBlur(SP tex, CBox* pBox, float glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); if (USENEWOPTIMIZE && !(m_RenderData.discardMode & DISCARD_ALPHA)) - renderRect(pBox, CHyprColor(0, 0, 0, 0), round, roundingPower); + renderRect(box, CHyprColor(0, 0, 0, 0), round, roundingPower); else - renderTexture(tex, pBox, a, round, roundingPower, true, true); // discard opaque + renderTexture(tex, box, a, round, roundingPower, true, true); // discard opaque glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glStencilFunc(GL_EQUAL, 1, 0xFF); @@ -2159,14 +2153,14 @@ void CHyprOpenGLImpl::renderTextureWithBlur(SP tex, CBox* pBox, float const auto LASTTL = m_RenderData.primarySurfaceUVTopLeft; const auto LASTBR = m_RenderData.primarySurfaceUVBottomRight; - m_RenderData.primarySurfaceUVTopLeft = pBox->pos() / MONITORBOX.size(); - m_RenderData.primarySurfaceUVBottomRight = (pBox->pos() + pBox->size()) / MONITORBOX.size(); + m_RenderData.primarySurfaceUVTopLeft = box.pos() / MONITORBOX.size(); + m_RenderData.primarySurfaceUVBottomRight = (box.pos() + box.size()) / MONITORBOX.size(); static auto PBLURIGNOREOPACITY = CConfigValue("decoration:blur:ignore_opacity"); setMonitorTransformEnabled(true); if (!USENEWOPTIMIZE) setRenderModifEnabled(false); - renderTextureInternalWithDamage(POUTFB->getTexture(), pBox, (*PBLURIGNOREOPACITY ? blurA : a * blurA) * overallA, texDamage, round, roundingPower, false, false, true); + renderTextureInternalWithDamage(POUTFB->getTexture(), box, (*PBLURIGNOREOPACITY ? blurA : a * blurA) * overallA, texDamage, round, roundingPower, false, false, true); if (!USENEWOPTIMIZE) setRenderModifEnabled(true); setMonitorTransformEnabled(false); @@ -2180,15 +2174,15 @@ void CHyprOpenGLImpl::renderTextureWithBlur(SP tex, CBox* pBox, float // draw window glDisable(GL_STENCIL_TEST); - renderTextureInternalWithDamage(tex, pBox, a * overallA, texDamage, round, roundingPower, false, false, true, true); + renderTextureInternalWithDamage(tex, box, a * overallA, texDamage, round, roundingPower, false, false, true, true); glStencilMask(0xFF); glStencilFunc(GL_ALWAYS, 1, 0xFF); - scissor((CBox*)nullptr); + scissor(nullptr); } -void CHyprOpenGLImpl::renderBorder(CBox* box, const CGradientValueData& grad, int round, float roundingPower, int borderSize, float a, int outerRound) { - RASSERT((box->width > 0 && box->height > 0), "Tried to render rect with width/height < 0!"); +void CHyprOpenGLImpl::renderBorder(const CBox& box, const CGradientValueData& grad, int round, float roundingPower, int borderSize, float a, int outerRound) { + RASSERT((box.width > 0 && box.height > 0), "Tried to render rect with width/height < 0!"); RASSERT(m_RenderData.pMonitor, "Tried to render rect without begin()!"); TRACY_GPU_ZONE("RenderBorder"); @@ -2196,11 +2190,9 @@ void CHyprOpenGLImpl::renderBorder(CBox* box, const CGradientValueData& grad, in if (m_RenderData.damage.empty() || (m_RenderData.currentWindow && m_RenderData.currentWindow->m_sWindowData.noBorder.valueOrDefault())) return; - CBox newBox = *box; + CBox newBox = box; m_RenderData.renderModif.applyToBox(newBox); - box = &newBox; - if (borderSize < 1) return; @@ -2208,10 +2200,10 @@ void CHyprOpenGLImpl::renderBorder(CBox* box, const CGradientValueData& grad, in scaledBorderSize = std::round(scaledBorderSize * m_RenderData.renderModif.combinedScale()); // adjust box - box->x -= scaledBorderSize; - box->y -= scaledBorderSize; - box->width += 2 * scaledBorderSize; - box->height += 2 * scaledBorderSize; + newBox.x -= scaledBorderSize; + newBox.y -= scaledBorderSize; + newBox.width += 2 * scaledBorderSize; + newBox.height += 2 * scaledBorderSize; round += round == 0 ? 0 : scaledBorderSize; @@ -2237,7 +2229,7 @@ void CHyprOpenGLImpl::renderBorder(CBox* box, const CGradientValueData& grad, in glUniform1f(m_RenderData.pCurrentMonData->m_shBORDER1.alpha, a); glUniform1i(m_RenderData.pCurrentMonData->m_shBORDER1.gradient2Length, 0); - CBox transformedBox = *box; + CBox transformedBox = box; transformedBox.transform(wlTransformToHyprutils(invertTransform(m_RenderData.pMonitor->transform)), m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y); @@ -2246,7 +2238,7 @@ void CHyprOpenGLImpl::renderBorder(CBox* box, const CGradientValueData& grad, in glUniform2f(m_RenderData.pCurrentMonData->m_shBORDER1.topLeft, (float)TOPLEFT.x, (float)TOPLEFT.y); glUniform2f(m_RenderData.pCurrentMonData->m_shBORDER1.fullSize, (float)FULLSIZE.x, (float)FULLSIZE.y); - glUniform2f(m_RenderData.pCurrentMonData->m_shBORDER1.fullSizeUntransformed, (float)box->width, (float)box->height); + glUniform2f(m_RenderData.pCurrentMonData->m_shBORDER1.fullSizeUntransformed, (float)box.width, (float)box.height); glUniform1f(m_RenderData.pCurrentMonData->m_shBORDER1.radius, round); glUniform1f(m_RenderData.pCurrentMonData->m_shBORDER1.radiusOuter, outerRound == -1 ? round : outerRound); glUniform1f(m_RenderData.pCurrentMonData->m_shBORDER1.roundingPower, roundingPower); @@ -2281,9 +2273,9 @@ void CHyprOpenGLImpl::renderBorder(CBox* box, const CGradientValueData& grad, in blend(BLEND); } -void CHyprOpenGLImpl::renderBorder(CBox* box, const CGradientValueData& grad1, const CGradientValueData& grad2, float lerp, int round, float roundingPower, int borderSize, float a, - int outerRound) { - RASSERT((box->width > 0 && box->height > 0), "Tried to render rect with width/height < 0!"); +void CHyprOpenGLImpl::renderBorder(const CBox& box, const CGradientValueData& grad1, const CGradientValueData& grad2, float lerp, int round, float roundingPower, int borderSize, + float a, int outerRound) { + RASSERT((box.width > 0 && box.height > 0), "Tried to render rect with width/height < 0!"); RASSERT(m_RenderData.pMonitor, "Tried to render rect without begin()!"); TRACY_GPU_ZONE("RenderBorder2"); @@ -2291,11 +2283,9 @@ void CHyprOpenGLImpl::renderBorder(CBox* box, const CGradientValueData& grad1, c if (m_RenderData.damage.empty() || (m_RenderData.currentWindow && m_RenderData.currentWindow->m_sWindowData.noBorder.valueOrDefault())) return; - CBox newBox = *box; + CBox newBox = box; m_RenderData.renderModif.applyToBox(newBox); - box = &newBox; - if (borderSize < 1) return; @@ -2303,10 +2293,10 @@ void CHyprOpenGLImpl::renderBorder(CBox* box, const CGradientValueData& grad1, c scaledBorderSize = std::round(scaledBorderSize * m_RenderData.renderModif.combinedScale()); // adjust box - box->x -= scaledBorderSize; - box->y -= scaledBorderSize; - box->width += 2 * scaledBorderSize; - box->height += 2 * scaledBorderSize; + newBox.x -= scaledBorderSize; + newBox.y -= scaledBorderSize; + newBox.width += 2 * scaledBorderSize; + newBox.height += 2 * scaledBorderSize; round += round == 0 ? 0 : scaledBorderSize; @@ -2336,7 +2326,7 @@ void CHyprOpenGLImpl::renderBorder(CBox* box, const CGradientValueData& grad1, c glUniform1f(m_RenderData.pCurrentMonData->m_shBORDER1.alpha, a); glUniform1f(m_RenderData.pCurrentMonData->m_shBORDER1.gradientLerp, lerp); - CBox transformedBox = *box; + CBox transformedBox = box; transformedBox.transform(wlTransformToHyprutils(invertTransform(m_RenderData.pMonitor->transform)), m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y); @@ -2345,7 +2335,7 @@ void CHyprOpenGLImpl::renderBorder(CBox* box, const CGradientValueData& grad1, c glUniform2f(m_RenderData.pCurrentMonData->m_shBORDER1.topLeft, (float)TOPLEFT.x, (float)TOPLEFT.y); glUniform2f(m_RenderData.pCurrentMonData->m_shBORDER1.fullSize, (float)FULLSIZE.x, (float)FULLSIZE.y); - glUniform2f(m_RenderData.pCurrentMonData->m_shBORDER1.fullSizeUntransformed, (float)box->width, (float)box->height); + glUniform2f(m_RenderData.pCurrentMonData->m_shBORDER1.fullSizeUntransformed, (float)box.width, (float)box.height); glUniform1f(m_RenderData.pCurrentMonData->m_shBORDER1.radius, round); glUniform1f(m_RenderData.pCurrentMonData->m_shBORDER1.radiusOuter, outerRound == -1 ? round : outerRound); glUniform1f(m_RenderData.pCurrentMonData->m_shBORDER1.roundingPower, roundingPower); @@ -2380,9 +2370,9 @@ void CHyprOpenGLImpl::renderBorder(CBox* box, const CGradientValueData& grad1, c blend(BLEND); } -void CHyprOpenGLImpl::renderRoundedShadow(CBox* box, int round, float roundingPower, int range, const CHyprColor& color, float a) { +void CHyprOpenGLImpl::renderRoundedShadow(const CBox& box, int round, float roundingPower, int range, const CHyprColor& color, float a) { RASSERT(m_RenderData.pMonitor, "Tried to render shadow without begin()!"); - RASSERT((box->width > 0 && box->height > 0), "Tried to render shadow with width/height < 0!"); + RASSERT((box.width > 0 && box.height > 0), "Tried to render shadow with width/height < 0!"); RASSERT(m_RenderData.currentWindow, "Tried to render shadow without a window!"); if (m_RenderData.damage.empty()) @@ -2390,11 +2380,9 @@ void CHyprOpenGLImpl::renderRoundedShadow(CBox* box, int round, float roundingPo TRACY_GPU_ZONE("RenderShadow"); - CBox newBox = *box; + CBox newBox = box; m_RenderData.renderModif.applyToBox(newBox); - box = &newBox; - static auto PSHADOWPOWER = CConfigValue("decoration:shadow:render_power"); const auto SHADOWPOWER = std::clamp((int)*PSHADOWPOWER, 1, 4); @@ -2418,8 +2406,8 @@ void CHyprOpenGLImpl::renderRoundedShadow(CBox* box, int round, float roundingPo glUniform4f(m_RenderData.pCurrentMonData->m_shSHADOW.color, col.r, col.g, col.b, col.a * a); const auto TOPLEFT = Vector2D(range + round, range + round); - const auto BOTTOMRIGHT = Vector2D(box->width - (range + round), box->height - (range + round)); - const auto FULLSIZE = Vector2D(box->width, box->height); + const auto BOTTOMRIGHT = Vector2D(newBox.width - (range + round), newBox.height - (range + round)); + const auto FULLSIZE = Vector2D(newBox.width, newBox.height); // Rounded corners glUniform2f(m_RenderData.pCurrentMonData->m_shSHADOW.topLeft, (float)TOPLEFT.x, (float)TOPLEFT.y); @@ -2457,7 +2445,7 @@ void CHyprOpenGLImpl::renderRoundedShadow(CBox* box, int round, float roundingPo glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shSHADOW.texAttrib); } -void CHyprOpenGLImpl::saveBufferForMirror(CBox* box) { +void CHyprOpenGLImpl::saveBufferForMirror(const CBox& box) { if (!m_RenderData.pCurrentMonData->monitorMirrorFB.isAllocated()) m_RenderData.pCurrentMonData->monitorMirrorFB.alloc(m_RenderData.pMonitor->vecPixelSize.x, m_RenderData.pMonitor->vecPixelSize.y, @@ -2850,11 +2838,11 @@ void CHyprOpenGLImpl::createBGTextureForMonitor(PHLMONITOR pMonitor) { } CBox texbox = CBox{origin, m_pBackgroundTexture->m_vSize * scale}; - renderTextureInternalWithDamage(m_pBackgroundTexture, &texbox, 1.0, fakeDamage); + renderTextureInternalWithDamage(m_pBackgroundTexture, texbox, 1.0, fakeDamage); } CBox monbox = {{}, pMonitor->vecPixelSize}; - renderTextureInternalWithDamage(tex, &monbox, 1.0, fakeDamage); + renderTextureInternalWithDamage(tex, monbox, 1.0, fakeDamage); // bind back if (m_RenderData.currentFB) @@ -2936,7 +2924,7 @@ void CHyprOpenGLImpl::bindOffMain() { void CHyprOpenGLImpl::renderOffToMain(CFramebuffer* off) { CBox monbox = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y}; - renderTexturePrimitive(off->getTexture(), &monbox); + renderTexturePrimitive(off->getTexture(), monbox); } void CHyprOpenGLImpl::bindBackOnMain() { diff --git a/src/render/OpenGL.hpp b/src/render/OpenGL.hpp index fd84d478..1ebb0162 100644 --- a/src/render/OpenGL.hpp +++ b/src/render/OpenGL.hpp @@ -166,86 +166,86 @@ class CHyprOpenGLImpl { CHyprOpenGLImpl(); ~CHyprOpenGLImpl(); - void begin(PHLMONITOR, const CRegion& damage, CFramebuffer* fb = nullptr, std::optional finalDamage = {}); - void beginSimple(PHLMONITOR, const CRegion& damage, SP rb = nullptr, CFramebuffer* fb = nullptr); - void end(); + void begin(PHLMONITOR, const CRegion& damage, CFramebuffer* fb = nullptr, std::optional finalDamage = {}); + void beginSimple(PHLMONITOR, const CRegion& damage, SP rb = nullptr, CFramebuffer* fb = nullptr); + void end(); - void renderRect(CBox*, const CHyprColor&, int round = 0, float roundingPower = 2.0f); - void renderRectWithBlur(CBox*, const CHyprColor&, int round = 0, float roundingPower = 2.0f, float blurA = 1.f, bool xray = false); - void renderRectWithDamage(CBox*, const CHyprColor&, const CRegion& damage, int round = 0, float roundingPower = 2.0f); - void renderTexture(SP, CBox*, float a, int round = 0, float roundingPower = 2.0f, bool discardActive = false, bool allowCustomUV = false); - void renderTextureWithDamage(SP, CBox*, const CRegion& damage, float a, int round = 0, float roundingPower = 2.0f, bool discardActive = false, - bool allowCustomUV = false, SP waitTimeline = nullptr, uint64_t waitPoint = 0); - void renderTextureWithBlur(SP, CBox*, float a, SP pSurface, int round = 0, float roundingPower = 2.0f, bool blockBlurOptimization = false, - float blurA = 1.f, float overallA = 1.f); - void renderRoundedShadow(CBox*, int round, float roundingPower, int range, const CHyprColor& color, float a = 1.0); - void renderBorder(CBox*, const CGradientValueData&, int round, float roundingPower, int borderSize, float a = 1.0, int outerRound = -1 /* use round */); - void renderBorder(CBox*, const CGradientValueData&, const CGradientValueData&, float lerp, int round, float roundingPower, int borderSize, float a = 1.0, - int outerRound = -1 /* use round */); - void renderTextureMatte(SP tex, CBox* pBox, CFramebuffer& matte); + void renderRect(const CBox&, const CHyprColor&, int round = 0, float roundingPower = 2.0f); + void renderRectWithBlur(const CBox&, const CHyprColor&, int round = 0, float roundingPower = 2.0f, float blurA = 1.f, bool xray = false); + void renderRectWithDamage(const CBox&, const CHyprColor&, const CRegion& damage, int round = 0, float roundingPower = 2.0f); + void renderTexture(SP, const CBox&, float a, int round = 0, float roundingPower = 2.0f, bool discardActive = false, bool allowCustomUV = false); + void renderTextureWithDamage(SP, const CBox&, const CRegion& damage, float a, int round = 0, float roundingPower = 2.0f, bool discardActive = false, + bool allowCustomUV = false, SP waitTimeline = nullptr, uint64_t waitPoint = 0); + void renderTextureWithBlur(SP, const CBox&, float a, SP pSurface, int round = 0, float roundingPower = 2.0f, bool blockBlurOptimization = false, + float blurA = 1.f, float overallA = 1.f); + void renderRoundedShadow(const CBox&, int round, float roundingPower, int range, const CHyprColor& color, float a = 1.0); + void renderBorder(const CBox&, const CGradientValueData&, int round, float roundingPower, int borderSize, float a = 1.0, int outerRound = -1 /* use round */); + void renderBorder(const CBox&, const CGradientValueData&, const CGradientValueData&, float lerp, int round, float roundingPower, int borderSize, float a = 1.0, + int outerRound = -1 /* use round */); + void renderTextureMatte(SP tex, const CBox& pBox, CFramebuffer& matte); - void setMonitorTransformEnabled(bool enabled); - void setRenderModifEnabled(bool enabled); + void setMonitorTransformEnabled(bool enabled); + void setRenderModifEnabled(bool enabled); - void saveMatrix(); - void setMatrixScaleTranslate(const Vector2D& translate, const float& scale); - void restoreMatrix(); + void saveMatrix(); + void setMatrixScaleTranslate(const Vector2D& translate, const float& scale); + void restoreMatrix(); - void blend(bool enabled); + void blend(bool enabled); - bool shouldUseNewBlurOptimizations(PHLLS pLayer, PHLWINDOW pWindow); + bool shouldUseNewBlurOptimizations(PHLLS pLayer, PHLWINDOW pWindow); - void clear(const CHyprColor&); - void clearWithTex(); - void scissor(const CBox*, bool transform = true); - void scissor(const pixman_box32*, bool transform = true); - void scissor(const int x, const int y, const int w, const int h, bool transform = true); + void clear(const CHyprColor&); + void clearWithTex(); + void scissor(const CBox&, bool transform = true); + void scissor(const pixman_box32*, bool transform = true); + void scissor(const int x, const int y, const int w, const int h, bool transform = true); - void destroyMonitorResources(PHLMONITOR); + void destroyMonitorResources(PHLMONITOR); - void markBlurDirtyForMonitor(PHLMONITOR); + void markBlurDirtyForMonitor(PHLMONITOR); - void preWindowPass(); - bool preBlurQueued(); - void preRender(PHLMONITOR); + void preWindowPass(); + bool preBlurQueued(); + void preRender(PHLMONITOR); - void saveBufferForMirror(CBox*); - void renderMirrored(); + void saveBufferForMirror(const CBox&); + void renderMirrored(); - void applyScreenShader(const std::string& path); + void applyScreenShader(const std::string& path); - void bindOffMain(); - void renderOffToMain(CFramebuffer* off); - void bindBackOnMain(); + void bindOffMain(); + void renderOffToMain(CFramebuffer* off); + void bindBackOnMain(); - SP loadAsset(const std::string& file); - SP renderText(const std::string& text, CHyprColor col, int pt, bool italic = false, const std::string& fontFamily = "", int maxWidth = 0); + SP loadAsset(const std::string& file); + SP renderText(const std::string& text, CHyprColor col, int pt, bool italic = false, const std::string& fontFamily = "", int maxWidth = 0); - void setDamage(const CRegion& damage, std::optional finalDamage = {}); + void setDamage(const CRegion& damage, std::optional finalDamage = {}); - void ensureBackgroundTexturePresence(); + void ensureBackgroundTexturePresence(); - uint32_t getPreferredReadFormat(PHLMONITOR pMonitor); - std::vector getDRMFormats(); - EGLImageKHR createEGLImage(const Aquamarine::SDMABUFAttrs& attrs); - SP createEGLSync(int fenceFD); - bool waitForTimelinePoint(SP timeline, uint64_t point); + uint32_t getPreferredReadFormat(PHLMONITOR pMonitor); + std::vector getDRMFormats(); + EGLImageKHR createEGLImage(const Aquamarine::SDMABUFAttrs& attrs); + SP createEGLSync(int fenceFD); + bool waitForTimelinePoint(SP timeline, uint64_t point); - SCurrentRenderData m_RenderData; + SCurrentRenderData m_RenderData; - GLint m_iCurrentOutputFb = 0; + GLint m_iCurrentOutputFb = 0; - int m_iGBMFD = -1; - gbm_device* m_pGbmDevice = nullptr; - EGLContext m_pEglContext = nullptr; - EGLDisplay m_pEglDisplay = nullptr; - EGLDeviceEXT m_pEglDevice = nullptr; - uint failedAssetsNo = 0; + int m_iGBMFD = -1; + gbm_device* m_pGbmDevice = nullptr; + EGLContext m_pEglContext = nullptr; + EGLDisplay m_pEglDisplay = nullptr; + EGLDeviceEXT m_pEglDevice = nullptr; + uint failedAssetsNo = 0; - bool m_bReloadScreenShader = true; // at launch it can be set + bool m_bReloadScreenShader = true; // at launch it can be set - std::map m_mWindowFramebuffers; - std::map m_mLayerFramebuffers; + std::map m_mWindowFramebuffers; + std::map m_mLayerFramebuffers; std::map m_mMonitorRenderResources; std::map m_mMonitorBGFBs; @@ -314,14 +314,14 @@ class CHyprOpenGLImpl { // returns the out FB, can be either Mirror or MirrorSwap CFramebuffer* blurMainFramebufferWithDamage(float a, CRegion* damage); - void renderTextureInternalWithDamage(SP, CBox* pBox, float a, const CRegion& damage, int round = 0, float roundingPower = 2.0f, bool discardOpaque = false, - bool noAA = false, bool allowCustomUV = false, bool allowDim = false, SP = nullptr, uint64_t waitPoint = 0); - void renderTexturePrimitive(SP tex, CBox* pBox); - void renderSplash(cairo_t* const, cairo_surface_t* const, double offset, const Vector2D& size); + void renderTextureInternalWithDamage(SP, const CBox& box, float a, const CRegion& damage, int round = 0, float roundingPower = 2.0f, bool discardOpaque = false, + bool noAA = false, bool allowCustomUV = false, bool allowDim = false, SP = nullptr, uint64_t waitPoint = 0); + void renderTexturePrimitive(SP tex, const CBox& box); + void renderSplash(cairo_t* const, cairo_surface_t* const, double offset, const Vector2D& size); - void preBlurForCurrentMonitor(); + void preBlurForCurrentMonitor(); - bool passRequiresIntrospection(PHLMONITOR pMonitor); + bool passRequiresIntrospection(PHLMONITOR pMonitor); friend class CHyprRenderer; friend class CTexPassElement; diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index f897379a..41ab0b37 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -978,15 +978,15 @@ void CHyprRenderer::renderSessionLockMissing(PHLMONITOR pMonitor) { if (ANY_PRESENT) { // render image2, without instructions. Lock still "alive", unless texture dead - g_pHyprOpenGL->renderTexture(g_pHyprOpenGL->m_pLockDead2Texture, &monbox, ALPHA); + g_pHyprOpenGL->renderTexture(g_pHyprOpenGL->m_pLockDead2Texture, monbox, ALPHA); } else { // render image, with instructions. Lock is gone. - g_pHyprOpenGL->renderTexture(g_pHyprOpenGL->m_pLockDeadTexture, &monbox, ALPHA); + g_pHyprOpenGL->renderTexture(g_pHyprOpenGL->m_pLockDeadTexture, monbox, ALPHA); // also render text for the tty number if (g_pHyprOpenGL->m_pLockTtyTextTexture) { CBox texbox = {{}, g_pHyprOpenGL->m_pLockTtyTextTexture->m_vSize}; - g_pHyprOpenGL->renderTexture(g_pHyprOpenGL->m_pLockTtyTextTexture, &texbox, 1.F); + g_pHyprOpenGL->renderTexture(g_pHyprOpenGL->m_pLockTtyTextTexture, texbox, 1.F); } } @@ -1836,7 +1836,7 @@ void CHyprRenderer::damageSurface(SP pSurface, double x, dou damageBoxForEach.set(damageBox); damageBoxForEach.translate({-m->vecPosition.x, -m->vecPosition.y}).scale(m->scale); - m->addDamage(&damageBoxForEach); + m->addDamage(damageBoxForEach); } static auto PLOGDAMAGE = CConfigValue("debug:log_damage"); @@ -1860,7 +1860,7 @@ void CHyprRenderer::damageWindow(PHLWINDOW pWindow, bool forceFull) { if (forceFull || shouldRenderWindow(pWindow, m)) { // only damage if window is rendered on monitor CBox fixedDamageBox = {windowBox.x - m->vecPosition.x, windowBox.y - m->vecPosition.y, windowBox.width, windowBox.height}; fixedDamageBox.scale(m->scale); - m->addDamage(&fixedDamageBox); + m->addDamage(fixedDamageBox); } } @@ -1878,7 +1878,7 @@ void CHyprRenderer::damageMonitor(PHLMONITOR pMonitor) { return; CBox damageBox = {0, 0, INT16_MAX, INT16_MAX}; - pMonitor->addDamage(&damageBox); + pMonitor->addDamage(damageBox); static auto PLOGDAMAGE = CConfigValue("debug:log_damage"); @@ -1886,7 +1886,7 @@ void CHyprRenderer::damageMonitor(PHLMONITOR pMonitor) { Debug::log(LOG, "Damage: Monitor {}", pMonitor->szName); } -void CHyprRenderer::damageBox(CBox* pBox, bool skipFrameSchedule) { +void CHyprRenderer::damageBox(const CBox& box, bool skipFrameSchedule) { if (g_pCompositor->m_bUnsafeState) return; @@ -1895,21 +1895,20 @@ void CHyprRenderer::damageBox(CBox* pBox, bool skipFrameSchedule) { continue; // don't damage mirrors traditionally if (!skipFrameSchedule) { - CBox damageBox = {pBox->x - m->vecPosition.x, pBox->y - m->vecPosition.y, pBox->width, pBox->height}; - damageBox.scale(m->scale); - m->addDamage(&damageBox); + CBox damageBox = box.copy().translate(-m->vecPosition).scale(m->scale); + m->addDamage(damageBox); } } static auto PLOGDAMAGE = CConfigValue("debug:log_damage"); if (*PLOGDAMAGE) - Debug::log(LOG, "Damage: Box: xy: {}, {} wh: {}, {}", pBox->x, pBox->y, pBox->width, pBox->height); + Debug::log(LOG, "Damage: Box: xy: {}, {} wh: {}, {}", box.x, box.y, box.w, box.h); } void CHyprRenderer::damageBox(const int& x, const int& y, const int& w, const int& h) { CBox box = {x, y, w, h}; - damageBox(&box); + damageBox(box); } void CHyprRenderer::damageRegion(const CRegion& rg) { @@ -1936,7 +1935,7 @@ void CHyprRenderer::damageMirrorsWith(PHLMONITOR pMonitor, const CRegion& pRegio transformed.transform(wlTransformToHyprutils(pMonitor->transform), pMonitor->vecPixelSize.x * scale, pMonitor->vecPixelSize.y * scale); transformed.translate(Vector2D(monbox.x, monbox.y)); - mirror->addDamage(&transformed); + mirror->addDamage(transformed); g_pCompositor->scheduleFrameForMonitor(mirror.lock(), Aquamarine::IOutput::AQ_SCHEDULE_DAMAGE); } diff --git a/src/render/Renderer.hpp b/src/render/Renderer.hpp index 30fba3ca..e64d41c1 100644 --- a/src/render/Renderer.hpp +++ b/src/render/Renderer.hpp @@ -53,7 +53,7 @@ class CHyprRenderer { void arrangeLayersForMonitor(const MONITORID&); void damageSurface(SP, double, double, double scale = 1.0); void damageWindow(PHLWINDOW, bool forceFull = false); - void damageBox(CBox*, bool skipFrameSchedule = false); + void damageBox(const CBox&, bool skipFrameSchedule = false); void damageBox(const int& x, const int& y, const int& w, const int& h); void damageRegion(const CRegion&); void damageMonitor(PHLMONITOR); diff --git a/src/render/decorations/CHyprDropShadowDecoration.cpp b/src/render/decorations/CHyprDropShadowDecoration.cpp index c576b966..8a934086 100644 --- a/src/render/decorations/CHyprDropShadowDecoration.cpp +++ b/src/render/decorations/CHyprDropShadowDecoration.cpp @@ -149,7 +149,7 @@ void CHyprDropShadowDecoration::render(PHLMONITOR pMonitor, float const& a) { if (fullBox.width < 1 || fullBox.height < 1) return; // don't draw invisible shadows - g_pHyprOpenGL->scissor((CBox*)nullptr); + g_pHyprOpenGL->scissor(nullptr); g_pHyprOpenGL->m_RenderData.currentWindow = m_pWindow; // we'll take the liberty of using this as it should not be used rn @@ -191,18 +191,18 @@ void CHyprDropShadowDecoration::render(PHLMONITOR pMonitor, float const& a) { // build the matte // 10-bit formats have dogshit alpha channels, so we have to use the matte to its fullest. // first, clear region of interest with black (fully transparent) - g_pHyprOpenGL->renderRect(&fullBox, CHyprColor(0, 0, 0, 1), 0); + g_pHyprOpenGL->renderRect(fullBox, CHyprColor(0, 0, 0, 1), 0); // render white shadow with the alpha of the shadow color (otherwise we clear with alpha later and shit it to 2 bit) - drawShadowInternal(&fullBox, ROUNDING * pMonitor->scale, ROUNDINGPOWER, *PSHADOWSIZE * pMonitor->scale, CHyprColor(1, 1, 1, PWINDOW->m_cRealShadowColor->value().a), a); + drawShadowInternal(fullBox, ROUNDING * pMonitor->scale, ROUNDINGPOWER, *PSHADOWSIZE * pMonitor->scale, CHyprColor(1, 1, 1, PWINDOW->m_cRealShadowColor->value().a), a); // render black window box ("clip") - g_pHyprOpenGL->renderRect(&windowBox, CHyprColor(0, 0, 0, 1.0), (ROUNDING + 1 /* This fixes small pixel gaps. */) * pMonitor->scale, ROUNDINGPOWER); + g_pHyprOpenGL->renderRect(windowBox, CHyprColor(0, 0, 0, 1.0), (ROUNDING + 1 /* This fixes small pixel gaps. */) * pMonitor->scale, ROUNDINGPOWER); alphaSwapFB.bind(); // alpha swap just has the shadow color. It will be the "texture" to render. - g_pHyprOpenGL->renderRect(&fullBox, PWINDOW->m_cRealShadowColor->value().stripA(), 0); + g_pHyprOpenGL->renderRect(fullBox, PWINDOW->m_cRealShadowColor->value().stripA(), 0); LASTFB->bind(); @@ -210,13 +210,13 @@ void CHyprDropShadowDecoration::render(PHLMONITOR pMonitor, float const& a) { g_pHyprOpenGL->setMonitorTransformEnabled(true); g_pHyprOpenGL->setRenderModifEnabled(false); - g_pHyprOpenGL->renderTextureMatte(alphaSwapFB.getTexture(), &monbox, alphaFB); + g_pHyprOpenGL->renderTextureMatte(alphaSwapFB.getTexture(), monbox, alphaFB); g_pHyprOpenGL->setRenderModifEnabled(true); g_pHyprOpenGL->setMonitorTransformEnabled(false); g_pHyprOpenGL->m_RenderData.damage = saveDamage; } else - drawShadowInternal(&fullBox, ROUNDING * pMonitor->scale, ROUNDINGPOWER, *PSHADOWSIZE * pMonitor->scale, PWINDOW->m_cRealShadowColor->value(), a); + drawShadowInternal(fullBox, ROUNDING * pMonitor->scale, ROUNDINGPOWER, *PSHADOWSIZE * pMonitor->scale, PWINDOW->m_cRealShadowColor->value(), a); if (m_seExtents != m_seReportedExtents) g_pDecorationPositioner->repositionDeco(this); @@ -228,7 +228,7 @@ eDecorationLayer CHyprDropShadowDecoration::getDecorationLayer() { return DECORATION_LAYER_BOTTOM; } -void CHyprDropShadowDecoration::drawShadowInternal(CBox* box, int round, float roundingPower, int range, CHyprColor color, float a) { +void CHyprDropShadowDecoration::drawShadowInternal(const CBox& box, int round, float roundingPower, int range, CHyprColor color, float a) { static auto PSHADOWSHARP = CConfigValue("decoration:shadow:sharp"); g_pHyprOpenGL->blend(true); diff --git a/src/render/decorations/CHyprDropShadowDecoration.hpp b/src/render/decorations/CHyprDropShadowDecoration.hpp index 93fa3d1a..3b1c67c5 100644 --- a/src/render/decorations/CHyprDropShadowDecoration.hpp +++ b/src/render/decorations/CHyprDropShadowDecoration.hpp @@ -36,7 +36,7 @@ class CHyprDropShadowDecoration : public IHyprWindowDecoration { Vector2D m_vLastWindowPos; Vector2D m_vLastWindowSize; - void drawShadowInternal(CBox* box, int round, float roundingPower, int range, CHyprColor color, float a); + void drawShadowInternal(const CBox& box, int round, float roundingPower, int range, CHyprColor color, float a); CBox m_bLastWindowBox = {0}; CBox m_bLastWindowBoxWithDecos = {0}; diff --git a/src/render/decorations/CHyprGroupBarDecoration.cpp b/src/render/decorations/CHyprGroupBarDecoration.cpp index 7cef21b8..4e7c3cbc 100644 --- a/src/render/decorations/CHyprGroupBarDecoration.cpp +++ b/src/render/decorations/CHyprGroupBarDecoration.cpp @@ -94,7 +94,7 @@ void CHyprGroupBarDecoration::updateWindow(PHLWINDOW pWindow) { void CHyprGroupBarDecoration::damageEntire() { auto box = assignedBoxGlobal(); box.translate(m_pWindow->m_vFloatingOffset); - g_pHyprRenderer->damageBox(&box); + g_pHyprRenderer->damageBox(box); } void CHyprGroupBarDecoration::draw(PHLMONITOR pMonitor, float const& a) { diff --git a/src/render/pass/BorderPassElement.cpp b/src/render/pass/BorderPassElement.cpp index ceeec6f3..31042c28 100644 --- a/src/render/pass/BorderPassElement.cpp +++ b/src/render/pass/BorderPassElement.cpp @@ -7,9 +7,9 @@ CBorderPassElement::CBorderPassElement(const CBorderPassElement::SBorderData& da void CBorderPassElement::draw(const CRegion& damage) { if (data.hasGrad2) - g_pHyprOpenGL->renderBorder(&data.box, data.grad1, data.grad2, data.lerp, data.round, data.roundingPower, data.borderSize, data.a, data.outerRound); + g_pHyprOpenGL->renderBorder(data.box, data.grad1, data.grad2, data.lerp, data.round, data.roundingPower, data.borderSize, data.a, data.outerRound); else - g_pHyprOpenGL->renderBorder(&data.box, data.grad1, data.round, data.roundingPower, data.borderSize, data.a, data.outerRound); + g_pHyprOpenGL->renderBorder(data.box, data.grad1, data.round, data.roundingPower, data.borderSize, data.a, data.outerRound); } bool CBorderPassElement::needsLiveBlur() { diff --git a/src/render/pass/Pass.cpp b/src/render/pass/Pass.cpp index 5b133b7d..81b918ac 100644 --- a/src/render/pass/Pass.cpp +++ b/src/render/pass/Pass.cpp @@ -202,9 +202,9 @@ CRegion CRenderPass::render(const CRegion& damage_) { void CRenderPass::renderDebugData() { CBox box = {{}, g_pHyprOpenGL->m_RenderData.pMonitor->vecTransformedSize}; for (const auto& rg : occludedRegions) { - g_pHyprOpenGL->renderRectWithDamage(&box, Colors::RED.modifyA(0.1F), rg); + g_pHyprOpenGL->renderRectWithDamage(box, Colors::RED.modifyA(0.1F), rg); } - g_pHyprOpenGL->renderRectWithDamage(&box, Colors::GREEN.modifyA(0.1F), totalLiveBlurRegion); + g_pHyprOpenGL->renderRectWithDamage(box, Colors::GREEN.modifyA(0.1F), totalLiveBlurRegion); std::unordered_map offsets; @@ -227,7 +227,7 @@ void CRenderPass::renderDebugData() { if (box.intersection(CBox{{}, g_pHyprOpenGL->m_RenderData.pMonitor->vecSize}).empty()) return; - g_pHyprOpenGL->renderRectWithDamage(&box, color, CRegion{0, 0, INT32_MAX, INT32_MAX}); + g_pHyprOpenGL->renderRectWithDamage(box, color, CRegion{0, 0, INT32_MAX, INT32_MAX}); if (offsets.contains(surface.get())) box.translate(Vector2D{0.F, offsets[surface.get()]}); @@ -235,8 +235,8 @@ void CRenderPass::renderDebugData() { offsets[surface.get()] = 0; box = {box.pos(), texture->m_vSize}; - g_pHyprOpenGL->renderRectWithDamage(&box, CHyprColor{0.F, 0.F, 0.F, 0.2F}, CRegion{0, 0, INT32_MAX, INT32_MAX}, std::min(5.0, box.size().y)); - g_pHyprOpenGL->renderTexture(texture, &box, 1.F); + g_pHyprOpenGL->renderRectWithDamage(box, CHyprColor{0.F, 0.F, 0.F, 0.2F}, CRegion{0, 0, INT32_MAX, INT32_MAX}, std::min(5.0, box.size().y)); + g_pHyprOpenGL->renderTexture(texture, box, 1.F); offsets[surface.get()] += texture->m_vSize.y; }; @@ -253,7 +253,7 @@ void CRenderPass::renderDebugData() { if (tex) { box = CBox{{0.F, g_pHyprOpenGL->m_RenderData.pMonitor->vecSize.y - tex->m_vSize.y}, tex->m_vSize}.scale(g_pHyprOpenGL->m_RenderData.pMonitor->scale); - g_pHyprOpenGL->renderTexture(tex, &box, 1.F); + g_pHyprOpenGL->renderTexture(tex, box, 1.F); } std::string passStructure; @@ -271,7 +271,7 @@ void CRenderPass::renderDebugData() { if (tex) { box = CBox{{g_pHyprOpenGL->m_RenderData.pMonitor->vecSize.x - tex->m_vSize.x, g_pHyprOpenGL->m_RenderData.pMonitor->vecSize.y - tex->m_vSize.y}, tex->m_vSize}.scale( g_pHyprOpenGL->m_RenderData.pMonitor->scale); - g_pHyprOpenGL->renderTexture(tex, &box, 1.F); + g_pHyprOpenGL->renderTexture(tex, box, 1.F); } } diff --git a/src/render/pass/RectPassElement.cpp b/src/render/pass/RectPassElement.cpp index 55471e78..a9ab737d 100644 --- a/src/render/pass/RectPassElement.cpp +++ b/src/render/pass/RectPassElement.cpp @@ -10,9 +10,9 @@ void CRectPassElement::draw(const CRegion& damage) { return; if (data.color.a == 1.F || !data.blur) - g_pHyprOpenGL->renderRectWithDamage(&data.box, data.color, damage, data.round, data.roundingPower); + g_pHyprOpenGL->renderRectWithDamage(data.box, data.color, damage, data.round, data.roundingPower); else - g_pHyprOpenGL->renderRectWithBlur(&data.box, data.color, data.round, data.roundingPower, data.blurA, data.xray); + g_pHyprOpenGL->renderRectWithBlur(data.box, data.color, data.round, data.roundingPower, data.blurA, data.xray); } bool CRectPassElement::needsLiveBlur() { diff --git a/src/render/pass/SurfacePassElement.cpp b/src/render/pass/SurfacePassElement.cpp index b79407c8..a5d3d7c0 100644 --- a/src/render/pass/SurfacePassElement.cpp +++ b/src/render/pass/SurfacePassElement.cpp @@ -122,14 +122,14 @@ void CSurfacePassElement::draw(const CRegion& damage) { // to what we do for misaligned surfaces (blur the entire thing and then render shit without blur) if (data.surfaceCounter == 0 && !data.popup) { if (BLUR) - g_pHyprOpenGL->renderTextureWithBlur(TEXTURE, &windowBox, ALPHA, data.surface, rounding, roundingPower, data.blockBlurOptimization, data.fadeAlpha, OVERALL_ALPHA); + g_pHyprOpenGL->renderTextureWithBlur(TEXTURE, windowBox, ALPHA, data.surface, rounding, roundingPower, data.blockBlurOptimization, data.fadeAlpha, OVERALL_ALPHA); else - g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, ALPHA * OVERALL_ALPHA, rounding, roundingPower, false, true); + g_pHyprOpenGL->renderTexture(TEXTURE, windowBox, ALPHA * OVERALL_ALPHA, rounding, roundingPower, false, true); } else { if (BLUR && data.popup) - g_pHyprOpenGL->renderTextureWithBlur(TEXTURE, &windowBox, ALPHA, data.surface, rounding, roundingPower, true, data.fadeAlpha, OVERALL_ALPHA); + g_pHyprOpenGL->renderTextureWithBlur(TEXTURE, windowBox, ALPHA, data.surface, rounding, roundingPower, true, data.fadeAlpha, OVERALL_ALPHA); else - g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, ALPHA * OVERALL_ALPHA, rounding, roundingPower, false, true); + g_pHyprOpenGL->renderTexture(TEXTURE, windowBox, ALPHA * OVERALL_ALPHA, rounding, roundingPower, false, true); } if (!g_pHyprRenderer->m_bBlockSurfaceFeedback) diff --git a/src/render/pass/TexPassElement.cpp b/src/render/pass/TexPassElement.cpp index 0624a786..c7eab292 100644 --- a/src/render/pass/TexPassElement.cpp +++ b/src/render/pass/TexPassElement.cpp @@ -18,7 +18,7 @@ void CTexPassElement::draw(const CRegion& damage) { if (data.replaceProjection) g_pHyprOpenGL->m_RenderData.monitorProjection = *data.replaceProjection; - g_pHyprOpenGL->renderTextureInternalWithDamage(data.tex, &data.box, data.a, data.damage.empty() ? damage : data.damage, data.round, data.roundingPower, data.syncTimeline, + g_pHyprOpenGL->renderTextureInternalWithDamage(data.tex, data.box, data.a, data.damage.empty() ? damage : data.damage, data.round, data.roundingPower, data.syncTimeline, data.syncPoint); if (data.replaceProjection) g_pHyprOpenGL->m_RenderData.monitorProjection = g_pHyprOpenGL->m_RenderData.pMonitor->projMatrix; diff --git a/src/render/pass/TextureMatteElement.cpp b/src/render/pass/TextureMatteElement.cpp index 5aed1c9a..3d927357 100644 --- a/src/render/pass/TextureMatteElement.cpp +++ b/src/render/pass/TextureMatteElement.cpp @@ -9,11 +9,11 @@ void CTextureMatteElement::draw(const CRegion& damage) { if (data.disableTransformAndModify) { g_pHyprOpenGL->setMonitorTransformEnabled(true); g_pHyprOpenGL->setRenderModifEnabled(false); - g_pHyprOpenGL->renderTextureMatte(data.tex, &data.box, *data.fb); + g_pHyprOpenGL->renderTextureMatte(data.tex, data.box, *data.fb); g_pHyprOpenGL->setRenderModifEnabled(true); g_pHyprOpenGL->setMonitorTransformEnabled(false); } else - g_pHyprOpenGL->renderTextureMatte(data.tex, &data.box, *data.fb); + g_pHyprOpenGL->renderTextureMatte(data.tex, data.box, *data.fb); } bool CTextureMatteElement::needsLiveBlur() {