Krita Source Code Documentation
Loading...
Searching...
No Matches
KisMultiSurfaceStateManager.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2025 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
8
9#include <KisView.h>
10
13
15
16
20
24
25#if KRITA_USE_SURFACE_COLOR_MANAGEMENT_API
26void KisMultiSurfaceStateManager::setRootSurfaceInfoProxy(KisRootSurfaceInfoProxy *proxy)
27{
28 m_rootSurfaceInfoProxy = proxy;
29}
30#endif /* KRITA_USE_SURFACE_COLOR_MANAGEMENT_API */
31
33{
34 State state;
35 KisMultiSurfaceDisplayConfig &multiConfig = state.multiConfig;
36
37 state.isCanvasOpenGL = isCanvasOpenGL;
38
39 KisConfig cfg(true);
40
43 state.proofingConfig = proofingConfig;
44
45 if (KisOpenGLModeProber::instance()->useHDRMode()) {
46 multiConfig.canvasProfile = state.isCanvasOpenGL
50
51 } else if (KisPlatformPluginInterfaceFactory::instance()->surfaceColorManagedByOS()) {
52#if KRITA_USE_SURFACE_COLOR_MANAGEMENT_API
53 KIS_SAFE_ASSERT_RECOVER_NOOP(m_rootSurfaceInfoProxy);
54 if (m_rootSurfaceInfoProxy) {
55 multiConfig.canvasProfile = m_rootSurfaceInfoProxy->rootSurfaceProfile();
56 multiConfig.uiProfile = m_rootSurfaceInfoProxy->rootSurfaceProfile();
57 }
58#else
59 KIS_SAFE_ASSERT_RECOVER_NOOP(0 && "managed surface mode is active, but Krita is compiled without it!");
62#endif /* KRITA_USE_SURFACE_COLOR_MANAGEMENT_API */
63 } else {
64 const KoColorProfile *profile = cfg.displayProfile(screenId);
67 }
68
69 multiConfig.canvasProfile = profile;
70 multiConfig.uiProfile = profile;
71 }
72
74 multiConfig.isCanvasHDR = false;
75
76 return state;
77}
78
80 const KisDisplayConfig &canvasConfig) const
81{
87
88 // the surface format change should not change the conversion
89 // options of the surface
90 // TODO: downgrade to a warning!
91 KIS_SAFE_ASSERT_RECOVER_NOOP(oldState.multiConfig.options() == canvasConfig.options());
92
93 State newState = oldState;
94 KisMultiSurfaceDisplayConfig &newMultiConfig = newState.multiConfig;
95
96 newMultiConfig.canvasProfile = canvasConfig.profile;
97 newMultiConfig.setOptions(canvasConfig.options());
98 newMultiConfig.isCanvasHDR = canvasConfig.isHDR;
99
100 return newState;
101}
102
104 const KoColorProfile *uiProfile) const
105{
110
111 State newState = oldState;
112 newState.multiConfig.uiProfile = uiProfile;
113
114 return newState;
115}
116
118{
119 State newState = oldState;
120 newState.proofingConfig = proofingConfig;
121 newState.multiConfig.setOptions(
123 return newState;
124}
125
127 int screenId,
129 const KisDisplayConfig::Options &options) const
130{
131 State newState = oldState;
132 newState.surfaceMode = surfaceMode;
133 newState.optionsFromConfig = options;
134 newState.multiConfig.setOptions(
136
137 if (!KisOpenGLModeProber::instance()->useHDRMode() &&
138 !KisPlatformPluginInterfaceFactory::instance()->surfaceColorManagedByOS()) {
139
140 KisConfig cfg(true);
141 const KoColorProfile *profile = cfg.displayProfile(screenId);
142 KIS_SAFE_ASSERT_RECOVER(profile) {
144 }
145 newState.multiConfig.canvasProfile = profile;
146 newState.multiConfig.uiProfile = profile;
147 }
148
149 return newState;
150}
151
153{
154 if (KisOpenGLModeProber::instance()->useHDRMode() ||
155 KisPlatformPluginInterfaceFactory::instance()->surfaceColorManagedByOS()) {
156 return oldState;
157 }
158
159 return onConfigChanged(oldState, screenId, oldState.surfaceMode, oldState.optionsFromConfig);
160}
161
163{
164 if (proofingConfig && proofingConfig->displayFlags.testFlag(KoColorConversionTransformation::SoftProofing)) {
165 return { proofingConfig->determineDisplayIntent(options.first),
166 proofingConfig->determineDisplayFlags(options.second) };
167 }
168
169 return options;
170}
CanvasSurfaceMode canvasSurfaceColorSpaceManagementMode(bool defaultValue=false) const
const KoColorProfile * displayProfile(int screen) const
KisDisplayConfig This class keeps track of the color management configuration for image to display....
Options options() const
std::pair< KoColorConversionTransformation::Intent, KoColorConversionTransformation::ConversionFlags > Options
static Options optionsFromKisConfig(const KisConfig &cfg)
const KoColorProfile * profile
void setOptions(const Options &options)
const KoColorProfile * uiProfile
const KoColorProfile * canvasProfile
State createInitializingConfig(bool isCanvasOpenGL, int screenId, KisProofingConfigurationSP proofingConfig) const
KisDisplayConfig::Options overriddenWithProofingConfig(const KisDisplayConfig::Options &options, KisProofingConfigurationSP proofingConfig) const
State onCanvasSurfaceFormatChanged(const State &oldState, const KisDisplayConfig &canvasConfig) const
State onConfigChanged(const State &oldState, int screenId, KisConfig::CanvasSurfaceMode surfaceMode, const KisDisplayConfig::Options &options) const
State onScreenChanged(const State &oldState, int screenId) const
State onGuiSurfaceFormatChanged(const State &oldState, const KoColorProfile *uiProfile) const
State onProofingChanged(const State &oldState, KisProofingConfigurationSP proofingConfig) const
static KisOpenGLModeProber * instance()
const KoColorProfile * rootSurfaceColorProfile() const
static KisPlatformPluginInterfaceFactory * instance()
#define KIS_SAFE_ASSERT_RECOVER(cond)
Definition kis_assert.h:126
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130
static KoColorSpaceRegistry * instance()
const KoColorProfile * p709SRGBProfile() const