Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Fix HDR initialization on Windows
Dmitry Kazakov1150b845b650
diff --git a/libs/ui/opengl/KisOpenGLModeProber.cpp b/libs/ui/opengl/KisOpenGLModeProber.cppindex f5d4054b2d..910982e694 100644--- a/libs/ui/opengl/KisOpenGLModeProber.cpp+++ b/libs/ui/opengl/KisOpenGLModeProber.cpp@@ -242,11 +242,10 @@ bool KisOpenGLModeProber::fuzzyCompareColorSpaces(const KisSurfaceColorSpaceWrapvoid KisOpenGLModeProber::initSurfaceFormatFromConfig(std::pair<KisSurfaceColorSpaceWrapper, int> rootSurfaceFormat,QSurfaceFormat *format){-if (rootSurfaceFormat.first == KisSurfaceColorSpaceWrapper::scRGBColorSpace) {- KIS_SAFE_ASSERT_RECOVER_NOOP(rootSurfaceFormat.second == 10);-}-#ifdef HAVE_HDR+ /**+ * In Windows' HDR we have three fixed modes only.+ */if (rootSurfaceFormat.first == KisSurfaceColorSpaceWrapper::bt2020PQColorSpace) {KIS_SAFE_ASSERT_RECOVER_NOOP(rootSurfaceFormat.second == 10);format->setRedBufferSize(10);@@ -261,35 +260,47 @@ if (rootSurfaceFormat.first == KisSurfaceColorSpaceWrapper::scRGBColorSpace) {format->setBlueBufferSize(16);format->setAlphaBufferSize(16);format->setColorSpace(KisSurfaceColorSpaceWrapper(KisSurfaceColorSpaceWrapper::scRGBColorSpace));- } else+ } else {+ KIS_SAFE_ASSERT_RECOVER_NOOP(rootSurfaceFormat.second == 8);+ format->setRedBufferSize(8);+ format->setGreenBufferSize(8);+ format->setBlueBufferSize(8);+ format->setAlphaBufferSize(8);+ // TODO: check if we can use real sRGB space here+ format->setColorSpace(KisSurfaceColorSpaceWrapper());+ }#else+ /**+ * In Wayland's HDR we don't set the mode on the root surface, we should only select+ * bit-width.+ */if (rootSurfaceFormat.first == KisSurfaceColorSpaceWrapper::bt2020PQColorSpace) {qWarning() << "WARNING: Bt.2020 PQ surface type is not supported by this build of Krita";rootSurfaceFormat.first = KisSurfaceColorSpaceWrapper::DefaultColorSpace;} else if (rootSurfaceFormat.first == KisSurfaceColorSpaceWrapper::scRGBColorSpace) {qWarning() << "WARNING: scRGB surface type is not supported by this build of Krita";rootSurfaceFormat.first = KisSurfaceColorSpaceWrapper::DefaultColorSpace;- }-#endif-- KIS_SAFE_ASSERT_RECOVER_NOOP(rootSurfaceFormat.first == KisSurfaceColorSpaceWrapper::DefaultColorSpace);- KIS_SAFE_ASSERT_RECOVER_NOOP(rootSurfaceFormat.second == 8 || rootSurfaceFormat.second == 10);-- if (rootSurfaceFormat.second == 10) {- format->setRedBufferSize(10);- format->setGreenBufferSize(10);- format->setBlueBufferSize(10);- format->setAlphaBufferSize(2);- // TODO: check if we can use real sRGB space here- format->setColorSpace(KisSurfaceColorSpaceWrapper());} else {- format->setRedBufferSize(8);- format->setGreenBufferSize(8);- format->setBlueBufferSize(8);- format->setAlphaBufferSize(8);- // TODO: check if we can use real sRGB space here- format->setColorSpace(KisSurfaceColorSpaceWrapper());+ KIS_SAFE_ASSERT_RECOVER_NOOP(rootSurfaceFormat.first == KisSurfaceColorSpaceWrapper::DefaultColorSpace);+ KIS_SAFE_ASSERT_RECOVER_NOOP(rootSurfaceFormat.second == 8 || rootSurfaceFormat.second == 10);++ if (rootSurfaceFormat.second == 10) {+ format->setRedBufferSize(10);+ format->setGreenBufferSize(10);+ format->setBlueBufferSize(10);+ format->setAlphaBufferSize(2);+ // TODO: check if we can use real sRGB space here+ format->setColorSpace(KisSurfaceColorSpaceWrapper());+ } else {+ format->setRedBufferSize(8);+ format->setGreenBufferSize(8);+ format->setBlueBufferSize(8);+ format->setAlphaBufferSize(8);+ // TODO: check if we can use real sRGB space here+ format->setColorSpace(KisSurfaceColorSpaceWrapper());+ }}+#endif}bool KisOpenGLModeProber::isFormatHDR(const QSurfaceFormat &format)