1
0
Fork 0
forked from wry/wry

renderer: draw surface at full size unconditionally w/ edge clamping

This commit is contained in:
atagen 2026-04-07 20:05:14 +10:00
parent 5657f45668
commit 7aea0095e9
4 changed files with 39 additions and 5 deletions

View file

@ -30,6 +30,7 @@ pub struct Renderer<'a> {
pub logical_extents: Rect,
pub pixel_extents: Rect,
pub icons: Option<Rc<SizedIcons>>,
pub stretch: Option<(i32, i32)>,
}
impl Renderer<'_> {
@ -397,9 +398,15 @@ impl Renderer<'_> {
let body = mb.move_(x, y);
let body = self.base.scale_rect(body);
let content = container.mono_content.get();
self.stretch = if content.width() != mb.width() || content.height() != mb.height() {
Some(self.base.scale_point(mb.width(), mb.height()))
} else {
None
};
child
.node
.node_render(self, x + content.x1(), y + content.y1(), Some(&body));
self.stretch = None;
} else {
let gap = self.state.theme.sizes.gap.get();
let (srgb_srgb, bw, border_color, focused_border_color, tpuh) = if gap != 0 {
@ -466,12 +473,18 @@ impl Renderer<'_> {
self.base.fill_boxes2(&frame_rects, c, srgb, perceptual, x, y);
}
}
let content = child.content.get();
self.stretch = if content.width() != body.width() || content.height() != body.height() {
Some(self.base.scale_point(body.width(), body.height()))
} else {
None
};
let body = body.move_(x, y);
let body = self.base.scale_rect(body);
let content = child.content.get();
child
.node
.node_render(self, x + content.x1(), y + content.y1(), Some(&body));
self.stretch = None;
}
}
@ -546,6 +559,7 @@ impl Renderer<'_> {
self.render_surface_scaled(surface, x, y, None, bounds, false);
}
pub fn render_surface_scaled(
&mut self,
surface: &WlSurface,
@ -555,6 +569,7 @@ impl Renderer<'_> {
bounds: Option<&Rect>,
is_subsurface: bool,
) {
let stretch = self.stretch.take();
let children = surface.children.borrow();
let buffer = match surface.buffer.get() {
Some(b) => b,
@ -574,6 +589,16 @@ impl Renderer<'_> {
} else {
size = self.base.scale_point(size.0, size.1);
}
let mut tpoints = *tpoints;
if let Some(s) = stretch {
if size.0 > 0 && size.1 > 0 {
let sx = s.0 as f32 / size.0 as f32;
let sy = s.1 as f32 / size.1 as f32;
tpoints.x2 *= sx;
tpoints.y2 *= sy;
}
size = s;
}
if let Some(children) = children.deref() {
macro_rules! render {
($children:expr) => {
@ -595,10 +620,10 @@ impl Renderer<'_> {
};
}
render!(&children.below);
self.render_buffer(surface, &buffer, x, y, *tpoints, size, bounds);
self.render_buffer(surface, &buffer, x, y, tpoints, size, bounds);
render!(&children.above);
} else {
self.render_buffer(surface, &buffer, x, y, *tpoints, size, bounds);
self.render_buffer(surface, &buffer, x, y, tpoints, size, bounds);
}
}