mirror of
https://github.com/hyprwm/Hyprland.git
synced 2026-08-24 02:24:14 -05:00
renderer/cm: Support wp-cm-v1 version 2 (#12817)
This commit is contained in:
+1
-1
@@ -246,7 +246,7 @@ set_source_files_properties(${CMAKE_SOURCE_DIR}/src/version.h PROPERTIES GENERAT
|
||||
|
||||
set(XKBCOMMON_MINIMUM_VERSION 1.11.0)
|
||||
set(WAYLAND_SERVER_MINIMUM_VERSION 1.22.91)
|
||||
set(WAYLAND_SERVER_PROTOCOLS_MINIMUM_VERSION 1.45)
|
||||
set(WAYLAND_SERVER_PROTOCOLS_MINIMUM_VERSION 1.47)
|
||||
set(LIBINPUT_MINIMUM_VERSION 1.28)
|
||||
|
||||
pkg_check_modules(
|
||||
|
||||
@@ -48,7 +48,7 @@ pkg_check_modules(
|
||||
IMPORTED_TARGET
|
||||
hyprutils>=0.8.0
|
||||
wayland-client
|
||||
wayland-protocols
|
||||
wayland-protocols>=1.47
|
||||
)
|
||||
|
||||
pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir)
|
||||
|
||||
@@ -822,6 +822,8 @@ CConfigManager::CConfigManager() {
|
||||
registerConfigVar("ecosystem:no_donation_nag", Hyprlang::INT{0});
|
||||
registerConfigVar("ecosystem:enforce_permissions", Hyprlang::INT{0});
|
||||
|
||||
registerConfigVar("experimental:wp_cm_1_2", Hyprlang::INT{0});
|
||||
|
||||
registerConfigVar("quirks:prefer_hdr", Hyprlang::INT{0});
|
||||
registerConfigVar("quirks:skip_non_kms_dmabuf_formats", Hyprlang::INT{0});
|
||||
|
||||
|
||||
@@ -2208,6 +2208,17 @@ namespace Config::Supplementary {
|
||||
.data = SConfigOptionDescription::SBoolData{.value = true},
|
||||
},
|
||||
|
||||
/*
|
||||
* Experimental
|
||||
*/
|
||||
|
||||
SConfigOptionDescription{
|
||||
.value = "experimental:wp_cm_1_2",
|
||||
.description = "Allow wp-cm-v1 version 2",
|
||||
.type = CONFIG_OPTION_BOOL,
|
||||
.data = SConfigOptionDescription::SBoolData{false},
|
||||
},
|
||||
|
||||
/*
|
||||
* Quirks
|
||||
*/
|
||||
|
||||
@@ -72,7 +72,7 @@ const Hyprgraphics::CMatrix3& CPrimaries::convertMatrix(const WP<const CPrimarie
|
||||
return primariesConversion[cacheKey];
|
||||
}
|
||||
|
||||
CImageDescription::CImageDescription(const SImageDescription& imageDescription, const uint32_t imageDescriptionId) :
|
||||
CImageDescription::CImageDescription(const SImageDescription& imageDescription, const uint64_t imageDescriptionId) :
|
||||
m_id(imageDescriptionId), m_imageDescription(imageDescription) {
|
||||
m_primariesId = CPrimaries::from(m_imageDescription.getPrimaries())->id();
|
||||
}
|
||||
@@ -87,7 +87,7 @@ PImageDescription CImageDescription::from(const SImageDescription& imageDescript
|
||||
return knownDescriptions.back();
|
||||
}
|
||||
|
||||
PImageDescription CImageDescription::from(const uint32_t imageDescriptionId) {
|
||||
PImageDescription CImageDescription::from(const uint64_t imageDescriptionId) {
|
||||
ASSERT(imageDescriptionId <= knownDescriptions.size());
|
||||
return knownDescriptions[imageDescriptionId - 1];
|
||||
}
|
||||
@@ -102,7 +102,7 @@ const SImageDescription& CImageDescription::value() const {
|
||||
return m_imageDescription;
|
||||
}
|
||||
|
||||
uint CImageDescription::id() const {
|
||||
uint64_t CImageDescription::id() const {
|
||||
return m_id;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,10 +65,16 @@ namespace NColorManagement {
|
||||
return sc<ePrimaries>(primaries);
|
||||
}
|
||||
inline wpColorManagerV1TransferFunction convertTransferFunction(eTransferFunction tf) {
|
||||
return sc<wpColorManagerV1TransferFunction>(tf);
|
||||
switch (tf) {
|
||||
case CM_TRANSFER_FUNCTION_SRGB: return WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_COMPOUND_POWER_2_4;
|
||||
default: return sc<wpColorManagerV1TransferFunction>(tf);
|
||||
}
|
||||
}
|
||||
inline eTransferFunction convertTransferFunction(wpColorManagerV1TransferFunction tf) {
|
||||
return sc<eTransferFunction>(tf);
|
||||
switch (tf) {
|
||||
case WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_COMPOUND_POWER_2_4: return CM_TRANSFER_FUNCTION_SRGB;
|
||||
default: return sc<eTransferFunction>(tf);
|
||||
}
|
||||
}
|
||||
|
||||
using SPCPRimaries = Hyprgraphics::SPCPRimaries;
|
||||
@@ -304,19 +310,19 @@ namespace NColorManagement {
|
||||
class CImageDescription {
|
||||
public:
|
||||
static WP<const CImageDescription> from(const SImageDescription& imageDescription);
|
||||
static WP<const CImageDescription> from(const uint32_t imageDescriptionId);
|
||||
static WP<const CImageDescription> from(const uint64_t imageDescriptionId);
|
||||
|
||||
WP<const CImageDescription> with(const SImageDescription::SPCLuminances& luminances) const;
|
||||
|
||||
const SImageDescription& value() const;
|
||||
uint32_t id() const;
|
||||
uint64_t id() const;
|
||||
|
||||
WP<const CPrimaries> getPrimaries() const;
|
||||
|
||||
private:
|
||||
CImageDescription(const SImageDescription& imageDescription, const uint imageDescriptionId);
|
||||
uint32_t m_id = 0;
|
||||
uint32_t m_primariesId = 0;
|
||||
CImageDescription(const SImageDescription& imageDescription, const uint64_t imageDescriptionId);
|
||||
uint64_t m_id = 0;
|
||||
uint m_primariesId = 0;
|
||||
SImageDescription m_imageDescription;
|
||||
};
|
||||
|
||||
|
||||
@@ -110,6 +110,7 @@ CProtocolManager::CProtocolManager() {
|
||||
|
||||
static const auto PENABLECM = CConfigValue<Hyprlang::INT>("render:cm_enabled");
|
||||
static const auto PDEBUGCM = CConfigValue<Hyprlang::INT>("debug:full_cm_proto");
|
||||
static const auto PCMV1_2 = CConfigValue<Hyprlang::INT>("experimental:wp_cm_1_2");
|
||||
|
||||
static const auto PENABLECT = CConfigValue<Hyprlang::INT>("render:commit_timing_enabled");
|
||||
|
||||
@@ -208,7 +209,7 @@ CProtocolManager::CProtocolManager() {
|
||||
PROTO::imageCopyCapture = makeUnique<CImageCopyCaptureProtocol>(&ext_image_copy_capture_manager_v1_interface, 1, "ImageCopyCapture");
|
||||
|
||||
if (*PENABLECM)
|
||||
PROTO::colorManagement = makeUnique<CColorManagementProtocol>(&wp_color_manager_v1_interface, 1, "ColorManagement", *PDEBUGCM);
|
||||
PROTO::colorManagement = makeUnique<CColorManagementProtocol>(&wp_color_manager_v1_interface, *PCMV1_2 ? 2 : 1, "ColorManagement", *PDEBUGCM);
|
||||
|
||||
// ! please read the top of this file before adding another protocol
|
||||
|
||||
|
||||
@@ -37,7 +37,12 @@ CColorManager::CColorManager(SP<CWpColorManagerV1> resource) : m_resource(resour
|
||||
m_resource->sendSupportedPrimariesNamed(WP_COLOR_MANAGER_V1_PRIMARIES_ADOBE_RGB);
|
||||
m_resource->sendSupportedPrimariesNamed(WP_COLOR_MANAGER_V1_PRIMARIES_CIE1931_XYZ);
|
||||
|
||||
m_resource->sendSupportedTfNamed(WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB);
|
||||
if (m_resource->version() == 1) {
|
||||
m_resource->sendSupportedTfNamed(WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB);
|
||||
m_resource->sendSupportedTfNamed(WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_SRGB);
|
||||
} else
|
||||
m_resource->sendSupportedTfNamed(WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_COMPOUND_POWER_2_4);
|
||||
|
||||
m_resource->sendSupportedTfNamed(WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_GAMMA22);
|
||||
m_resource->sendSupportedTfNamed(WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_GAMMA28);
|
||||
m_resource->sendSupportedTfNamed(WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_LINEAR);
|
||||
@@ -48,7 +53,6 @@ CColorManager::CColorManager(SP<CWpColorManagerV1> resource) : m_resource(resour
|
||||
m_resource->sendSupportedTfNamed(WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_LOG_100);
|
||||
m_resource->sendSupportedTfNamed(WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_LOG_316);
|
||||
m_resource->sendSupportedTfNamed(WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_XVYCC);
|
||||
m_resource->sendSupportedTfNamed(WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_SRGB);
|
||||
m_resource->sendSupportedTfNamed(WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST428);
|
||||
|
||||
m_resource->sendSupportedIntent(WP_COLOR_MANAGER_V1_RENDER_INTENT_PERCEPTUAL);
|
||||
@@ -57,6 +61,8 @@ CColorManager::CColorManager(SP<CWpColorManagerV1> resource) : m_resource(resour
|
||||
m_resource->sendSupportedIntent(WP_COLOR_MANAGER_V1_RENDER_INTENT_SATURATION);
|
||||
m_resource->sendSupportedIntent(WP_COLOR_MANAGER_V1_RENDER_INTENT_ABSOLUTE);
|
||||
m_resource->sendSupportedIntent(WP_COLOR_MANAGER_V1_RENDER_INTENT_RELATIVE_BPC);
|
||||
if (m_resource->version() > 1)
|
||||
m_resource->sendSupportedIntent(WP_COLOR_MANAGER_V1_RENDER_INTENT_ABSOLUTE_NO_ADAPTATION);
|
||||
}
|
||||
|
||||
m_resource->setDestroy([](CWpColorManagerV1* r) { LOGM(Log::TRACE, "Destroy WP_color_manager at {:x} (generated default)", (uintptr_t)r); });
|
||||
@@ -171,7 +177,32 @@ CColorManager::CColorManager(SP<CWpColorManagerV1> resource) : m_resource(resour
|
||||
RESOURCE->m_self = RESOURCE;
|
||||
RESOURCE->m_settings = SCRGB_IMAGE_DESCRIPTION;
|
||||
|
||||
RESOURCE->resource()->sendReady(RESOURCE->m_settings->id());
|
||||
RESOURCE->sendMaybeReady();
|
||||
});
|
||||
|
||||
m_resource->setGetImageDescription([](CWpColorManagerV1* r, uint32_t id, wl_resource* ref) {
|
||||
LOGM(Log::TRACE, "Get image description for reference={}, id={}", (uintptr_t)ref, id);
|
||||
|
||||
const auto OLD_RES = CColorManagementImageDescription::fromReference(ref);
|
||||
if (!OLD_RES) {
|
||||
OLD_RES->resource()->sendFailed(WP_IMAGE_DESCRIPTION_V1_CAUSE_UNSUPPORTED, "Not found");
|
||||
return;
|
||||
}
|
||||
|
||||
const auto RESOURCE = PROTO::colorManagement->m_imageDescriptions.emplace_back(
|
||||
makeShared<CColorManagementImageDescription>(makeShared<CWpImageDescriptionV1>(r->client(), r->version(), id), OLD_RES->m_allowGetInformation));
|
||||
|
||||
if UNLIKELY (!RESOURCE->good()) {
|
||||
r->noMemory();
|
||||
PROTO::colorManagement->m_imageDescriptions.pop_back();
|
||||
return;
|
||||
}
|
||||
|
||||
RESOURCE->m_self = RESOURCE;
|
||||
|
||||
RESOURCE->m_settings = OLD_RES->m_settings;
|
||||
|
||||
RESOURCE->sendMaybeReady();
|
||||
});
|
||||
|
||||
m_resource->setOnDestroy([this](CWpColorManagerV1* r) { PROTO::colorManagement->destroyResource(this); });
|
||||
@@ -216,7 +247,8 @@ CColorManagementOutput::CColorManagementOutput(SP<CWpColorManagementOutputV1> re
|
||||
RESOURCE->m_resource->sendFailed(WP_IMAGE_DESCRIPTION_V1_CAUSE_NO_OUTPUT, "No output");
|
||||
else {
|
||||
RESOURCE->m_settings = m_output->m_monitor->m_imageDescription;
|
||||
RESOURCE->m_resource->sendReady(RESOURCE->m_settings->id());
|
||||
|
||||
RESOURCE->sendMaybeReady();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -364,7 +396,7 @@ CColorManagementFeedbackSurface::CColorManagementFeedbackSurface(SP<CWpColorMana
|
||||
RESOURCE->m_self = RESOURCE;
|
||||
RESOURCE->m_settings = m_surface->getPreferredImageDescription();
|
||||
|
||||
RESOURCE->resource()->sendReady(RESOURCE->m_settings->id());
|
||||
RESOURCE->sendMaybeReady();
|
||||
});
|
||||
|
||||
m_resource->setGetPreferredParametric([this](CWpColorManagementSurfaceFeedbackV1* r, uint32_t id) {
|
||||
@@ -388,7 +420,13 @@ CColorManagementFeedbackSurface::CColorManagementFeedbackSurface(SP<CWpColorMana
|
||||
RESOURCE->m_settings = m_surface->getPreferredImageDescription();
|
||||
m_currentPreferredId = RESOURCE->m_settings->id();
|
||||
|
||||
RESOURCE->resource()->sendReady(m_currentPreferredId);
|
||||
if (!PROTO::colorManagement->m_debug && RESOURCE->m_settings->value().icc.present) {
|
||||
LOGM(Log::ERR, "FIXME: send ICC profile data");
|
||||
// r->error(WP_COLOR_MANAGER_V1_ERROR_UNSUPPORTED_FEATURE, "ICC profiles are not supported");
|
||||
// return;
|
||||
}
|
||||
|
||||
RESOURCE->sendMaybeReady();
|
||||
});
|
||||
|
||||
m_listeners.enter = m_surface->m_events.enter.listen([this](const auto& monitor) { onPreferredChanged(); });
|
||||
@@ -398,8 +436,14 @@ CColorManagementFeedbackSurface::CColorManagementFeedbackSurface(SP<CWpColorMana
|
||||
void CColorManagementFeedbackSurface::onPreferredChanged() {
|
||||
if (m_surface->m_enteredOutputs.size() == 1) {
|
||||
const auto newId = m_surface->getPreferredImageDescription()->id();
|
||||
if (m_currentPreferredId != newId)
|
||||
m_resource->sendPreferredChanged(newId);
|
||||
if (m_currentPreferredId != newId) {
|
||||
const uint32_t lo = sc<uint32_t>(newId & 0xFFFFFFFF);
|
||||
const uint32_t hi = sc<uint32_t>(newId >> 32);
|
||||
if (m_resource->version() > 1)
|
||||
m_resource->sendPreferredChanged2(hi, lo);
|
||||
else if (!hi)
|
||||
m_resource->sendPreferredChanged(lo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -447,7 +491,8 @@ CColorManagementIccCreator::CColorManagementIccCreator(SP<CWpImageDescriptionCre
|
||||
|
||||
RESOURCE->m_self = RESOURCE;
|
||||
RESOURCE->m_settings = CImageDescription::from(m_settings);
|
||||
RESOURCE->resource()->sendReady(RESOURCE->m_settings->id());
|
||||
|
||||
RESOURCE->sendMaybeReady();
|
||||
|
||||
PROTO::colorManagement->destroyResource(this);
|
||||
});
|
||||
@@ -509,7 +554,8 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SP<CWpImage
|
||||
|
||||
RESOURCE->m_self = RESOURCE;
|
||||
RESOURCE->m_settings = CImageDescription::from(m_settings);
|
||||
RESOURCE->resource()->sendReady(RESOURCE->m_settings->id());
|
||||
|
||||
RESOURCE->sendMaybeReady();
|
||||
|
||||
PROTO::colorManagement->destroyResource(this);
|
||||
});
|
||||
@@ -534,6 +580,7 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SP<CWpImage
|
||||
case WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_XVYCC: break;
|
||||
case WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_SRGB: break;
|
||||
case WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST428: break;
|
||||
case WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_COMPOUND_POWER_2_4: break;
|
||||
default: r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INVALID_TF, "Unsupported transfer function"); return;
|
||||
}
|
||||
|
||||
@@ -704,6 +751,11 @@ CColorManagementImageDescription::CColorManagementImageDescription(SP<CWpImageDe
|
||||
});
|
||||
}
|
||||
|
||||
SP<CColorManagementImageDescription> CColorManagementImageDescription::fromReference(wl_resource* res) {
|
||||
auto data = sc<CColorManagementImageDescription*>(sc<CWpImageDescriptionV1*>(wl_resource_get_user_data(res))->data());
|
||||
return data ? data->m_self.lock() : nullptr;
|
||||
}
|
||||
|
||||
bool CColorManagementImageDescription::good() {
|
||||
return m_resource->resource();
|
||||
}
|
||||
@@ -716,6 +768,22 @@ SP<CWpImageDescriptionV1> CColorManagementImageDescription::resource() {
|
||||
return m_resource;
|
||||
}
|
||||
|
||||
bool CColorManagementImageDescription::sendMaybeReady() {
|
||||
const uint32_t lo = sc<uint32_t>(m_settings->id() & 0xFFFFFFFF);
|
||||
const uint32_t hi = sc<uint32_t>(m_settings->id() >> 32);
|
||||
|
||||
if (m_resource->version() > 1)
|
||||
m_resource->sendReady2(hi, lo);
|
||||
else if (!hi)
|
||||
m_resource->sendReady(lo);
|
||||
else {
|
||||
m_resource->sendFailed(WP_IMAGE_DESCRIPTION_V1_CAUSE_LOW_VERSION, "id is too large");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CColorManagementImageDescriptionInfo::CColorManagementImageDescriptionInfo(SP<CWpImageDescriptionInfoV1> resource, const SImageDescription& settings_) :
|
||||
m_resource(resource), m_settings(settings_) {
|
||||
if UNLIKELY (!good())
|
||||
|
||||
@@ -87,7 +87,7 @@ class CColorManagementFeedbackSurface {
|
||||
SP<CWpColorManagementSurfaceFeedbackV1> m_resource;
|
||||
wl_client* m_client = nullptr;
|
||||
|
||||
uint32_t m_currentPreferredId = 0;
|
||||
uint64_t m_currentPreferredId = 0;
|
||||
|
||||
struct {
|
||||
CHyprSignalListener enter;
|
||||
@@ -154,20 +154,23 @@ class CColorManagementParametricCreator {
|
||||
class CColorManagementImageDescription {
|
||||
public:
|
||||
CColorManagementImageDescription(SP<CWpImageDescriptionV1> resource, bool allowGetInformation);
|
||||
static SP<CColorManagementImageDescription> fromReference(wl_resource* res);
|
||||
|
||||
bool good();
|
||||
wl_client* client();
|
||||
SP<CWpImageDescriptionV1> resource();
|
||||
bool good();
|
||||
wl_client* client();
|
||||
SP<CWpImageDescriptionV1> resource();
|
||||
bool sendMaybeReady();
|
||||
|
||||
WP<CColorManagementImageDescription> m_self;
|
||||
WP<CColorManagementImageDescription> m_self;
|
||||
|
||||
NColorManagement::PImageDescription m_settings;
|
||||
NColorManagement::PImageDescription m_settings;
|
||||
|
||||
private:
|
||||
SP<CWpImageDescriptionV1> m_resource;
|
||||
wl_client* m_client = nullptr;
|
||||
bool m_allowGetInformation = false;
|
||||
|
||||
friend class CColorManager;
|
||||
friend class CColorManagementOutput;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user