deco: reduce virtual calls in drop shadow
damageEntire() in CHyprdDropShadow is pretty much called per window per frame, instead of all the PWINDOW-> virtual calls, store pos and size once and move the duplicated code to a lambda. reducing it a bit. shows up in profiling as minor waste.
This commit is contained in:
parent
eb25dfd399
commit
f854b5bffb
1 changed files with 12 additions and 10 deletions
|
|
@ -42,15 +42,19 @@ void CHyprDropShadowDecoration::damageEntire() {
|
|||
return; // disabled
|
||||
|
||||
const auto PWINDOW = m_window.lock();
|
||||
const auto pos = PWINDOW->m_realPosition->value();
|
||||
const auto size = PWINDOW->m_realSize->value();
|
||||
|
||||
CBox shadowBox = {PWINDOW->m_realPosition->value().x - m_extents.topLeft.x, PWINDOW->m_realPosition->value().y - m_extents.topLeft.y,
|
||||
PWINDOW->m_realSize->value().x + m_extents.topLeft.x + m_extents.bottomRight.x,
|
||||
PWINDOW->m_realSize->value().y + m_extents.topLeft.y + m_extents.bottomRight.y};
|
||||
CBox shadowBox = {pos.x - m_extents.topLeft.x, pos.y - m_extents.topLeft.y, pos.x + size.x + m_extents.bottomRight.x, pos.y + size.y + m_extents.bottomRight.y};
|
||||
|
||||
const auto PWORKSPACE = PWINDOW->m_workspace;
|
||||
if (PWORKSPACE && PWORKSPACE->m_renderOffset->isBeingAnimated() && !PWINDOW->m_pinned)
|
||||
shadowBox.translate(PWORKSPACE->m_renderOffset->value());
|
||||
shadowBox.translate(PWINDOW->m_floatingOffset);
|
||||
const auto PWORKSPACE = PWINDOW->m_workspace;
|
||||
const auto applyOffset = [&](CBox& b) {
|
||||
if (PWORKSPACE && PWORKSPACE->m_renderOffset->isBeingAnimated() && !PWINDOW->m_pinned)
|
||||
b.translate(PWORKSPACE->m_renderOffset->value());
|
||||
b.translate(PWINDOW->m_floatingOffset);
|
||||
};
|
||||
|
||||
applyOffset(shadowBox);
|
||||
|
||||
static auto PSHADOWIGNOREWINDOW = CConfigValue<Hyprlang::INT>("decoration:shadow:ignore_window");
|
||||
const auto ROUNDING = PWINDOW->rounding();
|
||||
|
|
@ -59,9 +63,7 @@ void CHyprDropShadowDecoration::damageEntire() {
|
|||
CRegion shadowRegion(shadowBox);
|
||||
if (*PSHADOWIGNOREWINDOW) {
|
||||
CBox surfaceBox = PWINDOW->getWindowMainSurfaceBox();
|
||||
if (PWORKSPACE && PWORKSPACE->m_renderOffset->isBeingAnimated() && !PWINDOW->m_pinned)
|
||||
surfaceBox.translate(PWORKSPACE->m_renderOffset->value());
|
||||
surfaceBox.translate(PWINDOW->m_floatingOffset);
|
||||
applyOffset(surfaceBox);
|
||||
surfaceBox.expand(-ROUNDINGSIZE);
|
||||
shadowRegion.subtract(CRegion(surfaceBox));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue