2024-12-22 17:12:09 +01:00
|
|
|
#include "RectPassElement.hpp"
|
|
|
|
|
#include "../OpenGL.hpp"
|
|
|
|
|
|
|
|
|
|
CRectPassElement::CRectPassElement(const CRectPassElement::SRectData& data_) : data(data_) {
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CRectPassElement::draw(const CRegion& damage) {
|
2025-01-02 21:58:23 +01:00
|
|
|
if (data.box.w <= 0 || data.box.h <= 0)
|
|
|
|
|
return;
|
|
|
|
|
|
2025-01-31 13:32:36 +00:00
|
|
|
if (!data.clipBox.empty())
|
|
|
|
|
g_pHyprOpenGL->m_RenderData.clipBox = data.clipBox;
|
|
|
|
|
|
2024-12-22 17:12:09 +01:00
|
|
|
if (data.color.a == 1.F || !data.blur)
|
2025-01-26 15:05:34 +00:00
|
|
|
g_pHyprOpenGL->renderRectWithDamage(data.box, data.color, damage, data.round, data.roundingPower);
|
2024-12-22 17:12:09 +01:00
|
|
|
else
|
2025-01-26 15:05:34 +00:00
|
|
|
g_pHyprOpenGL->renderRectWithBlur(data.box, data.color, data.round, data.roundingPower, data.blurA, data.xray);
|
2025-01-31 13:32:36 +00:00
|
|
|
|
|
|
|
|
g_pHyprOpenGL->m_RenderData.clipBox = {};
|
2024-12-22 17:12:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CRectPassElement::needsLiveBlur() {
|
|
|
|
|
return data.color.a < 1.F && !data.xray && data.blur;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CRectPassElement::needsPrecomputeBlur() {
|
|
|
|
|
return data.color.a < 1.F && data.xray && data.blur;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::optional<CBox> CRectPassElement::boundingBox() {
|
2025-04-30 23:45:20 +02:00
|
|
|
return data.box.copy().scale(1.F / g_pHyprOpenGL->m_RenderData.pMonitor->m_scale).round();
|
2024-12-22 17:12:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CRegion CRectPassElement::opaqueRegion() {
|
2025-03-26 11:47:04 +00:00
|
|
|
if (data.color.a < 1.F)
|
|
|
|
|
return CRegion{};
|
|
|
|
|
|
|
|
|
|
CRegion rg = boundingBox()->expand(-data.round);
|
|
|
|
|
|
|
|
|
|
if (!data.clipBox.empty())
|
|
|
|
|
rg.intersect(data.clipBox);
|
|
|
|
|
|
|
|
|
|
return rg;
|
2024-12-22 17:12:09 +01:00
|
|
|
}
|