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++
Implement a report of the color management status for Krita surfaces
Dmitry Kazakova085a156254b
diff --git a/krita/krita.action b/krita/krita.actionindex 47153d2602..f0738934b9 100644--- a/krita/krita.action+++ b/krita/krita.action@@ -182,6 +182,16 @@<isCheckable>false</isCheckable><statusTip/></Action>+ <Action name="color_management_report">+ <icon/>+ <text>Show color management information</text>+ <whatsThis/>+ <toolTip>Show color management information for the surface of the current image</toolTip>+ <iconText>Show system information for bug reports</iconText>+ <shortcut/>+ <isCheckable>false</isCheckable>+ <statusTip/>+ </Action><Action name="logcatdump"><icon/><text>Show Android log for bug reports.</text>diff --git a/krita/krita5.xmlgui b/krita/krita5.xmlguiindex 560dfe7d1f..6b16e34070 100644--- a/krita/krita5.xmlgui+++ b/krita/krita5.xmlgui@@ -415,6 +415,7 @@ xsi:schemaLocation="http://www.kde.org/standards/kxmlgui/1.0 http://www.kde.org<Action name="help_report_bug"/><Action name="buginfo"/><Action name="sysinfo"/>+ <Action name="color_management_report"/><Action name="logcatdump"/><Action name="crashlog"/><Separator/>diff --git a/libs/surfacecolormanagementapi/surfacecolormanagement/KisSurfaceColorimetry.cpp b/libs/surfacecolormanagementapi/surfacecolormanagement/KisSurfaceColorimetry.cppindex f1ed4913aa..c69848ed71 100644--- a/libs/surfacecolormanagementapi/surfacecolormanagement/KisSurfaceColorimetry.cpp+++ b/libs/surfacecolormanagementapi/surfacecolormanagement/KisSurfaceColorimetry.cpp@@ -151,6 +151,55 @@ QDebug operator<<(QDebug debug, const KisSurfaceColorimetry::RenderIntent &valuereturn debug;}+QString SurfaceDescription::makeTextReport() const+{+ QString report;+ QDebug str(&report);++ str << " Color Space:" << Qt::endl;++ if (std::holds_alternative<KisSurfaceColorimetry::NamedPrimaries>(this->colorSpace.primaries)) {+ str << " Primaries: " << std::get<KisSurfaceColorimetry::NamedPrimaries>(this->colorSpace.primaries) << Qt::endl;+ } else {+ auto col = std::get<KisSurfaceColorimetry::Colorimetry>(this->colorSpace.primaries);+ str << " Primaries: " << Qt::endl;+ str << " Red: " << col.red().toxy() << Qt::endl;+ str << " Green: " << col.green().toxy() << Qt::endl;+ str << " Blue: " << col.blue().toxy() << Qt::endl;+ str << " White: " << col.white().toxy() << Qt::endl;+ }++ if (std::holds_alternative<KisSurfaceColorimetry::NamedTransferFunction>(this->colorSpace.transferFunction)) {+ str << " Transfer Function: " << std::get<KisSurfaceColorimetry::NamedTransferFunction>(this->colorSpace.transferFunction) << Qt::endl;+ } else {+ const uint32_t rawValue = std::get<uint32_t>(this->colorSpace.transferFunction);+ str << " Transfer Function (gamma): " << rawValue << "(" << qreal(rawValue) / 10000.0 << ")" << Qt::endl;+ }++ if (this->colorSpace.luminance) {+ str << " Luminance: " << *this->colorSpace.luminance << Qt::endl;+ } else {+ str << " Luminance: " << "<none>" << Qt::endl;+ }++ if (this->masteringInfo) {+ str << " Mastering Info:" << Qt::endl;+ auto col = this->masteringInfo->primaries;+ str << " Primaries: " << Qt::endl;+ str << " Red: " << col.red().toxy() << Qt::endl;+ str << " Green: " << col.green().toxy() << Qt::endl;+ str << " Blue: " << col.blue().toxy() << Qt::endl;+ str << " White: " << col.white().toxy() << Qt::endl;+ str << " Luminance: " << this->masteringInfo->luminance << Qt::endl;+ str << " Max CLL: " << (this->masteringInfo->maxCll ? QString::number(*this->masteringInfo->maxCll) : "<none>") << Qt::endl;+ str << " Max FALL: " << (this->masteringInfo->maxFall ? QString::number(*this->masteringInfo->maxFall) : "<none>") << Qt::endl;+ } else {+ str << " Mastering Info: <none>" << Qt::endl;+ }++ return report;+}+} // namespace KisSurfaceColorimetry/* KISSURFACECOLORIMETRY_H */\ No newline at end of filediff --git a/libs/surfacecolormanagementapi/surfacecolormanagement/KisSurfaceColorimetry.h b/libs/surfacecolormanagementapi/surfacecolormanagement/KisSurfaceColorimetry.hindex 0d24fb233b..5a152ecbf7 100644--- a/libs/surfacecolormanagementapi/surfacecolormanagement/KisSurfaceColorimetry.h+++ b/libs/surfacecolormanagementapi/surfacecolormanagement/KisSurfaceColorimetry.h@@ -118,6 +118,8 @@ namespace KisSurfaceColorimetryreturn colorSpace == other.colorSpace &&masteringInfo == other.masteringInfo;}++ QString makeTextReport() const;};KRITASURFACECOLORMANAGEMENTAPI_EXPORT QDebug operator<<(QDebug debug, const NamedPrimaries &value);diff --git a/libs/ui/KisCanvasSurfaceColorSpaceManager.cpp b/libs/ui/KisCanvasSurfaceColorSpaceManager.cppindex 36c5134cd6..06caa7ce19 100644--- a/libs/ui/KisCanvasSurfaceColorSpaceManager.cpp+++ b/libs/ui/KisCanvasSurfaceColorSpaceManager.cpp@@ -6,6 +6,7 @@#include "KisCanvasSurfaceColorSpaceManager.h"+#include <KoColorProfile.h>#include <KoColorSpaceRegistry.h>#include <kis_config.h>@@ -33,6 +34,92 @@ KisCanvasSurfaceColorSpaceManager::~KisCanvasSurfaceColorSpaceManager(){}+QString KisCanvasSurfaceColorSpaceManager::colorManagementReport() const+{+ QString report;+ QDebug str(&report);++ str << "(canvas surface color manager)" << Qt::endl;+ str << Qt::endl;++ using KisSurfaceColorimetry::RenderIntent;+ using KisSurfaceColorimetry::SurfaceDescription;+ using KisSurfaceColorimetry::NamedPrimaries;+ using KisSurfaceColorimetry::NamedTransferFunction;++ RenderIntent preferredIntent = calculateConfigIntent(m_currentConfig);+ str << "Configured intent:" << preferredIntent << "supported:" << m_interface->supportsRenderIntent(preferredIntent) << Qt::endl;++ str << "Proofing intent:";+ if (m_proofingIntentOverride) {+ str << *m_proofingIntentOverride << "supported:" << m_interface->supportsRenderIntent(*m_proofingIntentOverride) << Qt::endl;+ } else {+ str << "<none>" << Qt::endl;+ }++ str << "Actual intent:";+ if (m_interface->renderingIntent()) {+ str << *m_interface->renderingIntent() << Qt::endl;+ } else {+ str << "<none>" << Qt::endl;+ }+ str << Qt::endl;++ str << "Active surface description:";+ if (m_interface->surfaceDescription()) {+ str << Qt::endl;+ str.noquote() << m_interface->surfaceDescription()->makeTextReport() << Qt::endl;+ } else {+ str << "<none>" << Qt::endl;+ }+ str << Qt::endl;++ str << "Selected Profile:";+ if (m_currentConfig.profile) {+ auto profile = m_currentConfig.profile;++ str << profile->name() << Qt::endl;+ str << " primaries:" << KoColorProfile::getColorPrimariesName(profile->getColorPrimaries()) << Qt::endl;+ str << " transfer: " << KoColorProfile::getTransferCharacteristicName(profile->getTransferCharacteristics()) << Qt::endl;+ str << Qt::endl;++ {+ auto colVec = profile->getColorantsxyY();+ KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(colVec.size() == 9, report);+ KisColorimetryUtils::xyY colR{colVec[0], colVec[1], colVec[2]};+ KisColorimetryUtils::xyY colG{colVec[3], colVec[4], colVec[5]};+ KisColorimetryUtils::xyY colB{colVec[6], colVec[7], colVec[8]};++ str << " red: " << colR << Qt::endl;+ str << " green:" << colG << Qt::endl;+ str << " blue: " << colB << Qt::endl;+ }++ {+ auto whiteVec = profile->getWhitePointxyY();+ KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(whiteVec.size() == 3, report);+ KisColorimetryUtils::xyY white{whiteVec[0], whiteVec[1], whiteVec[2]};++ str << " white: " << white << Qt::endl;+ str << Qt::endl;+ }++ } else {+ str << "<none>" << Qt::endl;+ }++ str << "Compositor preferred surface description:";+ if (m_interface->preferredSurfaceDescription()) {+ str << Qt::endl;+ str.noquote() << m_interface->preferredSurfaceDescription()->makeTextReport() << Qt::endl;+ } else {+ str << "<none>" << Qt::endl;+ }+ str << Qt::endl;++ return report;+}+KisSurfaceColorimetry::RenderIntent KisCanvasSurfaceColorSpaceManager::calculateConfigIntent(int kritaIntent, bool useBlackPointCompensation){using KisSurfaceColorimetry::RenderIntent;@@ -200,8 +287,12 @@ void KisCanvasSurfaceColorSpaceManager::reinitializeSurfaceDescription()requestedDescription.colorSpace.transferFunction = NamedTransferFunction::transfer_function_srgb;if (!m_interface->supportsSurfaceDescription(requestedDescription)) {- qWarning() << "WARNING: failed to find a suitable surface format for the compositor";- return; // TODO: extra signals?+ requestedDescription.colorSpace.transferFunction = NamedTransferFunction::transfer_function_gamma22;++ if (!m_interface->supportsSurfaceDescription(requestedDescription)) {+ qWarning() << "WARNING: failed to find a suitable surface format for the compositor";+ return; // TODO: extra signals?+ }}}diff --git a/libs/ui/KisCanvasSurfaceColorSpaceManager.h b/libs/ui/KisCanvasSurfaceColorSpaceManager.hindex 57191744c0..f262af1daa 100644--- a/libs/ui/KisCanvasSurfaceColorSpaceManager.h+++ b/libs/ui/KisCanvasSurfaceColorSpaceManager.h@@ -26,6 +26,8 @@ public:KisDisplayConfig displayConfig() const;+ QString colorManagementReport() const;+void setProofingConfiguration(KisProofingConfigurationSP proofingConfig);Q_SIGNALS:diff --git a/libs/ui/KisMainWindow.cpp b/libs/ui/KisMainWindow.cppindex 03d483f3d5..29993e4d0d 100644--- a/libs/ui/KisMainWindow.cpp+++ b/libs/ui/KisMainWindow.cpp@@ -3244,4 +3244,15 @@ const KoColorProfile* KisMainWindow::managedSurfaceProfile() const#endif}+QString KisMainWindow::colorManagementReport() const+{+#if KRITA_USE_SURFACE_COLOR_MANAGEMENT_API+ return d->surfaceColorSpaceManager ?+ d->surfaceColorSpaceManager->colorManagementReport() :+ QString("Surface color management is not supported on this platform");+#else+ return "Surface color management is disabled";+#endif+}+#include <moc_KisMainWindow.cpp>diff --git a/libs/ui/KisMainWindow.h b/libs/ui/KisMainWindow.hindex d79a169d49..e4d26a31f9 100644--- a/libs/ui/KisMainWindow.h+++ b/libs/ui/KisMainWindow.h@@ -194,6 +194,13 @@ public:*/const KoColorProfile* managedSurfaceProfile() const;+ /**+ * Return user-facing information about color management status of the+ * main window surface. The information is intentionally left untranslated,+ * since it is supposed to be used for bugreports.+ */+ QString colorManagementReport() const;+Q_SIGNALS:/**diff --git a/libs/ui/KisSRGBSurfaceColorSpaceManager.cpp b/libs/ui/KisSRGBSurfaceColorSpaceManager.cppindex b5355617ec..90488feed2 100644--- a/libs/ui/KisSRGBSurfaceColorSpaceManager.cpp+++ b/libs/ui/KisSRGBSurfaceColorSpaceManager.cpp@@ -25,6 +25,49 @@ KisSRGBSurfaceColorSpaceManager::~KisSRGBSurfaceColorSpaceManager(){}+QString KisSRGBSurfaceColorSpaceManager::colorManagementReport() const+{+ QString report;+ QDebug str(&report);++ str << "(sRGB surface color manager)" << Qt::endl;+ str << Qt::endl;++ using KisSurfaceColorimetry::RenderIntent;+ using KisSurfaceColorimetry::SurfaceDescription;+ using KisSurfaceColorimetry::NamedPrimaries;+ using KisSurfaceColorimetry::NamedTransferFunction;++ RenderIntent preferredIntent = calculateConfigIntent();+ str << "Requested intent:" << preferredIntent << "supported:" << m_interface->supportsRenderIntent(preferredIntent) << Qt::endl;+ str << "Actual intent:";+ if (m_interface->renderingIntent()) {+ str << *m_interface->renderingIntent() << Qt::endl;+ } else {+ str << "<none>" << Qt::endl;+ }+ str << Qt::endl;++ str << "Active surface description:";+ if (m_interface->surfaceDescription()) {+ str << Qt::endl;+ str.noquote() << m_interface->surfaceDescription()->makeTextReport() << Qt::endl;+ } else {+ str << "<none>" << Qt::endl;+ }+ str << Qt::endl;++ str << "Compositor preferred surface description:";+ if (m_interface->preferredSurfaceDescription()) {+ str << Qt::endl;+ str.noquote() << m_interface->preferredSurfaceDescription()->makeTextReport() << Qt::endl;+ } else {+ str << "<none>" << Qt::endl;+ }++ return report;+}+KisSurfaceColorimetry::RenderIntent KisSRGBSurfaceColorSpaceManager::calculateConfigIntent() {using KisSurfaceColorimetry::RenderIntent;@@ -88,6 +131,11 @@ void KisSRGBSurfaceColorSpaceManager::reinitializeSurfaceDescription() {preferredDescription.colorSpace.primaries = NamedPrimaries::primaries_srgb;preferredDescription.colorSpace.transferFunction = NamedTransferFunction::transfer_function_srgb;++ if (!m_interface->supportsSurfaceDescription(preferredDescription)) {+ preferredDescription.colorSpace.transferFunction = NamedTransferFunction::transfer_function_gamma22;+ }+if (m_interface->supportsSurfaceDescription(preferredDescription)) {auto future = m_interface->setSurfaceDescription(preferredDescription, preferredIntent);future.then([] (QFuture<bool> result) {diff --git a/libs/ui/KisSRGBSurfaceColorSpaceManager.h b/libs/ui/KisSRGBSurfaceColorSpaceManager.hindex 29c7ea30a3..751ec8876a 100644--- a/libs/ui/KisSRGBSurfaceColorSpaceManager.h+++ b/libs/ui/KisSRGBSurfaceColorSpaceManager.h@@ -20,6 +20,8 @@ public:KisSRGBSurfaceColorSpaceManager(KisSurfaceColorManagerInterface *interface, QObject *parent = nullptr);~KisSRGBSurfaceColorSpaceManager();+ QString colorManagementReport() const;+protected:static KisSurfaceColorimetry::RenderIntent calculateConfigIntent();diff --git a/libs/ui/canvas/kis_canvas2.cpp b/libs/ui/canvas/kis_canvas2.cppindex f9c282ec78..43cf1dc777 100644--- a/libs/ui/canvas/kis_canvas2.cpp+++ b/libs/ui/canvas/kis_canvas2.cpp@@ -1539,3 +1539,14 @@ KisInputActionGroupsMaskInterface::SharedInterface KisCanvas2::inputActionGroups{return m_d->inputActionGroupsMaskInterface;}++QString KisCanvas2::colorManagementReport() const+{+#if KRITA_USE_SURFACE_COLOR_MANAGEMENT_API+ return m_d->surfaceColorManager ?+ m_d->surfaceColorManager->colorManagementReport() :+ QString("Surface color management is not supported on this platform");+#else+ return "Surface color management is disabled";+#endif+}diff --git a/libs/ui/canvas/kis_canvas2.h b/libs/ui/canvas/kis_canvas2.hindex c8472785c1..5fad6cc6cb 100644--- a/libs/ui/canvas/kis_canvas2.h+++ b/libs/ui/canvas/kis_canvas2.h@@ -214,6 +214,14 @@ public: // KisCanvas2 methods* @return a reference to alter this canvas' input action groups mask*/KisInputActionGroupsMaskInterface::SharedInterface inputActionGroupsMaskInterface();++ /**+ * Return user-facing information about color management status of the+ * main window surface. The information is intentionally left untranslated,+ * since it is supposed to be used for bugreports.+ */+ QString colorManagementReport() const;+Q_SIGNALS:void sigCanvasEngineChanged();diff --git a/plugins/extensions/buginfo/CMakeLists.txt b/plugins/extensions/buginfo/CMakeLists.txtindex f4c80f7841..a18bad1fb6 100644--- a/plugins/extensions/buginfo/CMakeLists.txt+++ b/plugins/extensions/buginfo/CMakeLists.txt@@ -13,6 +13,10 @@ if (WIN32 OR ANDROID)set(kritabuginfo_SOURCES ${kritabuginfo_SOURCES} DlgCrashLog.cpp)endif()+if (KRITA_USE_SURFACE_COLOR_MANAGEMENT_API)+ set(kritabuginfo_SOURCES ${kritabuginfo_SOURCES} DlgColorManagementInfo.cpp)+endif()+ki18n_wrap_ui(kritabuginfo_SOURCES wdg_buginfo.ui )kis_add_library(kritabuginfo MODULE ${kritabuginfo_SOURCES})diff --git a/plugins/extensions/buginfo/DlgColorManagementInfo.cpp b/plugins/extensions/buginfo/DlgColorManagementInfo.cppnew file mode 100644index 0000000000..c6cab8049d--- /dev/null+++ b/plugins/extensions/buginfo/DlgColorManagementInfo.cpp@@ -0,0 +1,74 @@+/*+ * SPDX-FileCopyrightText: 2025 Dmitry Kazakov <[email protected]>+ *+ * SPDX-License-Identifier: GPL-2.0-or-later+ */++#include "DlgColorManagementInfo.h"+#include <QStandardPaths>++#include <KisMainWindow.h>+++DlgColorManagementInfo::DlgColorManagementInfo(QWidget *parent)+ : DlgBugInfo(parent)+{+ initialize();+}++QString DlgColorManagementInfo::originalFileName()+{+ return "";+}++QString DlgColorManagementInfo::defaultNewFileName()+{+ return "KritaColorManagementInformation.txt";+}++QString DlgColorManagementInfo::captionText()+{+ return i18nc("Caption of the dialog with color management information for bug reports", "Krita Color Management Information: please paste this information to the bug report");+}++QString DlgColorManagementInfo::replacementWarningText()+{+ qFatal("not used");+ return "";+}++#include <KisViewManager.h>+#include <KisDocument.h>+#include <kis_canvas2.h>++QString DlgColorManagementInfo::infoText(QSettings& kritarc)+{+ Q_UNUSED(kritarc)++ QString report;+ QTextStream s(&report);++ s << "Main Window" << Qt::endl;+ s << "===" << Qt::endl;+ s << Qt::endl;++ KisMainWindow *mainWindow = qobject_cast<KisMainWindow*>(parent());+ s << mainWindow->colorManagementReport();++ if (mainWindow->viewManager()->document()) {+ auto *doc = mainWindow->viewManager()->document();+ auto *canvas = mainWindow->viewManager()->canvasBase();++ s << "Document: " << doc->objectName() << " path: " << doc->localFilePath() << Qt::endl;+ s << "===" << Qt::endl;+ s << Qt::endl;++ s << canvas->colorManagementReport();+ }++ return report;+}++DlgColorManagementInfo::~DlgColorManagementInfo()+{+}diff --git a/plugins/extensions/buginfo/DlgColorManagementInfo.h b/plugins/extensions/buginfo/DlgColorManagementInfo.hnew file mode 100644index 0000000000..0dc93d82b1--- /dev/null+++ b/plugins/extensions/buginfo/DlgColorManagementInfo.h@@ -0,0 +1,32 @@+/*+ * SPDX-FileCopyrightText: 2025 Dmitry Kazakov <[email protected]>+ *+ * SPDX-License-Identifier: GPL-2.0-or-later+ */++#ifndef DLG_COLORMANAGEMENTINFO_H+#define DLG_COLORMANAGEMENTINFO_H++#include <KoDialog.h>+#include "dlg_buginfo.h"+++class QSettings;++class DlgColorManagementInfo: public DlgBugInfo+{+ Q_OBJECT+public:+ DlgColorManagementInfo(QWidget * parent = 0);+ ~DlgColorManagementInfo() override;++ QString defaultNewFileName() override;+ QString originalFileName() override;++public:+ QString replacementWarningText() override;+ QString captionText() override;+ QString infoText(QSettings& kritarc) override;+};++#endif // DLG_COLORMANAGEMENTINFO_Hdiff --git a/plugins/extensions/buginfo/buginfo.cpp b/plugins/extensions/buginfo/buginfo.cppindex 61666366da..faa7158fdd 100644--- a/plugins/extensions/buginfo/buginfo.cpp+++ b/plugins/extensions/buginfo/buginfo.cpp@@ -25,8 +25,11 @@#include "DlgCrashLog.h"#endif-K_PLUGIN_FACTORY_WITH_JSON(BugInfoFactory, "kritabuginfo.json", registerPlugin<BugInfo>();)+#if KRITA_USE_SURFACE_COLOR_MANAGEMENT_API+#include "DlgColorManagementInfo.h"+#endif+K_PLUGIN_FACTORY_WITH_JSON(BugInfoFactory, "kritabuginfo.json", registerPlugin<BugInfo>();)BugInfo::BugInfo(QObject *parent, const QVariantList &)@@ -37,6 +40,11 @@ BugInfo::BugInfo(QObject *parent, const QVariantList &)connect(actionBug, SIGNAL(triggered()), this, SLOT(slotKritaLog()));connect(actionSys, SIGNAL(triggered()), this, SLOT(slotSysInfo()));+#if KRITA_USE_SURFACE_COLOR_MANAGEMENT_API+ KisAction *actionColorManagement = createAction("color_management_report");+ connect(actionColorManagement, SIGNAL(triggered()), this, SLOT(slotColorManagement()));+#endif+#ifdef Q_OS_ANDROIDKisAction *actionLogcatdump = createAction("logcatdump");connect(actionLogcatdump, SIGNAL(triggered()), this, SLOT(slotDumpLogcat()));@@ -81,4 +89,12 @@ void BugInfo::slotCrashLog()}#endif+#if KRITA_USE_SURFACE_COLOR_MANAGEMENT_API+void BugInfo::slotColorManagement()+{+ DlgColorManagementInfo dlg(viewManager()->mainWindowAsQWidget());+ dlg.exec();+}+#endif+#include "buginfo.moc"diff --git a/plugins/extensions/buginfo/buginfo.h b/plugins/extensions/buginfo/buginfo.hindex b353f111cc..94039ffe3d 100644--- a/plugins/extensions/buginfo/buginfo.h+++ b/plugins/extensions/buginfo/buginfo.h@@ -9,6 +9,7 @@#include <QVariant>#include <KisActionPlugin.h>+#include <config-use-surface-color-management-api.h>class KUndo2MagicString;@@ -31,6 +32,10 @@ public Q_SLOTS:#if defined(Q_OS_WIN) || defined(Q_OS_ANDROID)void slotCrashLog();#endif++#if KRITA_USE_SURFACE_COLOR_MANAGEMENT_API+ void slotColorManagement();+#endif};#endif // BUGINFO_Hdiff --git a/plugins/extensions/buginfo/dlg_buginfo.h b/plugins/extensions/buginfo/dlg_buginfo.hindex d7bbd682e7..12e7b67329 100644--- a/plugins/extensions/buginfo/dlg_buginfo.h+++ b/plugins/extensions/buginfo/dlg_buginfo.h@@ -38,7 +38,8 @@ public:virtual QString originalFileName() = 0;virtual QString captionText() = 0;virtual QString replacementWarningText() = 0;- QString infoText(QSettings& kritarc);++ virtual QString infoText(QSettings& kritarc);QString basicSystemInformationReplacementText();