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

Add Wayland protocol features report

Dmitry Kazakov5c61610287d8
diff --git a/libs/surfacecolormanagementapi/surfacecolormanagement/KisSurfaceColorManagementInfo.h b/libs/surfacecolormanagementapi/surfacecolormanagement/KisSurfaceColorManagementInfo.h
index 6254409275..94c8e34f50 100644
--- a/libs/surfacecolormanagementapi/surfacecolormanagement/KisSurfaceColorManagementInfo.h
+++ b/libs/surfacecolormanagementapi/surfacecolormanagement/KisSurfaceColorManagementInfo.h
@@ -9,6 +9,7 @@
#include <kritasurfacecolormanagementapi_export.h>
#include <QObject>
+#include <QFuture>
class KRITASURFACECOLORMANAGEMENTAPI_EXPORT KisSurfaceColorManagementInfo : public QObject
{
@@ -23,6 +24,8 @@ public:
* space should be managed by OS.
*/
virtual bool surfaceColorManagedByOS() = 0;
+
+ virtual QFuture<QString> debugReport() = 0;
};
#endif /* KISSURFACECOLORMANAGEMENTINFO_H */
\ No newline at end of file
diff --git a/plugins/extensions/buginfo/DlgColorManagementInfo.cpp b/plugins/extensions/buginfo/DlgColorManagementInfo.cpp
index 8c2297c4b9..c61dfa1260 100644
--- a/plugins/extensions/buginfo/DlgColorManagementInfo.cpp
+++ b/plugins/extensions/buginfo/DlgColorManagementInfo.cpp
@@ -12,6 +12,7 @@
#include <KoPluginLoader.h>
#include <kpluginfactory.h>
#include <surfacecolormanagement/KisOutputColorInfoInterface.h>
+#include <surfacecolormanagement/KisSurfaceColorManagementInfo.h>
DlgColorManagementInfo::DlgColorManagementInfo(QWidget *parent)
@@ -38,6 +39,17 @@ DlgColorManagementInfo::DlgColorManagementInfo(QWidget *parent)
}
});
}
+
+ m_surfaceColorManagementInfo.reset(
+ factory->create<KisSurfaceColorManagementInfo>(nullptr));
+
+ if (m_surfaceColorManagementInfo) {
+ auto future = m_surfaceColorManagementInfo->debugReport();
+ future.then([this] (const QString &report) {
+ m_surfaceManagementReport = report;
+ initializeText();
+ });
+ }
}
}
@@ -136,6 +148,14 @@ QString DlgColorManagementInfo::infoText(QSettings& kritarc)
}
}
+ s << "Color management plugin report" << Qt::endl;
+ s << "===" << Qt::endl;
+ s << Qt::endl;
+
+ s.noquote().nospace() << (m_surfaceManagementReport.isEmpty() ? "<no information available>" : m_surfaceManagementReport);
+ s.space().quote();
+ s << Qt::endl;
+
return report;
}
diff --git a/plugins/extensions/buginfo/DlgColorManagementInfo.h b/plugins/extensions/buginfo/DlgColorManagementInfo.h
index a46c2c684f..bb0ccc7cf9 100644
--- a/plugins/extensions/buginfo/DlgColorManagementInfo.h
+++ b/plugins/extensions/buginfo/DlgColorManagementInfo.h
@@ -13,6 +13,7 @@
class QSettings;
class KisOutputColorInfoInterface;
+class KisSurfaceColorManagementInfo;
class DlgColorManagementInfo: public DlgBugInfo
{
@@ -31,6 +32,8 @@ public:
private:
QScopedPointer<KisOutputColorInfoInterface> m_outputColorInfoInterface;
+ QScopedPointer<KisSurfaceColorManagementInfo> m_surfaceColorManagementInfo;
+ QString m_surfaceManagementReport;
};
#endif // DLG_COLORMANAGEMENTINFO_H
diff --git a/plugins/platforms/wayland/CMakeLists.txt b/plugins/platforms/wayland/CMakeLists.txt
index b02b39ae44..9dbdd5c115 100644
--- a/plugins/platforms/wayland/CMakeLists.txt
+++ b/plugins/platforms/wayland/CMakeLists.txt
@@ -51,7 +51,8 @@ if (KRITA_USE_SURFACE_COLOR_MANAGEMENT_API)
waylandcolormanagement/KisWaylandAPISurface.cpp
waylandcolormanagement/KisWaylandOutputColorInfo.cpp
waylandcolormanagement/KisWaylandSurfaceColorimetry.cpp
- waylandcolormanagement/KisWaylandSurfaceColorManager.cpp)
+ waylandcolormanagement/KisWaylandSurfaceColorManager.cpp
+ waylandcolormanagement/KisWaylandDebugInfoFetcher.cpp)
endif()
kis_add_library(kritaplatformpluginwayland MODULE ${kritaplatformpluginwayland_LIB_SRCS})
diff --git a/plugins/platforms/wayland/KritaPlatformPluginWayland.cpp b/plugins/platforms/wayland/KritaPlatformPluginWayland.cpp
index 8a6202906c..cc5f33f3a6 100644
--- a/plugins/platforms/wayland/KritaPlatformPluginWayland.cpp
+++ b/plugins/platforms/wayland/KritaPlatformPluginWayland.cpp
@@ -17,6 +17,7 @@
#include <waylandcolormanagement/KisWaylandSurfaceColorManager.h>
#include <waylandcolormanagement/KisWaylandOutputColorInfo.h>
#include <surfacecolormanagement/KisSurfaceColorManagementInfo.h>
+#include <waylandcolormanagement/KisWaylandDebugInfoFetcher.h>
#include <QWindow>
@@ -43,6 +44,37 @@ public:
bool surfaceColorManagedByOS() override {
return true;
}
+
+ QFuture<QString> debugReport() override {
+ QPromise<QString> promise;
+ promise.start();
+
+ std::shared_ptr<KisWaylandDebugInfoFetcher> infoFetcher(new KisWaylandDebugInfoFetcher());
+
+ if (infoFetcher->isReady()) {
+ promise.addResult(infoFetcher->report());
+ promise.finish();
+
+ return promise.future();
+ } else {
+ // wrap the info fetcher into the resulting lambda
+ QFuture<QString> result = promise.future().then(
+ [infoFetcher] (const QString &report) {
+ // a simple wrapping class that holds the fetcher until the
+ // result is reported or the future is destroyed
+ return report;
+ });
+
+ // move the promise into the handler of its completion signal
+ connect(infoFetcher.get(), &KisWaylandDebugInfoFetcher::sigDebugInfoReady,
+ infoFetcher.get(), [promise = std::move(promise)] (const QString &report) mutable {
+ promise.addResult(report);
+ promise.finish();
+ });
+
+ return result;
+ }
+ }
};
#endif /* KRITA_USE_SURFACE_COLOR_MANAGEMENT_API */
diff --git a/plugins/platforms/wayland/waylandcolormanagement/KisWaylandDebugInfoFetcher.cpp b/plugins/platforms/wayland/waylandcolormanagement/KisWaylandDebugInfoFetcher.cpp
new file mode 100644
index 0000000000..a8a98c9089
--- /dev/null
+++ b/plugins/platforms/wayland/waylandcolormanagement/KisWaylandDebugInfoFetcher.cpp
@@ -0,0 +1,140 @@
+/*
+ * SPDX-FileCopyrightText: 2025 Dmitry Kazakov <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "KisWaylandDebugInfoFetcher.h"
+
+#include <QScreen>
+#include <QTimer>
+#include <QPointer>
+
+#include <qpa/qplatformnativeinterface.h>
+
+#include "KisWaylandSurfaceColorManager.h"
+#include "KisWaylandAPIColorManager.h"
+
+ #include <QtAssert>
+ #include <kis_debug.h>
+
+KisWaylandDebugInfoFetcher::KisWaylandDebugInfoFetcher(QObject *parent)
+ : QObject(parent)
+{
+ m_waylandManager = KisWaylandSurfaceColorManager::getOrCreateGlobalWaylandManager();
+ connect(m_waylandManager.get(), &KisWaylandAPIColorManager::sigReadyChanged,
+ this, &KisWaylandDebugInfoFetcher::reinitialize);
+ reinitialize();
+}
+
+KisWaylandDebugInfoFetcher::~KisWaylandDebugInfoFetcher()
+{
+}
+
+bool KisWaylandDebugInfoFetcher::isReady() const
+{
+ return m_isReady;
+}
+
+QString KisWaylandDebugInfoFetcher::report() const
+{
+ return m_report;
+}
+
+void KisWaylandDebugInfoFetcher::reinitialize()
+{
+ if (m_waylandManager->isReady()) {
+ m_report = generateReport();
+ m_isReady = true;
+ Q_EMIT sigDebugInfoReady(m_report);
+ } else {
+ m_isReady = false;
+ m_report = "";
+ }
+}
+
+QString KisWaylandDebugInfoFetcher::generateReport()
+{
+ QString report;
+
+ QDebug s(&report);
+
+ s << "Wayland color management plugin report" << Qt::endl;
+ s << Qt::endl;
+
+ if (!m_waylandManager) {
+ s << "Wayland manager is not initialized." << Qt::endl;
+ return report;
+ }
+
+ s << "Supported Features:" << Qt::endl;
+ const std::map<QtWayland::wp_color_manager_v1::feature, QString> featureNames = {
+ {QtWayland::wp_color_manager_v1::feature_icc_v2_v4, "feature_icc_v2_v4"},
+ {QtWayland::wp_color_manager_v1::feature_parametric, "feature_parametric"},
+ {QtWayland::wp_color_manager_v1::feature_set_primaries, "feature_set_primaries"},
+ {QtWayland::wp_color_manager_v1::feature_set_tf_power, "feature_set_tf_power"},
+ {QtWayland::wp_color_manager_v1::feature_set_luminances, "feature_set_luminances"},
+ {QtWayland::wp_color_manager_v1::feature_set_mastering_display_primaries, "feature_set_mastering_display_primaries"},
+ {QtWayland::wp_color_manager_v1::feature_extended_target_volume, "feature_extended_target_volume"},
+ {QtWayland::wp_color_manager_v1::feature_windows_scrgb, "feature_windows_scrgb"}
+ };
+ for (const auto &[feature, name] : featureNames) {
+ s.noquote().nospace() << " " << name << ": " << (m_waylandManager->isFeatureSupported(feature) ? "yes" : "no") << Qt::endl;
+ }
+
+ s << Qt::endl;
+ s << "Supported Render Intents:" << Qt::endl;
+ const std::map<QtWayland::wp_color_manager_v1::render_intent, QString> intentNames = {
+ {QtWayland::wp_color_manager_v1::render_intent_perceptual, "render_intent_perceptual"},
+ {QtWayland::wp_color_manager_v1::render_intent_relative, "render_intent_relative"},
+ {QtWayland::wp_color_manager_v1::render_intent_saturation, "render_intent_saturation"},
+ {QtWayland::wp_color_manager_v1::render_intent_absolute, "render_intent_absolute"},
+ {QtWayland::wp_color_manager_v1::render_intent_relative_bpc, "render_intent_relative_bpc"}
+ };
+ for (const auto &[intent, name] : intentNames) {
+ s.noquote().nospace() << " " << name << ": " << (m_waylandManager->isIntentSupported(intent) ? "yes" : "no") << Qt::endl;
+ }
+
+ s << Qt::endl;
+ s << "Supported Transfer Functions:" << Qt::endl;
+ const std::map<QtWayland::wp_color_manager_v1::transfer_function, QString> tfNames = {
+ {QtWayland::wp_color_manager_v1::transfer_function_bt1886, "transfer_function_bt1886"},
+ {QtWayland::wp_color_manager_v1::transfer_function_gamma22, "transfer_function_gamma22"},
+ {QtWayland::wp_color_manager_v1::transfer_function_gamma28, "transfer_function_gamma28"},
+ {QtWayland::wp_color_manager_v1::transfer_function_st240, "transfer_function_st240"},
+ {QtWayland::wp_color_manager_v1::transfer_function_ext_linear, "transfer_function_ext_linear"},
+ {QtWayland::wp_color_manager_v1::transfer_function_log_100, "transfer_function_log_100"},
+ {QtWayland::wp_color_manager_v1::transfer_function_log_316, "transfer_function_log_316"},
+ {QtWayland::wp_color_manager_v1::transfer_function_xvycc, "transfer_function_xvycc"},
+ {QtWayland::wp_color_manager_v1::transfer_function_srgb, "transfer_function_srgb"},
+ {QtWayland::wp_color_manager_v1::transfer_function_ext_srgb, "transfer_function_ext_srgb"},
+ {QtWayland::wp_color_manager_v1::transfer_function_st2084_pq, "transfer_function_st2084_pq"},
+ {QtWayland::wp_color_manager_v1::transfer_function_st428, "transfer_function_st428"},
+ {QtWayland::wp_color_manager_v1::transfer_function_hlg, "transfer_function_hlg"}
+ };
+ for (const auto &[tf, name] : tfNames) {
+ s.noquote().nospace() << " " << name << ": " << (m_waylandManager->isTransferFunctionNamedSupported(tf) ? "yes" : "no") << Qt::endl;
+ }
+
+ s << Qt::endl;
+ s << "Supported Primaries:" << Qt::endl;
+ const std::map<QtWayland::wp_color_manager_v1::primaries, QString> primaryNames = {
+ {QtWayland::wp_color_manager_v1::primaries_srgb, "primaries_srgb"},
+ {QtWayland::wp_color_manager_v1::primaries_pal_m, "primaries_pal_m"},
+ {QtWayland::wp_color_manager_v1::primaries_pal, "primaries_pal"},
+ {QtWayland::wp_color_manager_v1::primaries_ntsc, "primaries_ntsc"},
+ {QtWayland::wp_color_manager_v1::primaries_generic_film, "primaries_generic_film"},
+ {QtWayland::wp_color_manager_v1::primaries_bt2020, "primaries_bt2020"},
+ {QtWayland::wp_color_manager_v1::primaries_cie1931_xyz, "primaries_cie1931_xyz"},
+ {QtWayland::wp_color_manager_v1::primaries_dci_p3, "primaries_dci_p3"},
+ {QtWayland::wp_color_manager_v1::primaries_display_p3, "primaries_display_p3"},
+ {QtWayland::wp_color_manager_v1::primaries_adobe_rgb, "primaries_adobe_rgb"}
+ };
+ for (const auto &[primary, name] : primaryNames) {
+ s.noquote().nospace() << " " << name << ": " << (m_waylandManager->isPrimariesNamedSupported(primary) ? "yes" : "no") << Qt::endl;
+ }
+
+ return report;
+}
+
+#include <moc_KisWaylandDebugInfoFetcher.cpp>
\ No newline at end of file
diff --git a/plugins/platforms/wayland/waylandcolormanagement/KisWaylandDebugInfoFetcher.h b/plugins/platforms/wayland/waylandcolormanagement/KisWaylandDebugInfoFetcher.h
new file mode 100644
index 0000000000..b7a7daf45e
--- /dev/null
+++ b/plugins/platforms/wayland/waylandcolormanagement/KisWaylandDebugInfoFetcher.h
@@ -0,0 +1,36 @@
+/*
+ * SPDX-FileCopyrightText: 2025 Dmitry Kazakov <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef KISWAYLANDDEBUGINFOFETCHER_H
+#define KISWAYLANDDEBUGINFOFETCHER_H
+
+#include <QObject>
+
+class KisWaylandAPIColorManager;
+
+class KisWaylandDebugInfoFetcher : public QObject
+{
+ Q_OBJECT
+public:
+ KisWaylandDebugInfoFetcher(QObject *parent = nullptr);
+ ~KisWaylandDebugInfoFetcher();
+
+ bool isReady() const;
+ QString report() const;
+
+private:
+ void reinitialize();
+ QString generateReport();
+
+Q_SIGNALS:
+ void sigDebugInfoReady(const QString &report);
+
+private:
+ std::shared_ptr<KisWaylandAPIColorManager> m_waylandManager;
+ bool m_isReady {false};
+ QString m_report;
+};
+
+#endif /* KISWAYLANDDEBUGINFOFETCHER_H */
\ No newline at end of file