diff options
| author | Tom Englund <tomenglund26@gmail.com> | 2025-09-27 02:50:40 +0200 |
|---|---|---|
| committer | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2025-09-28 23:20:52 +0200 |
| commit | b627885788acbab4c768632f800e010467ffbaf9 (patch) | |
| tree | 324a95da529af3e28efaa9f2ef95df353b66296f /src/render | |
| parent | c30036bdacbe5e87b49d6de6df652d56681ef457 (diff) | |
decoration: reduce virtual calls
this shows up as top contender in idle cpu usage, because decos in
animations keeps locking weak pointers to shared pointers per window per
frame when its not really needed, use weakpointers all the way and it
drops to a bottom contender. marginal gains in the big picture. but
gains is gains.
Diffstat (limited to 'src/render')
| -rw-r--r-- | src/render/decorations/CHyprBorderDecoration.cpp | 2 | ||||
| -rw-r--r-- | src/render/decorations/CHyprGroupBarDecoration.cpp | 2 | ||||
| -rw-r--r-- | src/render/decorations/DecorationPositioner.cpp | 13 | ||||
| -rw-r--r-- | src/render/decorations/DecorationPositioner.hpp | 8 |
4 files changed, 15 insertions, 10 deletions
diff --git a/src/render/decorations/CHyprBorderDecoration.cpp b/src/render/decorations/CHyprBorderDecoration.cpp index 0bf1f16a..75298ff7 100644 --- a/src/render/decorations/CHyprBorderDecoration.cpp +++ b/src/render/decorations/CHyprBorderDecoration.cpp @@ -34,7 +34,7 @@ void CHyprBorderDecoration::onPositioningReply(const SDecorationPositioningReply CBox CHyprBorderDecoration::assignedBoxGlobal() { CBox box = m_assignedGeometry; - box.translate(g_pDecorationPositioner->getEdgeDefinedPoint(DECORATION_EDGE_BOTTOM | DECORATION_EDGE_LEFT | DECORATION_EDGE_RIGHT | DECORATION_EDGE_TOP, m_window.lock())); + box.translate(g_pDecorationPositioner->getEdgeDefinedPoint(DECORATION_EDGE_BOTTOM | DECORATION_EDGE_LEFT | DECORATION_EDGE_RIGHT | DECORATION_EDGE_TOP, m_window)); const auto PWORKSPACE = m_window->m_workspace; diff --git a/src/render/decorations/CHyprGroupBarDecoration.cpp b/src/render/decorations/CHyprGroupBarDecoration.cpp index 10f1503a..49fcd347 100644 --- a/src/render/decorations/CHyprGroupBarDecoration.cpp +++ b/src/render/decorations/CHyprGroupBarDecoration.cpp @@ -596,7 +596,7 @@ std::string CHyprGroupBarDecoration::getDisplayName() { CBox CHyprGroupBarDecoration::assignedBoxGlobal() { CBox box = m_assignedBox; - box.translate(g_pDecorationPositioner->getEdgeDefinedPoint(DECORATION_EDGE_TOP, m_window.lock())); + box.translate(g_pDecorationPositioner->getEdgeDefinedPoint(DECORATION_EDGE_TOP, m_window)); const auto PWORKSPACE = m_window->m_workspace; diff --git a/src/render/decorations/DecorationPositioner.cpp b/src/render/decorations/DecorationPositioner.cpp index 760a9a33..1082812f 100644 --- a/src/render/decorations/DecorationPositioner.cpp +++ b/src/render/decorations/DecorationPositioner.cpp @@ -15,7 +15,12 @@ CDecorationPositioner::CDecorationPositioner() { }); } -Vector2D CDecorationPositioner::getEdgeDefinedPoint(uint32_t edges, PHLWINDOW pWindow) { +Vector2D CDecorationPositioner::getEdgeDefinedPoint(uint32_t edges, PHLWINDOWREF pWindow) { + if (!pWindow) { + Debug::log(ERR, "getEdgeDefinedPoint: invalid pWindow"); + return {}; + } + const bool TOP = edges & DECORATION_EDGE_TOP; const bool BOTTOM = edges & DECORATION_EDGE_BOTTOM; const bool LEFT = edges & DECORATION_EDGE_LEFT; @@ -286,14 +291,14 @@ void CDecorationPositioner::onWindowMap(PHLWINDOW pWindow) { m_windowDatas[pWindow] = {}; } -SBoxExtents CDecorationPositioner::getWindowDecorationReserved(PHLWINDOW pWindow) { +SBoxExtents CDecorationPositioner::getWindowDecorationReserved(PHLWINDOWREF pWindow) { try { const auto E = m_windowDatas.at(pWindow); return E.reserved; } catch (std::out_of_range& e) { return {}; } } -SBoxExtents CDecorationPositioner::getWindowDecorationExtents(PHLWINDOW pWindow, bool inputOnly) { +SBoxExtents CDecorationPositioner::getWindowDecorationExtents(PHLWINDOWREF pWindow, bool inputOnly) { CBox const mainSurfaceBox = pWindow->getWindowMainSurfaceBox(); CBox accum = mainSurfaceBox; @@ -301,7 +306,7 @@ SBoxExtents CDecorationPositioner::getWindowDecorationExtents(PHLWINDOW pWindow, if (!data->pDecoration || (inputOnly && !(data->pDecoration->getDecorationFlags() & DECORATION_ALLOWS_MOUSE_INPUT))) continue; - auto const window = data->pWindow.lock(); + auto const window = data->pWindow; if (!window || window != pWindow) continue; diff --git a/src/render/decorations/DecorationPositioner.hpp b/src/render/decorations/DecorationPositioner.hpp index 7189db41..8048c7ad 100644 --- a/src/render/decorations/DecorationPositioner.hpp +++ b/src/render/decorations/DecorationPositioner.hpp @@ -59,13 +59,13 @@ class CDecorationPositioner { public: CDecorationPositioner(); - Vector2D getEdgeDefinedPoint(uint32_t edges, PHLWINDOW pWindow); + Vector2D getEdgeDefinedPoint(uint32_t edges, PHLWINDOWREF pWindow); // called on resize, or insert/removal of a new deco void onWindowUpdate(PHLWINDOW pWindow); void uncacheDecoration(IHyprWindowDecoration* deco); - SBoxExtents getWindowDecorationReserved(PHLWINDOW pWindow); - SBoxExtents getWindowDecorationExtents(PHLWINDOW pWindow, bool inputOnly = false); + SBoxExtents getWindowDecorationReserved(PHLWINDOWREF pWindow); + SBoxExtents getWindowDecorationExtents(PHLWINDOWREF pWindow, bool inputOnly = false); CBox getBoxWithIncludedDecos(PHLWINDOW pWindow); void repositionDeco(IHyprWindowDecoration* deco); CBox getWindowDecorationBox(IHyprWindowDecoration* deco); @@ -96,4 +96,4 @@ class CDecorationPositioner { void sanitizeDatas(); }; -inline UP<CDecorationPositioner> g_pDecorationPositioner;
\ No newline at end of file +inline UP<CDecorationPositioner> g_pDecorationPositioner; |
