subsurface: Remove width/height arguments to Subsurface::new

In an earlier version, this took a `WlBuffer`, so the width/height
arguments were needed. But since using the same `wl_buffer` multiple
times conflicted with `release` handling we instead accept
`SubsurfaceBuffer`, which stores the same height/width.
This commit is contained in:
Ian Douglas Scott 2024-12-02 13:41:35 -08:00 committed by Ashley Wulber
parent c7dd111ae8
commit e034001468
No known key found for this signature in database
GPG key ID: 5216D4F46A90A820

View file

@ -579,7 +579,6 @@ pub(crate) fn take_subsurfaces() -> Vec<SubsurfaceInfo> {
#[must_use]
pub struct Subsurface {
buffer_size: Size<f32>,
buffer: SubsurfaceBuffer,
width: Length,
height: Length,
@ -602,10 +601,12 @@ where
_renderer: &Renderer,
limits: &layout::Limits,
) -> layout::Node {
let raw_size =
limits.resolve(self.width, self.height, self.buffer_size);
let buffer_size =
Size::new(self.buffer.width() as f32, self.buffer.height() as f32);
let full_size = self.content_fit.fit(self.buffer_size, raw_size);
let raw_size = limits.resolve(self.width, self.height, buffer_size);
let full_size = self.content_fit.fit(buffer_size, raw_size);
let final_size = Size {
width: match self.width {
@ -644,13 +645,8 @@ where
}
impl Subsurface {
pub fn new(
buffer_width: u32,
buffer_height: u32,
buffer: SubsurfaceBuffer,
) -> Self {
pub fn new(buffer: SubsurfaceBuffer) -> Self {
Self {
buffer_size: Size::new(buffer_width as f32, buffer_height as f32),
buffer,
// Matches defaults of image widget
width: Length::Shrink,