screencopy: un-hdr screencopy buffers for cm-unaware clients (#11294)

This commit is contained in:
Vaxry 2025-07-31 18:07:59 +02:00 committed by GitHub
parent a907ecd4ff
commit 9607e3b5a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 39 additions and 10 deletions

View file

@ -1593,11 +1593,12 @@ void CHyprOpenGLImpl::renderTextureInternal(SP<CTexture> 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<CTexture> 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());

View file

@ -200,6 +200,8 @@ class CHyprOpenGLImpl {
bool noAA = false;
bool blockBlurOptimization = false;
GLenum wrapX = GL_CLAMP_TO_EDGE, wrapY = GL_CLAMP_TO_EDGE;
bool cmBackToSRGB = false;
SP<CMonitor> cmBackToSRGBSource;
};
struct SBorderRenderData {