1
0
Fork 0
forked from wry/wry

Merge pull request #772 from mahkoh/jorth/coefrange

color-representation: advertise identity/full support
This commit is contained in:
mahkoh 2026-03-04 13:11:12 +01:00 committed by GitHub
commit 1e55d89cc9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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_STRAIGHT: u32 = 2;
pub const COEF_IDENTITY: u32 = 1;
pub const RANGE_FULL: u32 = 1;
impl WpColorRepresentationSurfaceV1 {
pub fn install(self: &Rc<Self>) -> Result<(), WpColorRepresentationSurfaceV1Error> {
if self.surface.color_representation_surface.is_some() {
@ -71,12 +74,15 @@ impl WpColorRepresentationSurfaceV1RequestHandler for WpColorRepresentationSurfa
req: SetCoefficientsAndRange,
_slf: &Rc<Self>,
) -> Result<(), Self::Error> {
Err(
WpColorRepresentationSurfaceV1Error::UnsupportedCoefficientsAndRange(
req.coefficients,
req.range,
),
)
if (req.coefficients, req.range) != (COEF_IDENTITY, RANGE_FULL) {
return Err(
WpColorRepresentationSurfaceV1Error::UnsupportedCoefficientsAndRange(
req.coefficients,
req.range,
),
);
}
Ok(())
}
fn set_chroma_location(

View file

@ -3,15 +3,15 @@ use {
client::{Client, ClientError},
globals::{Global, GlobalName},
ifs::wl_surface::wp_color_representation_surface_v1::{
AM_PREMULTIPLIED_ELECTRICAL, AM_PREMULTIPLIED_OPTICAL, AM_STRAIGHT,
WpColorRepresentationSurfaceV1, WpColorRepresentationSurfaceV1Error,
AM_PREMULTIPLIED_ELECTRICAL, AM_PREMULTIPLIED_OPTICAL, AM_STRAIGHT, COEF_IDENTITY,
RANGE_FULL, WpColorRepresentationSurfaceV1, WpColorRepresentationSurfaceV1Error,
},
leaks::Tracker,
object::{Object, Version},
wire::{
WpColorRepresentationManagerV1Id,
wp_color_representation_manager_v1::{
Destroy, Done, GetSurface, SupportedAlphaMode,
Destroy, Done, GetSurface, SupportedAlphaMode, SupportedCoefficientsAndRanges,
WpColorRepresentationManagerV1RequestHandler,
},
},
@ -70,6 +70,7 @@ impl WpColorRepresentationManagerV1 {
self.send_supported_alpha_mode(AM_PREMULTIPLIED_OPTICAL);
self.send_supported_alpha_mode(AM_STRAIGHT);
}
self.send_supported_coefficients_and_ranges(COEF_IDENTITY, RANGE_FULL);
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) {
self.client.event(Done { self_id: self.id });
}