From 5191311d36fbbbe51a3c137f36148a662a099963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B6glund?= Date: Sat, 29 Jun 2019 13:03:23 +0200 Subject: [PATCH 1/2] [effects/blur] Disable sRGB when the framebuffer is linear MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Disable sRGB rendering when the color encoding of the default framebuffer is linear. BUG: 408594 FIXED-IN: 5.16.3 Differential Revision: https://phabricator.kde.org/D22153 Signed-off-by: Fredrik Höglund --- effects/blur/blur.cpp | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/effects/blur/blur.cpp b/effects/blur/blur.cpp index f1a0b54217..02670ffa90 100644 --- a/effects/blur/blur.cpp +++ b/effects/blur/blur.cpp @@ -126,7 +126,30 @@ void BlurEffect::updateTexture() m_renderTargets.reserve(m_downSampleIterations + 2); m_renderTextures.reserve(m_downSampleIterations + 2); - const GLenum textureFormat = GLPlatform::instance()->isGLES() ? GL_RGBA8 : GL_SRGB8_ALPHA8; + GLenum textureFormat = GL_RGBA8; + + // Check the color encoding of the default framebuffer + if (!GLPlatform::instance()->isGLES()) { + GLuint prevFbo = 0; + glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, reinterpret_cast(&prevFbo)); + + if (prevFbo != 0) { + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); + } + + GLenum colorEncoding = GL_LINEAR; + glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, GL_BACK_LEFT, + GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, + reinterpret_cast(&colorEncoding)); + + if (prevFbo != 0) { + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, prevFbo); + } + + if (colorEncoding == GL_SRGB) { + textureFormat = GL_SRGB8_ALPHA8; + } + } for (int i = 0; i <= m_downSampleIterations; i++) { m_renderTextures.append(GLTexture(textureFormat, effects->virtualScreenSize() / (1 << i))); @@ -643,7 +666,7 @@ void BlurEffect::doBlur(const QRegion& shape, const QRect& screen, const float o const QRegion expandedBlurRegion = expand(shape) & expand(screen); - const bool isGLES = GLPlatform::instance()->isGLES(); + const bool useSRGB = m_renderTextures.first().internalFormat() == GL_SRGB8_ALPHA8; // Upload geometry for the down and upsample iterations GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer(); @@ -668,7 +691,7 @@ void BlurEffect::doBlur(const QRegion& shape, const QRect& screen, const float o if (isDock) { m_renderTargets.last()->blitFromFramebuffer(sourceRect, destRect); - if (!isGLES) { + if (useSRGB) { glEnable(GL_FRAMEBUFFER_SRGB); } @@ -676,7 +699,7 @@ void BlurEffect::doBlur(const QRegion& shape, const QRect& screen, const float o } else { m_renderTargets.first()->blitFromFramebuffer(sourceRect, destRect); - if (!isGLES) { + if (useSRGB) { glEnable(GL_FRAMEBUFFER_SRGB); } @@ -703,7 +726,7 @@ void BlurEffect::doBlur(const QRegion& shape, const QRect& screen, const float o upscaleRenderToScreen(vbo, blurRectCount * (m_downSampleIterations + 1), shape.rectCount() * 6, screenProjection, windowRect.topLeft()); - if (!isGLES) { + if (useSRGB) { glDisable(GL_FRAMEBUFFER_SRGB); } From 8dba9bfd438c7703c5d2ffb9d1e214554abac58a Mon Sep 17 00:00:00 2001 From: Igor Kovalenko Date: Tue, 9 Jul 2019 11:14:37 +0200 Subject: [PATCH 2/2] Fix check for SCHED_RESET_ON_FORK feature in clean build Configuration macro HAVE_SCHED_RESET_ON_FORK is not reflecting availability of SCHED_RESET_ON_FORK in config-kwin.h because that feature is detected after file is already generated. Fix this by moving config-kwin.h generation after feature detection. Differential Revision: https://phabricator.kde.org/D22337 --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 106ddca12b..120a20f0c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -350,7 +350,6 @@ add_feature_info("prctl/procctl tracing control" "Required for disallowing ptrace on kwin_wayland process") check_include_file("sys/sysmacros.h" HAVE_SYS_SYSMACROS_H) -configure_file(config-kwin.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kwin.h ) check_include_file("linux/vt.h" HAVE_LINUX_VT_H) add_feature_info("linux/vt.h" @@ -366,6 +365,8 @@ add_feature_info("SCHED_RESET_ON_FORK" HAVE_SCHED_RESET_ON_FORK "Required for running kwin_wayland with real-time scheduling") +configure_file(config-kwin.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kwin.h ) + ########### global ############### set(kwin_effects_dbus_xml ${CMAKE_CURRENT_SOURCE_DIR}/org.kde.kwin.Effects.xml)