From 6787fe8933b54f9e68f123df457e502dee9be13a Mon Sep 17 00:00:00 2001 From: UjinT34 <41110182+UjinT34@users.noreply.github.com> Date: Wed, 26 Feb 2025 17:56:37 +0300 Subject: protocols: Support wp color management proto (#9444) Adds support for the recently merged w-p CM protocol alongside the (now deprecated) old CM WIP protocols --- src/protocols/ColorManagement.hpp | 101 ++++++++++++++++++++++++-------------- 1 file changed, 63 insertions(+), 38 deletions(-) (limited to 'src/protocols/ColorManagement.hpp') diff --git a/src/protocols/ColorManagement.hpp b/src/protocols/ColorManagement.hpp index 39e3f486..644b0a4d 100644 --- a/src/protocols/ColorManagement.hpp +++ b/src/protocols/ColorManagement.hpp @@ -4,8 +4,9 @@ #include #include #include "WaylandProtocol.hpp" +#include "helpers/Monitor.hpp" #include "protocols/core/Compositor.hpp" -#include "xx-color-management-v4.hpp" +#include "color-management-v1.hpp" #include "types/ColorManagement.hpp" class CColorManager; @@ -15,17 +16,17 @@ class CColorManagementProtocol; class CColorManager { public: - CColorManager(SP resource_); + CColorManager(SP resource); bool good(); private: - SP resource; + SP m_resource; }; class CColorManagementOutput { public: - CColorManagementOutput(SP resource_); + CColorManagementOutput(SP resource, WP monitor); bool good(); wl_client* client(); @@ -34,8 +35,9 @@ class CColorManagementOutput { WP imageDescription; private: - SP resource; + SP m_resource; wl_client* pClient = nullptr; + WP m_monitor; friend class CColorManagementProtocol; friend class CColorManagementImageDescription; @@ -44,35 +46,36 @@ class CColorManagementOutput { class CColorManagementSurface { public: CColorManagementSurface(SP surface_); // temporary interface for frog CM - CColorManagementSurface(SP resource_, SP surface_); + CColorManagementSurface(SP resource, SP surface_); - bool good(); - wl_client* client(); + bool good(); + wl_client* client(); - WP self; - WP surface; + WP self; + WP surface; - const SImageDescription& imageDescription(); - bool hasImageDescription(); - void setHasImageDescription(bool has); - const hdr_output_metadata& hdrMetadata(); - void setHDRMetadata(const hdr_output_metadata& metadata); - bool needsHdrMetadataUpdate(); + const NColorManagement::SImageDescription& imageDescription(); + bool hasImageDescription(); + void setHasImageDescription(bool has); + const hdr_output_metadata& hdrMetadata(); + void setHDRMetadata(const hdr_output_metadata& metadata); + bool needsHdrMetadataUpdate(); private: - SP resource; - wl_client* pClient = nullptr; - SImageDescription m_imageDescription; - bool m_hasImageDescription = false; - bool m_needsNewMetadata = false; - hdr_output_metadata m_hdrMetadata; - + SP m_resource; + wl_client* pClient = nullptr; + NColorManagement::SImageDescription m_imageDescription; + bool m_hasImageDescription = false; + bool m_needsNewMetadata = false; + hdr_output_metadata m_hdrMetadata; + + friend class CXXColorManagementSurface; friend class CFrogColorManagementSurface; }; class CColorManagementFeedbackSurface { public: - CColorManagementFeedbackSurface(SP resource_, SP surface_); + CColorManagementFeedbackSurface(SP resource, SP surface_); bool good(); wl_client* client(); @@ -81,7 +84,7 @@ class CColorManagementFeedbackSurface { WP surface; private: - SP resource; + SP m_resource; wl_client* pClient = nullptr; WP m_currentPreferred; @@ -89,16 +92,32 @@ class CColorManagementFeedbackSurface { friend class CColorManagementProtocol; }; +class CColorManagementIccCreator { + public: + CColorManagementIccCreator(SP resource); + + bool good(); + wl_client* client(); + + WP self; + + NColorManagement::SImageDescription settings; + + private: + SP m_resource; + wl_client* pClient = nullptr; +}; + class CColorManagementParametricCreator { public: - CColorManagementParametricCreator(SP resource_); + CColorManagementParametricCreator(SP resource); bool good(); wl_client* client(); WP self; - SImageDescription settings; + NColorManagement::SImageDescription settings; private: enum eValuesSet : uint32_t { // NOLINT @@ -112,25 +131,25 @@ class CColorManagementParametricCreator { PC_FALL = (1 << 7), }; - SP resource; + SP m_resource; wl_client* pClient = nullptr; uint32_t valuesSet = 0; // enum eValuesSet }; class CColorManagementImageDescription { public: - CColorManagementImageDescription(SP resource_, bool allowGetInformation = false); + CColorManagementImageDescription(SP resource, bool allowGetInformation = false); bool good(); wl_client* client(); - SP resource(); + SP resource(); WP self; - SImageDescription settings; + NColorManagement::SImageDescription settings; private: - SP m_resource; + SP m_resource; wl_client* pClient = nullptr; bool m_allowGetInformation = false; @@ -139,30 +158,32 @@ class CColorManagementImageDescription { class CColorManagementImageDescriptionInfo { public: - CColorManagementImageDescriptionInfo(SP resource_, const SImageDescription& settings_); + CColorManagementImageDescriptionInfo(SP resource, const NColorManagement::SImageDescription& settings_); bool good(); wl_client* client(); private: - SP m_resource; - wl_client* pClient = nullptr; - SImageDescription settings; + SP m_resource; + wl_client* pClient = nullptr; + NColorManagement::SImageDescription settings; }; class CColorManagementProtocol : public IWaylandProtocol { public: - CColorManagementProtocol(const wl_interface* iface, const int& ver, const std::string& name); + CColorManagementProtocol(const wl_interface* iface, const int& ver, const std::string& name, bool debug = false); virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id); - void onImagePreferredChanged(); + void onImagePreferredChanged(uint32_t preferredId); + void onMonitorImageDescriptionChanged(WP monitor); private: void destroyResource(CColorManager* resource); void destroyResource(CColorManagementOutput* resource); void destroyResource(CColorManagementSurface* resource); void destroyResource(CColorManagementFeedbackSurface* resource); + void destroyResource(CColorManagementIccCreator* resource); void destroyResource(CColorManagementParametricCreator* resource); void destroyResource(CColorManagementImageDescription* resource); @@ -170,16 +191,20 @@ class CColorManagementProtocol : public IWaylandProtocol { std::vector> m_vOutputs; std::vector> m_vSurfaces; std::vector> m_vFeedbackSurfaces; + std::vector> m_vIccCreators; std::vector> m_vParametricCreators; std::vector> m_vImageDescriptions; + bool m_debug = false; friend class CColorManager; friend class CColorManagementOutput; friend class CColorManagementSurface; friend class CColorManagementFeedbackSurface; + friend class CColorManagementIccCreator; friend class CColorManagementParametricCreator; friend class CColorManagementImageDescription; + friend class CXXColorManagementSurface; friend class CFrogColorManagementSurface; }; -- cgit v1.2.3