summaryrefslogtreecommitdiff
path: root/src/render/Renderer.cpp
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2023-07-20 13:49:28 +0200
committervaxerski <43317083+vaxerski@users.noreply.github.com>2023-07-20 13:49:28 +0200
commit547305c7ed02c37b68773b2ccb6fb7f702898f0a (patch)
tree1f1f47781d7679f53f720f3709196145e65bf9d5 /src/render/Renderer.cpp
parentb65adf8d4a0c239f5aa44425d14d1fe14f675643 (diff)
opengl: adjust blend and reduce the usage of clear
Diffstat (limited to 'src/render/Renderer.cpp')
-rw-r--r--src/render/Renderer.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index acc5955e..f3656fc7 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -40,6 +40,13 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) {
rounding -= 1; // to fix a border issue
+ const bool CANDISABLEBLEND = RDATA->alpha >= 1.f && rounding == 0 && surface->opaque;
+
+ if (CANDISABLEBLEND)
+ g_pHyprOpenGL->blend(false);
+ else
+ g_pHyprOpenGL->blend(true);
+
if (RDATA->surface && surface == RDATA->surface) {
if (wlr_xwayland_surface_try_from_wlr_surface(surface) && !wlr_xwayland_surface_try_from_wlr_surface(surface)->has_alpha && RDATA->fadeAlpha * RDATA->alpha == 1.f) {
g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, rounding, true);
@@ -58,6 +65,8 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) {
wlr_presentation_surface_textured_on_output(g_pCompositor->m_sWLRPresentation, surface, RDATA->pMonitor->output);
}
+ g_pHyprOpenGL->blend(true);
+
// reset the UV, we might've set it above
g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(-1, -1);
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D(-1, -1);
@@ -806,6 +815,7 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
static auto* const PNODIRECTSCANOUT = &g_pConfigManager->getConfigValuePtr("misc:no_direct_scanout")->intValue;
static auto* const PVFR = &g_pConfigManager->getConfigValuePtr("misc:vfr")->intValue;
static auto* const PZOOMFACTOR = &g_pConfigManager->getConfigValuePtr("misc:cursor_zoom_factor")->floatValue;
+ static auto* const PRENDERTEX = &g_pConfigManager->getConfigValuePtr("misc:disable_hyprland_logo")->intValue;
static int damageBlinkCleanup = 0; // because double-buffered
@@ -979,11 +989,17 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
EMIT_HOOK_EVENT("render", RENDER_BEGIN);
if (pMonitor->isMirror()) {
+ g_pHyprOpenGL->blend(false);
g_pHyprOpenGL->renderMirrored();
+ g_pHyprOpenGL->blend(true);
EMIT_HOOK_EVENT("render", RENDER_POST_MIRROR);
} else {
- g_pHyprOpenGL->clear(CColor(17.0 / 255.0, 17.0 / 255.0, 17.0 / 255.0, 1.0));
- g_pHyprOpenGL->clearWithTex(); // will apply the hypr "wallpaper"
+ g_pHyprOpenGL->blend(false);
+ if (*PRENDERTEX /* inverted cfg flag */)
+ g_pHyprOpenGL->clear(CColor(17.0 / 255.0, 17.0 / 255.0, 17.0 / 255.0, 1.0));
+ else
+ g_pHyprOpenGL->clearWithTex(); // will apply the hypr "wallpaper"
+ g_pHyprOpenGL->blend(true);
wlr_box renderBox = {0, 0, (int)pMonitor->vecPixelSize.x, (int)pMonitor->vecPixelSize.y};
renderWorkspace(pMonitor, g_pCompositor->getWorkspaceByID(pMonitor->activeWorkspace), &now, renderBox);