2024-12-22 17:12:09 +01:00
|
|
|
#include "RectPassElement.hpp"
|
|
|
|
|
#include "../OpenGL.hpp"
|
|
|
|
|
|
2025-05-05 23:44:49 +02:00
|
|
|
CRectPassElement::CRectPassElement(const CRectPassElement::SRectData& data_) : m_data(data_) {
|
2024-12-22 17:12:09 +01:00
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CRectPassElement::draw(const CRegion& damage) {
|
2025-05-05 23:44:49 +02:00
|
|
|
if (m_data.box.w <= 0 || m_data.box.h <= 0)
|
2025-01-02 21:58:23 +01:00
|
|
|
return;
|
|
|
|
|
|
2025-05-05 23:44:49 +02:00
|
|
|
if (!m_data.clipBox.empty())
|
|
|
|
|
g_pHyprOpenGL->m_renderData.clipBox = m_data.clipBox;
|
2025-01-31 13:32:36 +00:00
|
|
|
|
2025-05-05 23:44:49 +02:00
|
|
|
if (m_data.color.a == 1.F || !m_data.blur)
|
2025-07-31 16:23:09 +02:00
|
|
|
g_pHyprOpenGL->renderRect(m_data.box, m_data.color, {.damage = &damage, .round = m_data.round, .roundingPower = m_data.roundingPower});
|
2024-12-22 17:12:09 +01:00
|
|
|
else
|
2025-07-31 16:23:09 +02:00
|
|
|
g_pHyprOpenGL->renderRect(m_data.box, m_data.color,
|
|
|
|
|
{.round = m_data.round, .roundingPower = m_data.roundingPower, .blur = true, .blurA = m_data.blurA, .xray = m_data.xray});
|
2025-01-31 13:32:36 +00:00
|
|
|
|
2025-05-05 23:44:49 +02:00
|
|
|
g_pHyprOpenGL->m_renderData.clipBox = {};
|
2024-12-22 17:12:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CRectPassElement::needsLiveBlur() {
|
2025-05-05 23:44:49 +02:00
|
|
|
return m_data.color.a < 1.F && !m_data.xray && m_data.blur;
|
2024-12-22 17:12:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CRectPassElement::needsPrecomputeBlur() {
|
2025-05-05 23:44:49 +02:00
|
|
|
return m_data.color.a < 1.F && m_data.xray && m_data.blur;
|
2024-12-22 17:12:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::optional<CBox> CRectPassElement::boundingBox() {
|
2025-05-05 23:44:49 +02:00
|
|
|
return m_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-05-05 23:44:49 +02:00
|
|
|
if (m_data.color.a < 1.F)
|
2025-03-26 11:47:04 +00:00
|
|
|
return CRegion{};
|
|
|
|
|
|
2025-05-05 23:44:49 +02:00
|
|
|
CRegion rg = boundingBox()->expand(-m_data.round);
|
2025-03-26 11:47:04 +00:00
|
|
|
|
2025-05-05 23:44:49 +02:00
|
|
|
if (!m_data.clipBox.empty())
|
|
|
|
|
rg.intersect(m_data.clipBox);
|
2025-03-26 11:47:04 +00:00
|
|
|
|
|
|
|
|
return rg;
|
2024-12-22 17:12:09 +01:00
|
|
|
}
|