summaryrefslogtreecommitdiff
path: root/src/render
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2024-11-05 15:44:40 +0000
committerVaxry <vaxry@vaxry.net>2024-11-05 15:44:40 +0000
commitd1638a09bacd84b994de3f77746b74f427b9d41e (patch)
treef66cae3de19e6708c9c6f09dff1fffbe014d2849 /src/render
parente3882b23d09aad7f5c3a708536c87b062f3b0d8d (diff)
shadow: add sharp and refactor options
options moved to decoration:shadow:
Diffstat (limited to 'src/render')
-rw-r--r--src/render/OpenGL.cpp6
-rw-r--r--src/render/decorations/CHyprDropShadowDecoration.cpp34
-rw-r--r--src/render/decorations/CHyprDropShadowDecoration.hpp2
3 files changed, 28 insertions, 14 deletions
diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp
index 45837509..52392436 100644
--- a/src/render/OpenGL.cpp
+++ b/src/render/OpenGL.cpp
@@ -2465,7 +2465,7 @@ void CHyprOpenGLImpl::renderRoundedShadow(CBox* box, int round, int range, const
box = &newBox;
- static auto PSHADOWPOWER = CConfigValue<Hyprlang::INT>("decoration:shadow_render_power");
+ static auto PSHADOWPOWER = CConfigValue<Hyprlang::INT>("decoration:shadow:render_power");
const auto SHADOWPOWER = std::clamp((int)*PSHADOWPOWER, 1, 4);
@@ -2475,7 +2475,7 @@ void CHyprOpenGLImpl::renderRoundedShadow(CBox* box, int round, int range, const
newBox, wlTransformToHyprutils(invertTransform(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform)), newBox.rot);
Mat3x3 glMatrix = m_RenderData.projection.copy().multiply(matrix);
- glEnable(GL_BLEND);
+ blend(true);
glUseProgram(m_RenderData.pCurrentMonData->m_shSHADOW.program);
@@ -2485,7 +2485,7 @@ void CHyprOpenGLImpl::renderRoundedShadow(CBox* box, int round, int range, const
glMatrix.transpose();
glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shSHADOW.proj, 1, GL_FALSE, glMatrix.getMatrix().data());
#endif
- glUniform4f(m_RenderData.pCurrentMonData->m_shSHADOW.color, col.r, col.g, col.b, col.a * a);
+ glUniform4f(m_RenderData.pCurrentMonData->m_shSHADOW.color, col.r * col.a * a, col.g * col.a * a, col.b * col.a * a, col.a * a);
const auto TOPLEFT = Vector2D(range + round, range + round);
const auto BOTTOMRIGHT = Vector2D(box->width - (range + round), box->height - (range + round));
diff --git a/src/render/decorations/CHyprDropShadowDecoration.cpp b/src/render/decorations/CHyprDropShadowDecoration.cpp
index f146776f..893ad498 100644
--- a/src/render/decorations/CHyprDropShadowDecoration.cpp
+++ b/src/render/decorations/CHyprDropShadowDecoration.cpp
@@ -36,7 +36,7 @@ std::string CHyprDropShadowDecoration::getDisplayName() {
}
void CHyprDropShadowDecoration::damageEntire() {
- static auto PSHADOWS = CConfigValue<Hyprlang::INT>("decoration:drop_shadow");
+ static auto PSHADOWS = CConfigValue<Hyprlang::INT>("decoration:shadow:enabled");
if (*PSHADOWS != 1)
return; // disabled
@@ -52,7 +52,7 @@ void CHyprDropShadowDecoration::damageEntire() {
shadowBox.translate(PWORKSPACE->m_vRenderOffset.value());
shadowBox.translate(PWINDOW->m_vFloatingOffset);
- static auto PSHADOWIGNOREWINDOW = CConfigValue<Hyprlang::INT>("decoration:shadow_ignore_window");
+ static auto PSHADOWIGNOREWINDOW = CConfigValue<Hyprlang::INT>("decoration:shadow:ignore_window");
const auto ROUNDING = PWINDOW->rounding();
const auto ROUNDINGSIZE = ROUNDING - M_SQRT1_2 * ROUNDING + 1;
@@ -102,11 +102,11 @@ void CHyprDropShadowDecoration::draw(PHLMONITOR pMonitor, float const& a) {
if (PWINDOW->m_sWindowData.noShadow.valueOrDefault())
return;
- static auto PSHADOWS = CConfigValue<Hyprlang::INT>("decoration:drop_shadow");
- static auto PSHADOWSIZE = CConfigValue<Hyprlang::INT>("decoration:shadow_range");
- static auto PSHADOWIGNOREWINDOW = CConfigValue<Hyprlang::INT>("decoration:shadow_ignore_window");
- static auto PSHADOWSCALE = CConfigValue<Hyprlang::FLOAT>("decoration:shadow_scale");
- static auto PSHADOWOFFSET = CConfigValue<Hyprlang::VEC2>("decoration:shadow_offset");
+ static auto PSHADOWS = CConfigValue<Hyprlang::INT>("decoration:shadow:enabled");
+ static auto PSHADOWSIZE = CConfigValue<Hyprlang::INT>("decoration:shadow:range");
+ static auto PSHADOWIGNOREWINDOW = CConfigValue<Hyprlang::INT>("decoration:shadow:ignore_window");
+ static auto PSHADOWSCALE = CConfigValue<Hyprlang::FLOAT>("decoration:shadow:scale");
+ static auto PSHADOWOFFSET = CConfigValue<Hyprlang::VEC2>("decoration:shadow:offset");
if (*PSHADOWS != 1)
return; // disabled
@@ -184,7 +184,7 @@ void CHyprDropShadowDecoration::draw(PHLMONITOR pMonitor, float const& a) {
g_pHyprOpenGL->renderRect(&fullBox, CColor(0, 0, 0, 1), 0);
// render white shadow with the alpha of the shadow color (otherwise we clear with alpha later and shit it to 2 bit)
- g_pHyprOpenGL->renderRoundedShadow(&fullBox, ROUNDING * pMonitor->scale, *PSHADOWSIZE * pMonitor->scale, CColor(1, 1, 1, PWINDOW->m_cRealShadowColor.value().a), a);
+ drawShadowInternal(&fullBox, ROUNDING * pMonitor->scale, *PSHADOWSIZE * pMonitor->scale, CColor(1, 1, 1, PWINDOW->m_cRealShadowColor.value().a), a);
// render black window box ("clip")
g_pHyprOpenGL->renderRect(&windowBox, CColor(0, 0, 0, 1.0), (ROUNDING + 1 /* This fixes small pixel gaps. */) * pMonitor->scale);
@@ -204,9 +204,8 @@ void CHyprDropShadowDecoration::draw(PHLMONITOR pMonitor, float const& a) {
g_pHyprOpenGL->setMonitorTransformEnabled(false);
g_pHyprOpenGL->m_RenderData.damage = saveDamage;
- } else {
- g_pHyprOpenGL->renderRoundedShadow(&fullBox, ROUNDING * pMonitor->scale, *PSHADOWSIZE * pMonitor->scale, PWINDOW->m_cRealShadowColor.value(), a);
- }
+ } else
+ drawShadowInternal(&fullBox, ROUNDING * pMonitor->scale, *PSHADOWSIZE * pMonitor->scale, PWINDOW->m_cRealShadowColor.value(), a);
if (m_seExtents != m_seReportedExtents)
g_pDecorationPositioner->repositionDeco(this);
@@ -215,3 +214,16 @@ void CHyprDropShadowDecoration::draw(PHLMONITOR pMonitor, float const& a) {
eDecorationLayer CHyprDropShadowDecoration::getDecorationLayer() {
return DECORATION_LAYER_BOTTOM;
}
+
+void CHyprDropShadowDecoration::drawShadowInternal(CBox* box, int round, int range, CColor color, float a) {
+ static auto PSHADOWSHARP = CConfigValue<Hyprlang::INT>("decoration:shadow:sharp");
+
+ g_pHyprOpenGL->blend(true);
+
+ color.a *= a;
+
+ if (*PSHADOWSHARP)
+ g_pHyprOpenGL->renderRect(box, color, round);
+ else
+ g_pHyprOpenGL->renderRoundedShadow(box, round, range, color, 1.F);
+}
diff --git a/src/render/decorations/CHyprDropShadowDecoration.hpp b/src/render/decorations/CHyprDropShadowDecoration.hpp
index 8335cde9..933ee0ef 100644
--- a/src/render/decorations/CHyprDropShadowDecoration.hpp
+++ b/src/render/decorations/CHyprDropShadowDecoration.hpp
@@ -34,6 +34,8 @@ class CHyprDropShadowDecoration : public IHyprWindowDecoration {
Vector2D m_vLastWindowPos;
Vector2D m_vLastWindowSize;
+ void drawShadowInternal(CBox* box, int round, int range, CColor color, float a);
+
CBox m_bLastWindowBox = {0};
CBox m_bLastWindowBoxWithDecos = {0};
};