Krita Source Code Documentation
Loading...
Searching...
No Matches
KisWaylandOutputColorInfo Class Reference

#include <KisWaylandOutputColorInfo.h>

+ Inheritance diagram for KisWaylandOutputColorInfo:

Public Member Functions

bool isReady () const override
 
 KisWaylandOutputColorInfo (QObject *parent=nullptr)
 
std::optional< KisSurfaceColorimetry::SurfaceDescriptionoutputDescription (const QScreen *screen) const override
 
 ~KisWaylandOutputColorInfo () override
 
- Public Member Functions inherited from KisOutputColorInfoInterface
 KisOutputColorInfoInterface (QObject *parent=nullptr)
 
virtual ~KisOutputColorInfoInterface ()
 

Private Member Functions

bool checkIfAllReady () const
 
void initScreenConnection (QScreen *screen)
 
void reinitialize ()
 
void setReadyImpl (bool value)
 
void slotScreenAdded (QScreen *screen)
 
void slotScreenRemoved (QScreen *screen)
 

Private Attributes

bool m_isReady {false}
 
std::shared_ptr< KisWaylandAPIColorManagerm_waylandManager
 
std::unordered_map< const QScreen *, std::unique_ptr< KisWaylandAPIOutput > > m_waylandOutputs
 

Additional Inherited Members

- Signals inherited from KisOutputColorInfoInterface
void sigOutputDescriptionChanged (QScreen *screen, const KisSurfaceColorimetry::SurfaceDescription &desc)
 
void sigReadyChanged (bool isReady)
 
- Protected Attributes inherited from KisOutputColorInfoInterface
QWindow * m_window
 

Detailed Description

Definition at line 16 of file KisWaylandOutputColorInfo.h.

Constructor & Destructor Documentation

◆ KisWaylandOutputColorInfo()

KisWaylandOutputColorInfo::KisWaylandOutputColorInfo ( QObject * parent = nullptr)

Definition at line 24 of file KisWaylandOutputColorInfo.cpp.

26{
31
32 connect(qApp, &QGuiApplication::screenAdded, this, &KisWaylandOutputColorInfo::slotScreenAdded);
33 connect(qApp, &QGuiApplication::screenRemoved, this, &KisWaylandOutputColorInfo::slotScreenRemoved);
34}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
KisOutputColorInfoInterface(QObject *parent=nullptr)
void sigReadyChanged(bool value)
std::shared_ptr< KisWaylandAPIColorManager > m_waylandManager
static std::shared_ptr< KisWaylandAPIColorManager > getOrCreateGlobalWaylandManager()

References connect(), KisWaylandSurfaceColorManager::getOrCreateGlobalWaylandManager(), m_waylandManager, reinitialize(), KisWaylandAPIColorManager::sigReadyChanged(), slotScreenAdded(), and slotScreenRemoved().

◆ ~KisWaylandOutputColorInfo()

KisWaylandOutputColorInfo::~KisWaylandOutputColorInfo ( )
override

Definition at line 36 of file KisWaylandOutputColorInfo.cpp.

37{
38}

Member Function Documentation

◆ checkIfAllReady()

bool KisWaylandOutputColorInfo::checkIfAllReady ( ) const
private

Definition at line 48 of file KisWaylandOutputColorInfo.cpp.

49{
50 if (m_waylandOutputs.empty()) return false;
51
52 return std::find_if(m_waylandOutputs.begin(), m_waylandOutputs.end(),
53 [] (const auto &it) {
54 return !it.second->m_imageDescription->info.isReady();
55 }
56 ) == m_waylandOutputs.end();
57}
std::unordered_map< const QScreen *, std::unique_ptr< KisWaylandAPIOutput > > m_waylandOutputs

References m_waylandOutputs.

◆ initScreenConnection()

void KisWaylandOutputColorInfo::initScreenConnection ( QScreen * screen)
private

Definition at line 75 of file KisWaylandOutputColorInfo.cpp.

76{
77 auto waylandScreen = screen->nativeInterface<QNativeInterface::QWaylandScreen>();
78
79 // the screen may have no wayland screen if it is a fake placeholder screen
80 // that was created by Qt while compositor restart
81 if (!waylandScreen) return;
82
83 ::wl_output *output = waylandScreen->output();
84 ::wp_color_management_output_v1 *cmoutput = m_waylandManager->get_output(output);
85 Q_ASSERT(cmoutput);
86
87 auto outputObject = std::make_unique<KisWaylandAPIOutput>(cmoutput);
88 connect(outputObject.get(), &KisWaylandAPIOutput::outputImageDescriptionChanged, outputObject.get(), [this, screen, outputPtr = outputObject.get()]() {
89 auto desc = outputPtr->m_imageDescription->info.m_data;
90 Q_EMIT sigOutputDescriptionChanged(screen, desc.toSurfaceDescription());
91
92 setReadyImpl(checkIfAllReady());
93 });
94
95 m_waylandOutputs.insert_or_assign(screen, std::move(outputObject));
96}
void outputImageDescriptionChanged()

References connect(), m_waylandManager, m_waylandOutputs, and KisWaylandAPIOutput::outputImageDescriptionChanged().

◆ isReady()

bool KisWaylandOutputColorInfo::isReady ( ) const
overridevirtual
Returns
true when the interface is considered as "fully initialized", i.e. when all screen descriptions are ready.

Implements KisOutputColorInfoInterface.

Definition at line 120 of file KisWaylandOutputColorInfo.cpp.

121{
122 return m_isReady;
123}

References m_isReady.

◆ outputDescription()

std::optional< KisSurfaceColorimetry::SurfaceDescription > KisWaylandOutputColorInfo::outputDescription ( const QScreen * screen) const
overridevirtual
Returns
a color space description for the specified screen

When isReady() is set to false may or may not return std::nullopt, wait for sigReadyChanged() to make sure all screens are initialized.

Implements KisOutputColorInfoInterface.

Definition at line 125 of file KisWaylandOutputColorInfo.cpp.

126{
127 auto it = m_waylandOutputs.find(screen);
128 if (it == m_waylandOutputs.end()) return std::nullopt;
129
130 const auto &info = it->second->m_imageDescription->info;
131
132 if (!info.isReady()) {
133 return std::nullopt;
134 }
135
136 return info.m_data.toSurfaceDescription();
137}

References m_waylandOutputs.

◆ reinitialize()

void KisWaylandOutputColorInfo::reinitialize ( )
private

Definition at line 59 of file KisWaylandOutputColorInfo.cpp.

60{
61 m_waylandOutputs.clear();
62
63 if (!m_waylandManager->isReady()) {
64 setReadyImpl(false);
65 return;
66 }
67
68 for (QScreen *screen : qApp->screens()) {
70 }
71
73}
void initScreenConnection(QScreen *screen)

References checkIfAllReady(), initScreenConnection(), m_waylandManager, m_waylandOutputs, and setReadyImpl().

◆ setReadyImpl()

void KisWaylandOutputColorInfo::setReadyImpl ( bool value)
private

Definition at line 40 of file KisWaylandOutputColorInfo.cpp.

41{
42 if (value == m_isReady) return;
43
46}
float value(const T *src, size_t ch)
void sigReadyChanged(bool isReady)

References m_isReady, KisOutputColorInfoInterface::sigReadyChanged(), and value().

◆ slotScreenAdded()

void KisWaylandOutputColorInfo::slotScreenAdded ( QScreen * screen)
private

Definition at line 98 of file KisWaylandOutputColorInfo.cpp.

99{
100 if (!m_waylandManager->isActive()) {
101 return;
102 }
103
104 initScreenConnection(screen);
105
107}

References checkIfAllReady(), initScreenConnection(), m_waylandManager, and setReadyImpl().

◆ slotScreenRemoved()

void KisWaylandOutputColorInfo::slotScreenRemoved ( QScreen * screen)
private

Definition at line 109 of file KisWaylandOutputColorInfo.cpp.

110{
111 if (!m_waylandManager->isActive()) {
112 return;
113 }
114
115 m_waylandOutputs.erase(screen);
116
118}

References checkIfAllReady(), m_waylandManager, m_waylandOutputs, and setReadyImpl().

Member Data Documentation

◆ m_isReady

bool KisWaylandOutputColorInfo::m_isReady {false}
private

Definition at line 38 of file KisWaylandOutputColorInfo.h.

38{false};

◆ m_waylandManager

std::shared_ptr<KisWaylandAPIColorManager> KisWaylandOutputColorInfo::m_waylandManager
private

Definition at line 36 of file KisWaylandOutputColorInfo.h.

◆ m_waylandOutputs

std::unordered_map<const QScreen*, std::unique_ptr<KisWaylandAPIOutput> > KisWaylandOutputColorInfo::m_waylandOutputs
private

Definition at line 37 of file KisWaylandOutputColorInfo.h.


The documentation for this class was generated from the following files: