1
0
Fork 0
forked from wry/wry

wp-color-management-v1: update to version 2

This commit is contained in:
Julian Orth 2025-12-18 16:51:57 +01:00
parent 5090b45918
commit 3e3cb3114c
12 changed files with 143 additions and 23 deletions

View file

@ -3,7 +3,10 @@ use {
client::{Client, ClientError},
cmm::cmm_description::ColorDescription,
ifs::{
color_management::wp_image_description_v1::WpImageDescriptionV1, wl_surface::WlSurface,
color_management::{
UNIQUE_CM_IDS_SINCE, wp_image_description_v1::WpImageDescriptionV1,
},
wl_surface::WlSurface,
},
leaks::Tracker,
object::{Object, Version},
@ -43,10 +46,18 @@ impl WpColorManagementSurfaceFeedbackV1 {
}
pub fn send_preferred_changed(&self, cd: &ColorDescription) {
self.client.event(PreferredChanged {
self_id: self.id,
identity: cd.id.raw() as u32,
});
let identity = cd.id.raw();
if self.version >= UNIQUE_CM_IDS_SINCE {
self.client.event(PreferredChanged2 {
self_id: self.id,
identity,
});
} else {
self.client.event(PreferredChanged {
self_id: self.id,
identity: identity as u32,
});
}
}
}

View file

@ -5,7 +5,7 @@ use {
ifs::{
color_management::{
FEATURE_EXTENDED_TARGET_VOLUME, FEATURE_SET_MASTERING_DISPLAY_PRIMARIES,
FEATURE_SET_TF_POWER,
FEATURE_SET_TF_POWER, SRGB_DEPRECATED_SINCE,
consts::{
FEATURE_PARAMETRIC, FEATURE_SET_LUMINANCES, FEATURE_SET_PRIMARIES,
FEATURE_WINDOWS_SCRGB, PRIMARIES_ADOBE_RGB, PRIMARIES_BT2020,
@ -90,8 +90,10 @@ impl WpColorManagerV1 {
self.send_supported_tf_named(TRANSFER_FUNCTION_EXT_LINEAR);
self.send_supported_tf_named(TRANSFER_FUNCTION_LOG_100);
self.send_supported_tf_named(TRANSFER_FUNCTION_LOG_316);
self.send_supported_tf_named(TRANSFER_FUNCTION_SRGB);
self.send_supported_tf_named(TRANSFER_FUNCTION_EXT_SRGB);
if self.version < SRGB_DEPRECATED_SINCE {
self.send_supported_tf_named(TRANSFER_FUNCTION_SRGB);
self.send_supported_tf_named(TRANSFER_FUNCTION_EXT_SRGB);
}
self.send_supported_tf_named(TRANSFER_FUNCTION_ST2084_PQ);
self.send_supported_tf_named(TRANSFER_FUNCTION_ST428);
self.send_supported_primaries_named(PRIMARIES_SRGB);
@ -249,6 +251,25 @@ impl WpColorManagerV1RequestHandler for WpColorManagerV1 {
obj.send_ready();
Ok(())
}
fn get_image_description(
&self,
req: GetImageDescription,
_slf: &Rc<Self>,
) -> Result<(), Self::Error> {
let desc = self.client.lookup(req.reference)?;
let obj = Rc::new(WpImageDescriptionV1 {
id: req.image_description,
client: self.client.clone(),
version: self.version,
tracker: Default::default(),
description: Some(desc.description.clone()),
});
track!(self.client, obj);
self.client.add_client_obj(&obj)?;
obj.send_ready();
Ok(())
}
}
global_base!(
@ -263,7 +284,7 @@ impl Global for WpColorManagerV1Global {
}
fn version(&self) -> u32 {
1
2
}
fn exposed(&self, state: &State) -> bool {

View file

@ -7,7 +7,7 @@ use {
cmm_primaries::{NamedPrimaries, Primaries},
},
ifs::color_management::{
MIN_LUM_MUL_INV, PRIMARIES_MUL_INV,
MIN_LUM_MUL_INV, PRIMARIES_MUL_INV, SRGB_DEPRECATED_SINCE,
consts::{
PRIMARIES_ADOBE_RGB, PRIMARIES_BT2020, PRIMARIES_CIE1931_XYZ, PRIMARIES_DCI_P3,
PRIMARIES_DISPLAY_P3, PRIMARIES_GENERIC_FILM, PRIMARIES_NTSC, PRIMARIES_PAL,
@ -116,8 +116,8 @@ impl WpImageDescriptionCreatorParamsV1RequestHandler for WpImageDescriptionCreat
TRANSFER_FUNCTION_EXT_LINEAR => Eotf::Linear,
TRANSFER_FUNCTION_LOG_100 => Eotf::Log100,
TRANSFER_FUNCTION_LOG_316 => Eotf::Log316,
TRANSFER_FUNCTION_SRGB => Eotf::Gamma22,
TRANSFER_FUNCTION_EXT_SRGB => Eotf::Gamma22,
TRANSFER_FUNCTION_SRGB if self.version < SRGB_DEPRECATED_SINCE => Eotf::Gamma22,
TRANSFER_FUNCTION_EXT_SRGB if self.version < SRGB_DEPRECATED_SINCE => Eotf::Gamma22,
TRANSFER_FUNCTION_ST2084_PQ => Eotf::St2084Pq,
TRANSFER_FUNCTION_ST428 => Eotf::St428,
_ => {

View file

@ -0,0 +1,48 @@
use {
crate::{
client::{Client, ClientError},
cmm::cmm_description::ColorDescription,
leaks::Tracker,
object::{Object, Version},
wire::{WpImageDescriptionReferenceV1Id, wp_image_description_reference_v1::*},
},
std::rc::Rc,
thiserror::Error,
};
#[expect(dead_code)]
pub struct WpImageDescriptionReferenceV1 {
pub id: WpImageDescriptionReferenceV1Id,
pub client: Rc<Client>,
pub tracker: Tracker<Self>,
pub description: Rc<ColorDescription>,
}
impl WpImageDescriptionReferenceV1RequestHandler for WpImageDescriptionReferenceV1 {
type Error = WpImageDescriptionReferenceV1Error;
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
self.client.remove_obj(self)?;
Ok(())
}
}
object_base! {
self = WpImageDescriptionReferenceV1;
version = Version(1);
}
impl Object for WpImageDescriptionReferenceV1 {}
dedicated_add_obj!(
WpImageDescriptionReferenceV1,
WpImageDescriptionReferenceV1Id,
wp_image_description_reference
);
#[derive(Debug, Error)]
pub enum WpImageDescriptionReferenceV1Error {
#[error(transparent)]
ClientError(Box<ClientError>),
}
efrom!(WpImageDescriptionReferenceV1Error, ClientError);

View file

@ -2,7 +2,9 @@ use {
crate::{
client::{Client, ClientError},
cmm::cmm_description::ColorDescription,
ifs::color_management::wp_image_description_info_v1::WpImageDescriptionInfoV1,
ifs::color_management::{
UNIQUE_CM_IDS_SINCE, wp_image_description_info_v1::WpImageDescriptionInfoV1,
},
leaks::Tracker,
object::{Object, Version},
wire::{WpImageDescriptionV1Id, wp_image_description_v1::*},
@ -29,10 +31,18 @@ impl WpImageDescriptionV1 {
}
pub fn send_ready(&self) {
self.client.event(Ready {
self_id: self.id,
identity: self.description.as_ref().unwrap().id.raw() as u32,
});
let identity = self.description.as_ref().unwrap().id.raw();
if self.version >= UNIQUE_CM_IDS_SINCE {
self.client.event(Ready2 {
self_id: self.id,
identity,
});
} else {
self.client.event(Ready {
self_id: self.id,
identity: identity as u32,
});
}
}
}