Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ Jay supports the following wayland protocols:
| wp_linux_drm_syncobj_manager_v1 | 1 | |
| wp_presentation | 2 | |
| wp_security_context_manager_v1 | 1 | |
| wp_single_pixel_buffer_manager_v1 | 1 | |
| wp_single_pixel_buffer_manager_v1 | 2 | |
| wp_tearing_control_manager_v1 | 1 | |
| wp_viewporter | 1 | |
| xdg_activation_v1 | 1 | |
Expand Down
1 change: 1 addition & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Implement cursor-shape-v1 version 2.
- Outputs can now optionally use the BT.2020/PQ color space.
- Implement ext-shell version 7.
- Implement single-pixel-buffer version 2.

# 1.9.1 (2025-02-13)

Expand Down
10 changes: 5 additions & 5 deletions src/ifs/wl_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub struct WlBuffer {
render_ctx_version: Cell<u32>,
pub storage: RefCell<Option<WlBufferStorage>>,
shm: bool,
pub color: Option<[u32; 4]>,
pub color: Option<[f32; 4]>,
width: i32,
height: i32,
pub tracker: Tracker<Self>,
Expand Down Expand Up @@ -130,10 +130,10 @@ impl WlBuffer {
pub fn new_single_pixel(
id: WlBufferId,
client: &Rc<Client>,
r: u32,
g: u32,
b: u32,
a: u32,
r: f32,
g: f32,
b: f32,
a: f32,
) -> Self {
Self {
id,
Expand Down
27 changes: 23 additions & 4 deletions src/ifs/wp_single_pixel_buffer_manager_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,32 @@ impl WpSinglePixelBufferManagerV1RequestHandler for WpSinglePixelBufferManagerV1
req: CreateU32RgbaBuffer,
_slf: &Rc<Self>,
) -> Result<(), Self::Error> {
let map = |c: u32| (c as f64 / u32::MAX as f64) as f32;
let buffer = Rc::new(WlBuffer::new_single_pixel(
req.id,
&self.client,
req.r,
req.g,
req.b,
req.a,
map(req.r),
map(req.g),
map(req.b),
map(req.a),
));
track!(self.client, buffer);
self.client.add_client_obj(&buffer)?;
Ok(())
}

fn create_f32_rgba_buffer(
&self,
req: CreateF32RgbaBuffer,
_slf: &Rc<Self>,
) -> Result<(), Self::Error> {
let buffer = Rc::new(WlBuffer::new_single_pixel(
req.id,
&self.client,
f32::from_bits(req.r),
f32::from_bits(req.g),
f32::from_bits(req.b),
f32::from_bits(req.a),
));
track!(self.client, buffer);
self.client.add_client_obj(&buffer)?;
Expand Down
2 changes: 1 addition & 1 deletion src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ impl Renderer<'_> {
Some(bounds) => rect.intersect(*bounds),
};
if !rect.is_empty() {
let color = Color::from_u32_premultiplied(
let color = Color::new_premultiplied(
cd.transfer_function,
color[0],
color[1],
Expand Down
19 changes: 0 additions & 19 deletions src/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,25 +193,6 @@ impl Color {
)
}

pub fn from_u32_premultiplied(
transfer_function: TransferFunction,
r: u32,
g: u32,
b: u32,
a: u32,
) -> Self {
fn to_f32(c: u32) -> f32 {
((c as f64) / (u32::MAX as f64)) as f32
}
Self::new_premultiplied(
transfer_function,
to_f32(r),
to_f32(g),
to_f32(b),
to_f32(a),
)
}

pub fn from_srgba_straight(r: u8, g: u8, b: u8, a: u8) -> Self {
let mut c = Self::new(TransferFunction::Srgb, to_f32(r), to_f32(g), to_f32(b));
if a < 255 {
Expand Down
8 changes: 8 additions & 0 deletions wire/wp_single_pixel_buffer_manager_v1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@ request create_u32_rgba_buffer {
b: u32,
a: u32,
}

request create_f32_rgba_buffer {
id: id(wl_buffer),
r: u32,
g: u32,
b: u32,
a: u32,
}