From 9607e3b5a88f22017af64ab1ba360a39169a4bf7 Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Thu, 31 Jul 2025 18:07:59 +0200 Subject: screencopy: un-hdr screencopy buffers for cm-unaware clients (#11294) --- src/render/OpenGL.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/render/OpenGL.cpp') diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index 5470951e..420e997e 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -1593,11 +1593,12 @@ void CHyprOpenGLImpl::renderTextureInternal(SP tex, const CBox& box, c tex->setTexParameter(GL_TEXTURE_MIN_FILTER, GL_LINEAR); } - const auto imageDescription = - m_renderData.surface.valid() && m_renderData.surface->m_colorManagement.valid() ? m_renderData.surface->m_colorManagement->imageDescription() : SImageDescription{}; + const auto imageDescription = m_renderData.surface.valid() && m_renderData.surface->m_colorManagement.valid() ? + m_renderData.surface->m_colorManagement->imageDescription() : + (data.cmBackToSRGB ? data.cmBackToSRGBSource->m_imageDescription : SImageDescription{}); - const bool skipCM = !*PENABLECM || !m_cmSupported /* CM unsupported or disabled */ - || (imageDescription == m_renderData.pMonitor->m_imageDescription) /* Source and target have the same image description */ + const bool skipCM = !*PENABLECM || !m_cmSupported /* CM unsupported or disabled */ + || (imageDescription == m_renderData.pMonitor->m_imageDescription && !data.cmBackToSRGB) /* Source and target have the same image description */ || ((*PPASS == 1 || (*PPASS == 2 && imageDescription.transferFunction == CM_TRANSFER_FUNCTION_ST2084_PQ)) && m_renderData.pMonitor->m_activeWorkspace && m_renderData.pMonitor->m_activeWorkspace->m_hasFullscreenWindow && m_renderData.pMonitor->m_activeWorkspace->m_fullscreenMode == FSMODE_FULLSCREEN) /* Fullscreen window with pass cm enabled */; @@ -1609,7 +1610,10 @@ void CHyprOpenGLImpl::renderTextureInternal(SP tex, const CBox& box, c if (shader == &m_shaders->m_shCM) { shader->setUniformInt(SHADER_TEX_TYPE, texType); - passCMUniforms(*shader, imageDescription); + if (data.cmBackToSRGB) + passCMUniforms(*shader, imageDescription, NColorManagement::SImageDescription{}, true, -1, -1); + else + passCMUniforms(*shader, imageDescription); } shader->setUniformMatrix3fv(SHADER_PROJ, 1, GL_TRUE, glMatrix.getMatrix()); -- cgit v1.2.3