| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
#ifndef KISWAYLANDSURFACECOLORMANAGER_H |
| 7 |
#define KISWAYLANDSURFACECOLORMANAGER_H |
| 8 |
|
| 9 |
#include <QPointer> |
| 10 |
|
| 11 |
#include <surfacecolormanagement/KisSurfaceColorManagerInterface.h> |
| 12 |
|
| 13 |
class KisWaylandAPIColorManager; |
| 14 |
class KisWaylandAPISurface; |
| 15 |
|
| 16 |
class KisWaylandSurfaceColorManager : public KisSurfaceColorManagerInterface |
| 17 |
{ |
| 18 |
Q_OBJECT |
| 19 |
public: |
| 20 |
KisWaylandSurfaceColorManager(QWindow *window, QObject *parent = nullptr); |
| 21 |
~KisWaylandSurfaceColorManager() override; |
| 22 |
|
| 23 |
bool isReady() const override; |
| 24 |
bool supportsSurfaceDescription(const KisSurfaceColorimetry::SurfaceDescription &desc) override; |
| 25 |
bool supportsRenderIntent(const KisSurfaceColorimetry::RenderIntent &intent) override; |
| 26 |
QFuture<bool> setSurfaceDescription(const KisSurfaceColorimetry::SurfaceDescription &desc, KisSurfaceColorimetry::RenderIntent intent) override; |
| 27 |
void unsetSurfaceDescription() override; |
| 28 |
std::optional<KisSurfaceColorimetry::SurfaceDescription> surfaceDescription() const override; |
| 29 |
std::optional<KisSurfaceColorimetry::RenderIntent> renderingIntent() const override; |
| 30 |
std::optional<KisSurfaceColorimetry::SurfaceDescription> preferredSurfaceDescription() const override; |
| 31 |
|
| 32 |
static std::shared_ptr<KisWaylandAPIColorManager> getOrCreateGlobalWaylandManager(); |
| 33 |
|
| 34 |
enum class WaylandSurfaceState { |
| 35 |
Disconnected = 0, |
| 36 |
Connected, |
| 37 |
WaylandWindowCreated, |
| 38 |
WaylandSurfaceCreated, |
| 39 |
APIFeedbackCreated, |
| 40 |
PreferredDescriptionReceived |
| 41 |
}; |
| 42 |
Q_ENUM(WaylandSurfaceState) |
| 43 |
|
| 44 |
private Q_SLOTS: |
| 45 |
void slotPreferredChanged(); |
| 46 |
|
| 47 |
void slotPlatformWindowCreated(); |
| 48 |
void slotPlatformWindowDestroyed(); |
| 49 |
|
| 50 |
void slotWaylandSurfaceCreated(); |
| 51 |
void slotWaylandSurfaceDestroyed(); |
| 52 |
|
| 53 |
private: |
| 54 |
void reinitialize(); |
| 55 |
void setReadyImpl(bool value); |
| 56 |
|
| 57 |
WaylandSurfaceState tryInitilize(); |
| 58 |
WaylandSurfaceState tryDeinitialize(std::optional<KisWaylandSurfaceColorManager::WaylandSurfaceState> targetState); |
| 59 |
|
| 60 |
private: |
| 61 |
WaylandSurfaceState m_currentState {WaylandSurfaceState::Disconnected}; |
| 62 |
std::shared_ptr<KisWaylandAPIColorManager> m_waylandManager; |
| 63 |
std::unique_ptr<KisWaylandAPISurface> m_surface; |
| 64 |
|
| 65 |
std::optional<KisSurfaceColorimetry::SurfaceDescription> m_currentDescription; |
| 66 |
std::optional<KisSurfaceColorimetry::RenderIntent> m_renderingIntent; |
| 67 |
std::optional<KisSurfaceColorimetry::SurfaceDescription> m_preferredDescription; |
| 68 |
|
| 69 |
bool m_isReady {false}; |
| 70 |
|
| 71 |
QMetaObject::Connection m_surfaceCreatedConnection; |
| 72 |
QMetaObject::Connection m_surfaceDestroyedConnection; |
| 73 |
QPointer<QObject> m_platformWindowStateDetector; |
| 74 |
}; |
| 75 |
|
| 76 |
#endif |