summaryrefslogtreecommitdiff
path: root/src/render/decorations/DecorationPositioner.cpp
diff options
context:
space:
mode:
authorTom Englund <tomenglund26@gmail.com>2024-10-28 19:02:52 +0100
committerGitHub <noreply@github.com>2024-10-28 18:02:52 +0000
commitc7315617eb6186912d03232e1968f32b88f153f2 (patch)
tree7e22a153c332378439c72ebf4bb06f6069411527 /src/render/decorations/DecorationPositioner.cpp
parentd49a1334a8af7c704626cdf1746cb72415ad6d0d (diff)
internal: few more marginal optimisations from profiling (#8271)
* deco: reduce local temporars and function calls profiling shows this is a high used function, reduce the amount of function calls and local temporar copies and also check if we even need to add extents at all in the loop. * popup: optimize bfhelper in popups pass nodes as const reference and reserve the size of the children node vector help reduce the reallocations. * procotol: make compositor bfhelper use const ref use const ref for nodes and reserve second nodes vector size to reduce amount of reallocation needed.
Diffstat (limited to 'src/render/decorations/DecorationPositioner.cpp')
-rw-r--r--src/render/decorations/DecorationPositioner.cpp39
1 files changed, 23 insertions, 16 deletions
diff --git a/src/render/decorations/DecorationPositioner.cpp b/src/render/decorations/DecorationPositioner.cpp
index 3eb45546..995283c6 100644
--- a/src/render/decorations/DecorationPositioner.cpp
+++ b/src/render/decorations/DecorationPositioner.cpp
@@ -294,13 +294,11 @@ SBoxExtents CDecorationPositioner::getWindowDecorationReserved(PHLWINDOW pWindow
}
SBoxExtents CDecorationPositioner::getWindowDecorationExtents(PHLWINDOW pWindow, bool inputOnly) {
- CBox accum = pWindow->getWindowMainSurfaceBox();
+ CBox const mainSurfaceBox = pWindow->getWindowMainSurfaceBox();
+ CBox accum = mainSurfaceBox;
for (auto const& data : m_vWindowPositioningDatas) {
- if (!data->pDecoration)
- continue;
-
- if (!(data->pDecoration->getDecorationFlags() & DECORATION_ALLOWS_MOUSE_INPUT) && inputOnly)
+ if (!data->pDecoration || (inputOnly && !(data->pDecoration->getDecorationFlags() & DECORATION_ALLOWS_MOUSE_INPUT)))
continue;
auto const window = data->pWindow.lock();
@@ -308,31 +306,40 @@ SBoxExtents CDecorationPositioner::getWindowDecorationExtents(PHLWINDOW pWindow,
continue;
CBox decoBox;
-
if (data->positioningInfo.policy == DECORATION_POSITION_ABSOLUTE) {
- decoBox = data->pWindow->getWindowMainSurfaceBox();
+ decoBox = mainSurfaceBox;
decoBox.addExtents(data->positioningInfo.desiredExtents);
} else {
- decoBox = data->lastReply.assignedGeometry;
- const auto EDGEPOINT = getEdgeDefinedPoint(data->positioningInfo.edges, pWindow);
- decoBox.translate(EDGEPOINT);
+ decoBox = data->lastReply.assignedGeometry;
+ decoBox.translate(getEdgeDefinedPoint(data->positioningInfo.edges, pWindow));
}
+ // Check bounds only if decoBox extends beyond accum
SBoxExtents extentsToAdd;
+ bool needUpdate = false;
- if (decoBox.x < accum.x)
+ if (decoBox.x < accum.x) {
extentsToAdd.topLeft.x = accum.x - decoBox.x;
- if (decoBox.y < accum.y)
+ needUpdate = true;
+ }
+ if (decoBox.y < accum.y) {
extentsToAdd.topLeft.y = accum.y - decoBox.y;
- if (decoBox.x + decoBox.w > accum.x + accum.w)
+ needUpdate = true;
+ }
+ if (decoBox.x + decoBox.w > accum.x + accum.w) {
extentsToAdd.bottomRight.x = (decoBox.x + decoBox.w) - (accum.x + accum.w);
- if (decoBox.y + decoBox.h > accum.y + accum.h)
+ needUpdate = true;
+ }
+ if (decoBox.y + decoBox.h > accum.y + accum.h) {
extentsToAdd.bottomRight.y = (decoBox.y + decoBox.h) - (accum.y + accum.h);
+ needUpdate = true;
+ }
- accum.addExtents(extentsToAdd);
+ if (needUpdate)
+ accum.addExtents(extentsToAdd);
}
- return accum.extentsFrom(pWindow->getWindowMainSurfaceBox());
+ return accum.extentsFrom(mainSurfaceBox);
}
CBox CDecorationPositioner::getBoxWithIncludedDecos(PHLWINDOW pWindow) {