1
0
Fork 0
forked from wry/wry

color-representation: advertise identity/full support

This commit is contained in:
Julian Orth 2026-03-04 13:04:59 +01:00
parent 8e51c71224
commit 7873d1df1f
2 changed files with 24 additions and 9 deletions

View file

@ -30,6 +30,9 @@ pub const AM_PREMULTIPLIED_ELECTRICAL: u32 = 0;
pub const AM_PREMULTIPLIED_OPTICAL: u32 = 1; pub const AM_PREMULTIPLIED_OPTICAL: u32 = 1;
pub const AM_STRAIGHT: u32 = 2; pub const AM_STRAIGHT: u32 = 2;
pub const COEF_IDENTITY: u32 = 1;
pub const RANGE_FULL: u32 = 1;
impl WpColorRepresentationSurfaceV1 { impl WpColorRepresentationSurfaceV1 {
pub fn install(self: &Rc<Self>) -> Result<(), WpColorRepresentationSurfaceV1Error> { pub fn install(self: &Rc<Self>) -> Result<(), WpColorRepresentationSurfaceV1Error> {
if self.surface.color_representation_surface.is_some() { if self.surface.color_representation_surface.is_some() {
@ -71,12 +74,15 @@ impl WpColorRepresentationSurfaceV1RequestHandler for WpColorRepresentationSurfa
req: SetCoefficientsAndRange, req: SetCoefficientsAndRange,
_slf: &Rc<Self>, _slf: &Rc<Self>,
) -> Result<(), Self::Error> { ) -> Result<(), Self::Error> {
Err( if (req.coefficients, req.range) != (COEF_IDENTITY, RANGE_FULL) {
WpColorRepresentationSurfaceV1Error::UnsupportedCoefficientsAndRange( return Err(
req.coefficients, WpColorRepresentationSurfaceV1Error::UnsupportedCoefficientsAndRange(
req.range, req.coefficients,
), req.range,
) ),
);
}
Ok(())
} }
fn set_chroma_location( fn set_chroma_location(

View file

@ -3,15 +3,15 @@ use {
client::{Client, ClientError}, client::{Client, ClientError},
globals::{Global, GlobalName}, globals::{Global, GlobalName},
ifs::wl_surface::wp_color_representation_surface_v1::{ ifs::wl_surface::wp_color_representation_surface_v1::{
AM_PREMULTIPLIED_ELECTRICAL, AM_PREMULTIPLIED_OPTICAL, AM_STRAIGHT, AM_PREMULTIPLIED_ELECTRICAL, AM_PREMULTIPLIED_OPTICAL, AM_STRAIGHT, COEF_IDENTITY,
WpColorRepresentationSurfaceV1, WpColorRepresentationSurfaceV1Error, RANGE_FULL, WpColorRepresentationSurfaceV1, WpColorRepresentationSurfaceV1Error,
}, },
leaks::Tracker, leaks::Tracker,
object::{Object, Version}, object::{Object, Version},
wire::{ wire::{
WpColorRepresentationManagerV1Id, WpColorRepresentationManagerV1Id,
wp_color_representation_manager_v1::{ wp_color_representation_manager_v1::{
Destroy, Done, GetSurface, SupportedAlphaMode, Destroy, Done, GetSurface, SupportedAlphaMode, SupportedCoefficientsAndRanges,
WpColorRepresentationManagerV1RequestHandler, WpColorRepresentationManagerV1RequestHandler,
}, },
}, },
@ -70,6 +70,7 @@ impl WpColorRepresentationManagerV1 {
self.send_supported_alpha_mode(AM_PREMULTIPLIED_OPTICAL); self.send_supported_alpha_mode(AM_PREMULTIPLIED_OPTICAL);
self.send_supported_alpha_mode(AM_STRAIGHT); self.send_supported_alpha_mode(AM_STRAIGHT);
} }
self.send_supported_coefficients_and_ranges(COEF_IDENTITY, RANGE_FULL);
self.send_done(); self.send_done();
} }
@ -80,6 +81,14 @@ impl WpColorRepresentationManagerV1 {
}); });
} }
fn send_supported_coefficients_and_ranges(&self, coefficients: u32, range: u32) {
self.client.event(SupportedCoefficientsAndRanges {
self_id: self.id,
coefficients,
range,
});
}
fn send_done(&self) { fn send_done(&self) {
self.client.event(Done { self_id: self.id }); self.client.event(Done { self_id: self.id });
} }