Check earlier if pixman regions are empty.

This commit is contained in:
Felix Dick 2022-10-08 00:40:05 +02:00
parent 1964bcb13f
commit 2f3528c076

View file

@ -310,6 +310,7 @@ 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) { void CHyprOpenGLImpl::renderRect(wlr_box* box, const CColor& col, int round) {
if(pixman_region32_not_empty(m_RenderData.pDamage))
renderRectWithDamage(box, col, m_RenderData.pDamage, round); renderRectWithDamage(box, col, m_RenderData.pDamage, round);
} }
@ -366,14 +367,12 @@ void CHyprOpenGLImpl::renderRectWithDamage(wlr_box* box, const CColor& col, pixm
pixman_region32_fini(&damageClip); pixman_region32_fini(&damageClip);
} else { } else {
if (pixman_region32_not_empty(damage)) {
PIXMAN_DAMAGE_FOREACH(damage) { PIXMAN_DAMAGE_FOREACH(damage) {
const auto RECT = RECTSARR[i]; const auto RECT = RECTSARR[i];
scissor(&RECT); scissor(&RECT);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
} }
} }
}
glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shQUAD.posAttrib); glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shQUAD.posAttrib);
glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shQUAD.texAttrib); glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shQUAD.texAttrib);
@ -399,6 +398,9 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b
RASSERT(m_RenderData.pMonitor, "Tried to render texture without begin()!"); RASSERT(m_RenderData.pMonitor, "Tried to render texture without begin()!");
RASSERT((tex.m_iTexID > 0), "Attempted to draw NULL texture!"); RASSERT((tex.m_iTexID > 0), "Attempted to draw NULL texture!");
if (!pixman_region32_not_empty(m_RenderData.pDamage))
return;
static auto *const PDIMINACTIVE = &g_pConfigManager->getConfigValuePtr("decoration:dim_inactive")->intValue; static auto *const PDIMINACTIVE = &g_pConfigManager->getConfigValuePtr("decoration:dim_inactive")->intValue;
// get transform // get transform
@ -498,14 +500,12 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b
pixman_region32_fini(&damageClip); pixman_region32_fini(&damageClip);
} else { } else {
if (pixman_region32_not_empty(damage)) {
PIXMAN_DAMAGE_FOREACH(damage) { PIXMAN_DAMAGE_FOREACH(damage) {
const auto RECT = RECTSARR[i]; const auto RECT = RECTSARR[i];
scissor(&RECT); scissor(&RECT);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
} }
} }
}
glDisableVertexAttribArray(shader->posAttrib); glDisableVertexAttribArray(shader->posAttrib);
glDisableVertexAttribArray(shader->texAttrib); glDisableVertexAttribArray(shader->texAttrib);
@ -709,16 +709,19 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox,
static auto *const PNOBLUROVERSIZED = &g_pConfigManager->getConfigValuePtr("decoration:no_blur_on_oversized")->intValue; static auto *const PNOBLUROVERSIZED = &g_pConfigManager->getConfigValuePtr("decoration:no_blur_on_oversized")->intValue;
static auto *const PBLURNEWOPTIMIZE = &g_pConfigManager->getConfigValuePtr("decoration:blur_new_optimizations")->intValue; static auto *const PBLURNEWOPTIMIZE = &g_pConfigManager->getConfigValuePtr("decoration:blur_new_optimizations")->intValue;
if (*PBLURENABLED == 0 || (*PNOBLUROVERSIZED && m_RenderData.primarySurfaceUVTopLeft != Vector2D(-1, -1)) || (m_pCurrentWindow && m_pCurrentWindow->m_sAdditionalConfigData.forceNoBlur)) {
renderTexture(tex, pBox, a, round, false, true);
return;
}
// make a damage region for this window // make a damage region for this window
pixman_region32_t damage; pixman_region32_t damage;
pixman_region32_init(&damage); pixman_region32_init(&damage);
pixman_region32_intersect_rect(&damage, m_RenderData.pDamage, pBox->x, pBox->y, pBox->width, pBox->height); // clip it to the box pixman_region32_intersect_rect(&damage, m_RenderData.pDamage, pBox->x, pBox->y, pBox->width, pBox->height); // clip it to the box
if(!pixman_region32_not_empty(&damage))
return;
if (*PBLURENABLED == 0 || (*PNOBLUROVERSIZED && m_RenderData.primarySurfaceUVTopLeft != Vector2D(-1, -1)) || (m_pCurrentWindow && m_pCurrentWindow->m_sAdditionalConfigData.forceNoBlur)) {
renderTexture(tex, pBox, a, round, false, true);
return;
}
// amazing hack: the surface has an opaque region! // amazing hack: the surface has an opaque region!
pixman_region32_t inverseOpaque; pixman_region32_t inverseOpaque;
pixman_region32_init(&inverseOpaque); pixman_region32_init(&inverseOpaque);
@ -769,7 +772,6 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox,
// stencil done. Render everything. // stencil done. Render everything.
wlr_box MONITORBOX = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y}; wlr_box MONITORBOX = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y};
if (pixman_region32_not_empty(&damage)) {
// render our great blurred FB // render our great blurred FB
static auto *const PBLURIGNOREOPACITY = &g_pConfigManager->getConfigValuePtr("decoration:blur_ignore_opacity")->intValue; static auto *const PBLURIGNOREOPACITY = &g_pConfigManager->getConfigValuePtr("decoration:blur_ignore_opacity")->intValue;
m_bEndFrame = true; // fix transformed m_bEndFrame = true; // fix transformed
@ -783,7 +785,6 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox,
// draw window // draw window
glDisable(GL_STENCIL_TEST); glDisable(GL_STENCIL_TEST);
renderTextureInternalWithDamage(tex, pBox, a, &damage, round, false, false, true, true); renderTextureInternalWithDamage(tex, pBox, a, &damage, round, false, false, true, true);
}
glStencilMask(-1); glStencilMask(-1);
glStencilFunc(GL_ALWAYS, 1, 0xFF); glStencilFunc(GL_ALWAYS, 1, 0xFF);
@ -802,6 +803,9 @@ void CHyprOpenGLImpl::renderBorder(wlr_box* box, const CColor& col, int round) {
RASSERT((box->width > 0 && box->height > 0), "Tried to render rect with width/height < 0!"); 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()!"); RASSERT(m_RenderData.pMonitor, "Tried to render rect without begin()!");
if (!pixman_region32_not_empty(m_RenderData.pDamage))
return;
static auto *const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue; static auto *const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
static auto *const PMULTISAMPLE = &g_pConfigManager->getConfigValuePtr("decoration:multisample_edges")->intValue; static auto *const PMULTISAMPLE = &g_pConfigManager->getConfigValuePtr("decoration:multisample_edges")->intValue;
@ -881,14 +885,12 @@ void CHyprOpenGLImpl::renderBorder(wlr_box* box, const CColor& col, int round) {
pixman_region32_fini(&damageClip); pixman_region32_fini(&damageClip);
} else { } else {
if (pixman_region32_not_empty(m_RenderData.pDamage)) {
PIXMAN_DAMAGE_FOREACH(m_RenderData.pDamage) { PIXMAN_DAMAGE_FOREACH(m_RenderData.pDamage) {
const auto RECT = RECTSARR[i]; const auto RECT = RECTSARR[i];
scissor(&RECT); scissor(&RECT);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
} }
} }
}
glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shBORDER1.posAttrib); glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shBORDER1.posAttrib);
glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shBORDER1.texAttrib); glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shBORDER1.texAttrib);
@ -1083,6 +1085,9 @@ void CHyprOpenGLImpl::renderRoundedShadow(wlr_box* box, int round, int range, fl
RASSERT((box->width > 0 && box->height > 0), "Tried to render shadow with width/height < 0!"); RASSERT((box->width > 0 && box->height > 0), "Tried to render shadow with width/height < 0!");
RASSERT(m_pCurrentWindow, "Tried to render shadow without a window!"); RASSERT(m_pCurrentWindow, "Tried to render shadow without a window!");
if (!pixman_region32_not_empty(m_RenderData.pDamage))
return;
static auto *const PSHADOWPOWER = &g_pConfigManager->getConfigValuePtr("decoration:shadow_render_power")->intValue; static auto *const PSHADOWPOWER = &g_pConfigManager->getConfigValuePtr("decoration:shadow_render_power")->intValue;
const auto SHADOWPOWER = std::clamp((int)*PSHADOWPOWER, 1, 4); const auto SHADOWPOWER = std::clamp((int)*PSHADOWPOWER, 1, 4);
@ -1139,14 +1144,12 @@ void CHyprOpenGLImpl::renderRoundedShadow(wlr_box* box, int round, int range, fl
pixman_region32_fini(&damageClip); pixman_region32_fini(&damageClip);
} else { } else {
if (pixman_region32_not_empty(m_RenderData.pDamage)) {
PIXMAN_DAMAGE_FOREACH(m_RenderData.pDamage) { PIXMAN_DAMAGE_FOREACH(m_RenderData.pDamage) {
const auto RECT = RECTSARR[i]; const auto RECT = RECTSARR[i];
scissor(&RECT); scissor(&RECT);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
} }
} }
}
glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shSHADOW.posAttrib); glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shSHADOW.posAttrib);
glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shSHADOW.texAttrib); glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shSHADOW.texAttrib);