Skip to content

armgit / krita

Public Imported from GitHub
0

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++

Disable support of transfer_function_srgb in Wayland

Dmitry Kazakovf46be1bb7e25
diff --git a/libs/surfacecolormanagementapi/surfacecolormanagement/KisSurfaceColorimetry.h b/libs/surfacecolormanagementapi/surfacecolormanagement/KisSurfaceColorimetry.h
index 5a152ecbf7..edfa21f1cc 100644
--- a/libs/surfacecolormanagementapi/surfacecolormanagement/KisSurfaceColorimetry.h
+++ b/libs/surfacecolormanagementapi/surfacecolormanagement/KisSurfaceColorimetry.h
@@ -29,7 +29,7 @@ namespace KisSurfaceColorimetry
transfer_function_gamma22 = 2, // supported by KDE
transfer_function_gamma28 = 3,
transfer_function_ext_linear = 5, // supported by KDE
- transfer_function_srgb = 9, // supported by KDE
+ transfer_function_srgb = 9, // supported by KDE, but broken and deprecated
transfer_function_ext_srgb = 10,
transfer_function_st2084_pq = 11, // supported by KDE
transfer_function_st428 = 12,
diff --git a/plugins/platforms/wayland/waylandcolormanagement/KisWaylandSurfaceColorManager.cpp b/plugins/platforms/wayland/waylandcolormanagement/KisWaylandSurfaceColorManager.cpp
index e83844e83e..d72ab4f8ea 100644
--- a/plugins/platforms/wayland/waylandcolormanagement/KisWaylandSurfaceColorManager.cpp
+++ b/plugins/platforms/wayland/waylandcolormanagement/KisWaylandSurfaceColorManager.cpp
@@ -229,6 +229,19 @@ bool KisWaylandSurfaceColorManager::supportsSurfaceDescription(const KisSurfaceC
if (std::holds_alternative<KisSurfaceColorimetry::NamedTransferFunction>(desc.colorSpace.transferFunction)) {
auto waylandTransferFunction = transferFunctionKritaToWayland(std::get<KisSurfaceColorimetry::NamedTransferFunction>(desc.colorSpace.transferFunction));
+ /**
+ * For some obscure reason Wayland compositors implemented transfer_function_srgb
+ * as gamma-2.2 transfer function, which caused a lot of confustion. Hence the enum
+ * is going to be deprecated in the upcoming version of the protocol.
+ *
+ * https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/442
+ */
+ if (waylandTransferFunction == QtWayland::wp_color_manager_v1::transfer_function_srgb ||
+ waylandTransferFunction == QtWayland::wp_color_manager_v1::transfer_function_ext_srgb) {
+
+ return false;
+ }
+
if (!m_waylandManager->isTransferFunctionNamedSupported(waylandTransferFunction))
return false;
}