Skip to content

Commit

Permalink
render: fix top-left clipping of surfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
mahkoh committed Feb 14, 2024
1 parent ccacdda commit 250026f
Show file tree
Hide file tree
Showing 18 changed files with 147 additions and 277 deletions.
29 changes: 7 additions & 22 deletions src/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,7 @@ fn render_img(image: &InstantiatedCursorImage, renderer: &mut Renderer, x: Fixed
None,
None,
scale,
i32::MAX,
i32::MAX,
None,
);
}
}
Expand All @@ -379,16 +378,9 @@ impl Cursor for StaticCursor {

fn render_hardware_cursor(&self, renderer: &mut Renderer) {
if let Some(img) = self.image.scales.get(&renderer.scale()) {
renderer.base.render_texture(
&img.tex,
0,
0,
None,
None,
renderer.scale(),
i32::MAX,
i32::MAX,
);
renderer
.base
.render_texture(&img.tex, 0, 0, None, None, renderer.scale(), None);
}
}

Expand Down Expand Up @@ -416,16 +408,9 @@ impl Cursor for AnimatedCursor {
fn render_hardware_cursor(&self, renderer: &mut Renderer) {
let img = &self.images[self.idx.get()];
if let Some(img) = img.scales.get(&renderer.scale()) {
renderer.base.render_texture(
&img.tex,
0,
0,
None,
None,
renderer.scale(),
i32::MAX,
i32::MAX,
);
renderer
.base
.render_texture(&img.tex, 0, 0, None, None, renderer.scale(), None);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/gfx_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl dyn GfxFramebuffer {
scale,
scalef: 1.0,
};
renderer.render_texture(texture, x, y, None, None, scale, i32::MAX, i32::MAX);
renderer.render_texture(texture, x, y, None, None, scale, None);
let clear = self.format().has_alpha.then_some(&Color::TRANSPARENT);
self.render(ops, clear);
}
Expand Down Expand Up @@ -195,7 +195,7 @@ impl dyn GfxFramebuffer {
logical_extents: node.node_absolute_position().at_point(0, 0),
physical_extents: Rect::new(0, 0, width, height).unwrap(),
};
node.node_render(&mut renderer, 0, 0, i32::MAX, i32::MAX);
node.node_render(&mut renderer, 0, 0, None);
if let Some(rect) = cursor_rect {
let seats = state.globals.lock_seats();
for seat in seats.values() {
Expand All @@ -208,7 +208,7 @@ impl dyn GfxFramebuffer {
);
if extents.intersects(&rect) {
let (x, y) = rect.translate(extents.x1(), extents.y1());
renderer.render_surface(&dnd_icon, x, y, i32::MAX, i32::MAX);
renderer.render_surface(&dnd_icon, x, y, None);
}
}
if render_hardware_cursor || !seat.hardware_cursor() {
Expand Down
11 changes: 2 additions & 9 deletions src/ifs/wl_surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1142,15 +1142,8 @@ impl Node for WlSurface {
}
}

fn node_render(
&self,
renderer: &mut Renderer,
x: i32,
y: i32,
max_width: i32,
max_height: i32,
) {
renderer.render_surface(self, x, y, max_width, max_height);
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32, bounds: Option<&Rect>) {
renderer.render_surface(self, x, y, bounds);
}

fn node_client(&self) -> Option<Rc<Client>> {
Expand Down
26 changes: 3 additions & 23 deletions src/ifs/wl_surface/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,36 +76,16 @@ impl Cursor for CursorSurface {
let (hot_x, hot_y) = (Fixed::from_int(hot_x), Fixed::from_int(hot_y));
let x = ((x - hot_x).to_f64() * scale).round() as _;
let y = ((y - hot_y).to_f64() * scale).round() as _;
renderer.render_surface_scaled(
&self.surface,
x,
y,
None,
i32::MAX,
i32::MAX,
false,
);
renderer.render_surface_scaled(&self.surface, x, y, None, None, false);
} else {
renderer.render_surface(
&self.surface,
x_int - hot_x,
y_int - hot_y,
i32::MAX,
i32::MAX,
);
renderer.render_surface(&self.surface, x_int - hot_x, y_int - hot_y, None);
}
}
}

fn render_hardware_cursor(&self, renderer: &mut Renderer) {
let extents = self.surface.extents.get();
renderer.render_surface(
&self.surface,
-extents.x1(),
-extents.y1(),
i32::MAX,
i32::MAX,
);
renderer.render_surface(&self.surface, -extents.x1(), -extents.y1(), None);

struct FrameRequests;
impl NodeVisitorBase for FrameRequests {
Expand Down
11 changes: 2 additions & 9 deletions src/ifs/wl_surface/x_surface/xwindow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,15 +332,8 @@ impl Node for Xwindow {
FindTreeResult::Other
}

fn node_render(
&self,
renderer: &mut Renderer,
x: i32,
y: i32,
max_width: i32,
max_height: i32,
) {
renderer.render_surface(&self.x.surface, x, y, max_width, max_height)
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32, bounds: Option<&Rect>) {
renderer.render_surface(&self.x.surface, x, y, bounds)
}

fn node_client(&self) -> Option<Rc<Client>> {
Expand Down
11 changes: 2 additions & 9 deletions src/ifs/wl_surface/xdg_surface/xdg_popup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,15 +300,8 @@ impl Node for XdgPopup {
self.xdg.find_tree_at(x, y, tree)
}

fn node_render(
&self,
renderer: &mut Renderer,
x: i32,
y: i32,
max_width: i32,
max_height: i32,
) {
renderer.render_xdg_surface(&self.xdg, x, y, max_width, max_height)
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32, bounds: Option<&Rect>) {
renderer.render_xdg_surface(&self.xdg, x, y, bounds)
}

fn node_client(&self) -> Option<Rc<Client>> {
Expand Down
11 changes: 2 additions & 9 deletions src/ifs/wl_surface/xdg_surface/xdg_toplevel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,15 +422,8 @@ impl Node for XdgToplevel {
self.xdg.find_tree_at(x, y, tree)
}

fn node_render(
&self,
renderer: &mut Renderer,
x: i32,
y: i32,
max_width: i32,
max_height: i32,
) {
renderer.render_xdg_surface(&self.xdg, x, y, max_width, max_height)
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32, bounds: Option<&Rect>) {
renderer.render_xdg_surface(&self.xdg, x, y, bounds)
}

fn node_client(&self) -> Option<Rc<Client>> {
Expand Down
9 changes: 1 addition & 8 deletions src/ifs/wl_surface/zwlr_layer_surface_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,14 +394,7 @@ impl Node for ZwlrLayerSurfaceV1 {
self.surface.find_tree_at_(x, y, tree)
}

fn node_render(
&self,
renderer: &mut Renderer,
x: i32,
y: i32,
_max_width: i32,
_max_height: i32,
) {
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32, _bounds: Option<&Rect>) {
renderer.render_layer_surface(self, x, y);
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/portal/ptr_gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,7 @@ impl GuiElement for Button {
None,
None,
r.scale(),
i32::MAX,
i32::MAX,
None,
);
}
}
Expand Down Expand Up @@ -323,8 +322,7 @@ impl GuiElement for Label {
None,
None,
r.scale(),
i32::MAX,
i32::MAX,
None,
);
}
}
Expand Down
Loading

0 comments on commit 250026f

Please sign in to comment.