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

@ -706,6 +706,7 @@ impl dyn GfxFramebuffer {
Rect::new_saturating(0, 0, width, height) Rect::new_saturating(0, 0, width, height)
}, },
icons: None, icons: None,
stretch: None,
}; };
cursor.render_hardware_cursor(&mut renderer); cursor.render_hardware_cursor(&mut renderer);
self.render( self.render(
@ -1039,6 +1040,7 @@ pub fn create_render_pass(
Rect::new_saturating(0, 0, width, height) Rect::new_saturating(0, 0, width, height)
}, },
icons: state.icons.get(state, scale), icons: state.icons.get(state, scale),
stretch: None,
}; };
node.node_render(&mut renderer, 0, 0, None); node.node_render(&mut renderer, 0, 0, None);
if let Some(rect) = cursor_rect { if let Some(rect) = cursor_rect {

View file

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

View file

@ -1297,6 +1297,7 @@ impl State {
Rect::new_sized_saturating(0, 0, width, height) Rect::new_sized_saturating(0, 0, width, height)
}, },
icons: None, icons: None,
stretch: None,
}; };
let mut sample_rect = SampleRect::identity(); let mut sample_rect = SampleRect::identity();
sample_rect.buffer_transform = transform; sample_rect.buffer_transform = transform;

View file

@ -336,6 +336,7 @@ impl ContainerNode {
node: new.clone(), node: new.clone(),
active: Default::default(), active: Default::default(),
body: Default::default(), body: Default::default(),
content: Default::default(), content: Default::default(),
factor: Default::default(), factor: Default::default(),
title: Default::default(), title: Default::default(),
@ -489,9 +490,12 @@ impl ContainerNode {
self.schedule_render_titles(); self.schedule_render_titles();
self.schedule_compute_render_positions(); self.schedule_compute_render_positions();
self.layout_complete.trigger(); self.layout_complete.trigger();
if self.toplevel_data.visible.get() && self.all_children_match_body() { if self.all_children_match_body() {
self.all_children_resized.trigger(); self.all_children_resized.trigger();
self.damage(); if self.toplevel_data.visible.get() {
self.damage();
}
} }
} }
@ -1843,6 +1847,7 @@ impl Node for ContainerNode {
self.update_child_size(node, width, height); self.update_child_size(node, width, height);
} }
if self.all_children_match_body() { if self.all_children_match_body() {
self.all_children_resized.trigger(); self.all_children_resized.trigger();
if self.toplevel_data.visible.get() { if self.toplevel_data.visible.get() {
self.damage(); self.damage();
@ -2043,6 +2048,7 @@ impl ContainingNode for ContainerNode {
node: new.clone(), node: new.clone(),
active: Cell::new(false), active: Cell::new(false),
body: Cell::new(node.body.get()), body: Cell::new(node.body.get()),
content: Default::default(), content: Default::default(),
factor: Cell::new(node.factor.get()), factor: Cell::new(node.factor.get()),
title: Default::default(), title: Default::default(),