subsurface: Add width/height methods to SubsuraceBuffer

This is potentially useful.

Other properties are specific to shm/dmabuf, and not meaningful in
general.
This commit is contained in:
Ian Douglas Scott 2024-12-02 12:42:16 -08:00 committed by Ashley Wulber
parent 18f0521357
commit c7dd111ae8
No known key found for this signature in database
GPG key ID: 5216D4F46A90A820

View file

@ -158,6 +158,20 @@ impl SubsurfaceBuffer {
(subsurface_buffer, SubsurfaceBufferRelease(receiver))
}
pub fn width(&self) -> i32 {
match &*self.0.source {
BufferSource::Dma(dma) => dma.width,
BufferSource::Shm(shm) => shm.width,
}
}
pub fn height(&self) -> i32 {
match &*self.0.source {
BufferSource::Dma(dma) => dma.height,
BufferSource::Shm(shm) => shm.height,
}
}
// Behavior of `wl_buffer::released` is undefined if attached to multiple surfaces. To allow
// things like that, create a new `wl_buffer` each time.
fn create_buffer(