wp-color-management-v1: update to version 2
This commit is contained in:
parent
5090b45918
commit
3e3cb3114c
12 changed files with 143 additions and 23 deletions
|
|
@ -2,7 +2,10 @@ use {
|
|||
crate::{
|
||||
client::{Client, ClientError},
|
||||
ifs::{
|
||||
color_management::wp_image_description_v1::WpImageDescriptionV1,
|
||||
color_management::{
|
||||
wp_image_description_reference_v1::WpImageDescriptionReferenceV1,
|
||||
wp_image_description_v1::WpImageDescriptionV1,
|
||||
},
|
||||
ext_foreign_toplevel_handle_v1::ExtForeignToplevelHandleV1,
|
||||
ext_image_capture_source_v1::ExtImageCaptureSourceV1,
|
||||
ext_image_copy::ext_image_copy_capture_session_v1::ExtImageCopyCaptureSessionV1,
|
||||
|
|
@ -48,10 +51,11 @@ use {
|
|||
ExtImageCopyCaptureSessionV1Id, ExtWorkspaceGroupHandleV1Id, JayHeadErrorV1Id,
|
||||
JayOutputId, JayScreencastId, JayToplevelId, JayWorkspaceId, WlBufferId,
|
||||
WlDataSourceId, WlOutputId, WlPointerId, WlRegionId, WlRegistryId, WlSeatId,
|
||||
WlSurfaceId, WpDrmLeaseConnectorV1Id, WpImageDescriptionV1Id,
|
||||
WpLinuxDrmSyncobjTimelineV1Id, XdgPopupId, XdgPositionerId, XdgSurfaceId,
|
||||
XdgToplevelId, XdgWmBaseId, ZwlrDataControlSourceV1Id, ZwlrOutputHeadV1Id,
|
||||
ZwlrOutputModeV1Id, ZwpPrimarySelectionSourceV1Id, ZwpTabletToolV2Id,
|
||||
WlSurfaceId, WpDrmLeaseConnectorV1Id, WpImageDescriptionReferenceV1Id,
|
||||
WpImageDescriptionV1Id, WpLinuxDrmSyncobjTimelineV1Id, XdgPopupId, XdgPositionerId,
|
||||
XdgSurfaceId, XdgToplevelId, XdgWmBaseId, ZwlrDataControlSourceV1Id,
|
||||
ZwlrOutputHeadV1Id, ZwlrOutputModeV1Id, ZwpPrimarySelectionSourceV1Id,
|
||||
ZwpTabletToolV2Id,
|
||||
},
|
||||
},
|
||||
std::{cell::RefCell, rc::Rc},
|
||||
|
|
@ -94,6 +98,8 @@ pub struct Objects {
|
|||
pub ext_workspace_groups:
|
||||
CopyHashMap<ExtWorkspaceGroupHandleV1Id, Rc<ExtWorkspaceGroupHandleV1>>,
|
||||
pub wp_image_description: CopyHashMap<WpImageDescriptionV1Id, Rc<WpImageDescriptionV1>>,
|
||||
pub wp_image_description_reference:
|
||||
CopyHashMap<WpImageDescriptionReferenceV1Id, Rc<WpImageDescriptionReferenceV1>>,
|
||||
pub jay_head_errors: CopyHashMap<JayHeadErrorV1Id, Rc<JayHeadErrorV1>>,
|
||||
ids: RefCell<Vec<usize>>,
|
||||
}
|
||||
|
|
@ -136,6 +142,7 @@ impl Objects {
|
|||
ext_data_sources: Default::default(),
|
||||
ext_workspace_groups: Default::default(),
|
||||
wp_image_description: Default::default(),
|
||||
wp_image_description_reference: Default::default(),
|
||||
jay_head_errors: Default::default(),
|
||||
ids: RefCell::new(vec![]),
|
||||
}
|
||||
|
|
@ -182,6 +189,8 @@ impl Objects {
|
|||
self.ext_data_sources.clear();
|
||||
self.ext_workspace_groups.clear();
|
||||
self.jay_head_errors.clear();
|
||||
self.wp_image_description.clear();
|
||||
self.wp_image_description_reference.clear();
|
||||
}
|
||||
|
||||
pub fn id<T>(&self, client_data: &Client) -> Result<T, ClientError>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
use crate::object::Version;
|
||||
pub use consts::*;
|
||||
|
||||
pub mod wp_color_management_output_v1;
|
||||
|
|
@ -6,8 +7,12 @@ pub mod wp_color_manager_v1;
|
|||
pub mod wp_image_description_creator_icc_v1;
|
||||
pub mod wp_image_description_creator_params_v1;
|
||||
pub mod wp_image_description_info_v1;
|
||||
pub mod wp_image_description_reference_v1;
|
||||
pub mod wp_image_description_v1;
|
||||
|
||||
const UNIQUE_CM_IDS_SINCE: Version = Version(2);
|
||||
const SRGB_DEPRECATED_SINCE: Version = Version(2);
|
||||
|
||||
const PRIMARIES_MUL: f64 = 1_000_000.0;
|
||||
const PRIMARIES_MUL_INV: f64 = 1.0 / PRIMARIES_MUL;
|
||||
|
||||
|
|
@ -55,6 +60,7 @@ mod consts {
|
|||
pub const TRANSFER_FUNCTION_ST2084_PQ: u32 = 11;
|
||||
pub const TRANSFER_FUNCTION_ST428: u32 = 12;
|
||||
pub const TRANSFER_FUNCTION_HLG: u32 = 13;
|
||||
pub const TRANSFER_FUNCTION_COMPOUND_POWER_2_4: u32 = 14;
|
||||
|
||||
pub const CAUSE_LOW_VERSION: u32 = 0;
|
||||
pub const CAUSE_UNSUPPORTED: u32 = 1;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
_ => {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue