aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorvaxerski <[email protected]>2022-06-21 23:09:20 +0200
committervaxerski <[email protected]>2022-06-21 23:09:20 +0200
commit4c2459861b9e61b13443efebde5125d5c68221b0 (patch)
treeacacf74aaa93a2b8644c3197c89d0f1c606eff10
parent0f1ad16aecfdf89dd5d83d38318de8518157e6ee (diff)
downloadHyprland-4c2459861b9e61b13443efebde5125d5c68221b0.tar.gz
Hyprland-4c2459861b9e61b13443efebde5125d5c68221b0.zip
fix borders sometimes disappearing on certain windows
-rw-r--r--src/render/OpenGL.cpp40
-rw-r--r--src/render/OpenGL.hpp1
2 files changed, 28 insertions, 13 deletions
diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp
index 6a82cb83..d8f64e0c 100644
--- a/src/render/OpenGL.cpp
+++ b/src/render/OpenGL.cpp
@@ -240,6 +240,10 @@ void CHyprOpenGLImpl::scissor(const int x, const int y, const int w, const int h
}
void CHyprOpenGLImpl::renderRect(wlr_box* box, const CColor& col, int round) {
+ renderRectWithDamage(box, col, m_RenderData.pDamage, round);
+}
+
+void CHyprOpenGLImpl::renderRectWithDamage(wlr_box* box, const CColor& col, pixman_region32_t* damage, int round) {
RASSERT((box->width > 0 && box->height > 0), "Tried to render rect with width/height < 0!");
RASSERT(m_RenderData.pMonitor, "Tried to render rect without begin()!");
@@ -279,8 +283,8 @@ void CHyprOpenGLImpl::renderRect(wlr_box* box, const CColor& col, int round) {
glEnableVertexAttribArray(m_shQUAD.posAttrib);
glEnableVertexAttribArray(m_shQUAD.texAttrib);
- if (pixman_region32_not_empty(m_RenderData.pDamage)) {
- PIXMAN_DAMAGE_FOREACH(m_RenderData.pDamage) {
+ if (pixman_region32_not_empty(damage)) {
+ PIXMAN_DAMAGE_FOREACH(damage) {
const auto RECT = RECTSARR[i];
scissor(&RECT);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
@@ -341,6 +345,21 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b
RASSERT(false, "tex.m_iTarget unsupported!");
}
+ // stencil for when we want a border
+ if (border) {
+ glClearStencil(0);
+ glClear(GL_STENCIL_BUFFER_BIT);
+
+ glEnable(GL_STENCIL_TEST);
+
+ glStencilFunc(GL_ALWAYS, 1, -1);
+ glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
+
+ // hacky fix to fix broken borders.
+ // TODO: this is kinda slow... question mark?
+ renderRect(pBox, CColor(0, 0, 0, 0), round);
+ }
+
glActiveTexture(GL_TEXTURE0);
glBindTexture(tex.m_iTarget, tex.m_iTexID);
@@ -374,17 +393,6 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b
glEnableVertexAttribArray(shader->posAttrib);
glEnableVertexAttribArray(shader->texAttrib);
- // stencil for when we want a border
- if (border) {
- glClearStencil(0);
- glClear(GL_STENCIL_BUFFER_BIT);
-
- glEnable(GL_STENCIL_TEST);
-
- glStencilFunc(GL_ALWAYS, 1, -1);
- glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
- }
-
if (pixman_region32_not_empty(m_RenderData.pDamage)) {
PIXMAN_DAMAGE_FOREACH(m_RenderData.pDamage) {
const auto RECT = RECTSARR[i];
@@ -609,6 +617,12 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox,
glStencilFunc(GL_ALWAYS, 1, -1);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
+ if (border) {
+ // hacky fix to fix broken borders.
+ // TODO: this is kinda slow... question mark?
+ renderRectWithDamage(pBox, CColor(0,0,0,0), &damage, round);
+ }
+
renderTextureInternalWithDamage(tex, pBox, a, &damage, round, false, false, true);
// then stop
diff --git a/src/render/OpenGL.hpp b/src/render/OpenGL.hpp
index 9a8084db..76de6311 100644
--- a/src/render/OpenGL.hpp
+++ b/src/render/OpenGL.hpp
@@ -53,6 +53,7 @@ public:
void end();
void renderRect(wlr_box*, const CColor&, int round = 0);
+ void renderRectWithDamage(wlr_box*, const CColor&, pixman_region32_t* damage, int round = 0);
void renderTexture(wlr_texture*, wlr_box*, float a, int round = 0);
void renderTexture(const CTexture&, wlr_box*, float a, int round = 0, bool discardOpaque = false, bool border = false);
void renderTextureWithBlur(const CTexture&, wlr_box*, float a, wlr_surface* pSurface, int round = 0, bool border = false);