Merge pull request #87 from mahkoh/jorth/fix-surface-position
render: fix top-left clipping of surfaces
This commit is contained in:
commit
30fb0f087f
18 changed files with 147 additions and 277 deletions
|
|
@ -366,8 +366,7 @@ fn render_img(image: &InstantiatedCursorImage, renderer: &mut Renderer, x: Fixed
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
scale,
|
scale,
|
||||||
i32::MAX,
|
None,
|
||||||
i32::MAX,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -379,16 +378,9 @@ impl Cursor for StaticCursor {
|
||||||
|
|
||||||
fn render_hardware_cursor(&self, renderer: &mut Renderer) {
|
fn render_hardware_cursor(&self, renderer: &mut Renderer) {
|
||||||
if let Some(img) = self.image.scales.get(&renderer.scale()) {
|
if let Some(img) = self.image.scales.get(&renderer.scale()) {
|
||||||
renderer.base.render_texture(
|
renderer
|
||||||
&img.tex,
|
.base
|
||||||
0,
|
.render_texture(&img.tex, 0, 0, None, None, renderer.scale(), None);
|
||||||
0,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
renderer.scale(),
|
|
||||||
i32::MAX,
|
|
||||||
i32::MAX,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -416,16 +408,9 @@ impl Cursor for AnimatedCursor {
|
||||||
fn render_hardware_cursor(&self, renderer: &mut Renderer) {
|
fn render_hardware_cursor(&self, renderer: &mut Renderer) {
|
||||||
let img = &self.images[self.idx.get()];
|
let img = &self.images[self.idx.get()];
|
||||||
if let Some(img) = img.scales.get(&renderer.scale()) {
|
if let Some(img) = img.scales.get(&renderer.scale()) {
|
||||||
renderer.base.render_texture(
|
renderer
|
||||||
&img.tex,
|
.base
|
||||||
0,
|
.render_texture(&img.tex, 0, 0, None, None, renderer.scale(), None);
|
||||||
0,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
renderer.scale(),
|
|
||||||
i32::MAX,
|
|
||||||
i32::MAX,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ impl dyn GfxFramebuffer {
|
||||||
scale,
|
scale,
|
||||||
scalef: 1.0,
|
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);
|
let clear = self.format().has_alpha.then_some(&Color::TRANSPARENT);
|
||||||
self.render(ops, clear);
|
self.render(ops, clear);
|
||||||
}
|
}
|
||||||
|
|
@ -195,7 +195,7 @@ impl dyn GfxFramebuffer {
|
||||||
logical_extents: node.node_absolute_position().at_point(0, 0),
|
logical_extents: node.node_absolute_position().at_point(0, 0),
|
||||||
physical_extents: Rect::new(0, 0, width, height).unwrap(),
|
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 {
|
if let Some(rect) = cursor_rect {
|
||||||
let seats = state.globals.lock_seats();
|
let seats = state.globals.lock_seats();
|
||||||
for seat in seats.values() {
|
for seat in seats.values() {
|
||||||
|
|
@ -208,7 +208,7 @@ impl dyn GfxFramebuffer {
|
||||||
);
|
);
|
||||||
if extents.intersects(&rect) {
|
if extents.intersects(&rect) {
|
||||||
let (x, y) = rect.translate(extents.x1(), extents.y1());
|
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() {
|
if render_hardware_cursor || !seat.hardware_cursor() {
|
||||||
|
|
|
||||||
|
|
@ -1142,15 +1142,8 @@ impl Node for WlSurface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn node_render(
|
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32, bounds: Option<&Rect>) {
|
||||||
&self,
|
renderer.render_surface(self, x, y, bounds);
|
||||||
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_client(&self) -> Option<Rc<Client>> {
|
fn node_client(&self) -> Option<Rc<Client>> {
|
||||||
|
|
|
||||||
|
|
@ -76,36 +76,16 @@ impl Cursor for CursorSurface {
|
||||||
let (hot_x, hot_y) = (Fixed::from_int(hot_x), Fixed::from_int(hot_y));
|
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 x = ((x - hot_x).to_f64() * scale).round() as _;
|
||||||
let y = ((y - hot_y).to_f64() * scale).round() as _;
|
let y = ((y - hot_y).to_f64() * scale).round() as _;
|
||||||
renderer.render_surface_scaled(
|
renderer.render_surface_scaled(&self.surface, x, y, None, None, false);
|
||||||
&self.surface,
|
|
||||||
x,
|
|
||||||
y,
|
|
||||||
None,
|
|
||||||
i32::MAX,
|
|
||||||
i32::MAX,
|
|
||||||
false,
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
renderer.render_surface(
|
renderer.render_surface(&self.surface, x_int - hot_x, y_int - hot_y, None);
|
||||||
&self.surface,
|
|
||||||
x_int - hot_x,
|
|
||||||
y_int - hot_y,
|
|
||||||
i32::MAX,
|
|
||||||
i32::MAX,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_hardware_cursor(&self, renderer: &mut Renderer) {
|
fn render_hardware_cursor(&self, renderer: &mut Renderer) {
|
||||||
let extents = self.surface.extents.get();
|
let extents = self.surface.extents.get();
|
||||||
renderer.render_surface(
|
renderer.render_surface(&self.surface, -extents.x1(), -extents.y1(), None);
|
||||||
&self.surface,
|
|
||||||
-extents.x1(),
|
|
||||||
-extents.y1(),
|
|
||||||
i32::MAX,
|
|
||||||
i32::MAX,
|
|
||||||
);
|
|
||||||
|
|
||||||
struct FrameRequests;
|
struct FrameRequests;
|
||||||
impl NodeVisitorBase for FrameRequests {
|
impl NodeVisitorBase for FrameRequests {
|
||||||
|
|
|
||||||
|
|
@ -335,15 +335,8 @@ impl Node for Xwindow {
|
||||||
FindTreeResult::Other
|
FindTreeResult::Other
|
||||||
}
|
}
|
||||||
|
|
||||||
fn node_render(
|
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32, bounds: Option<&Rect>) {
|
||||||
&self,
|
renderer.render_surface(&self.x.surface, x, y, bounds)
|
||||||
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_client(&self) -> Option<Rc<Client>> {
|
fn node_client(&self) -> Option<Rc<Client>> {
|
||||||
|
|
|
||||||
|
|
@ -300,15 +300,8 @@ impl Node for XdgPopup {
|
||||||
self.xdg.find_tree_at(x, y, tree)
|
self.xdg.find_tree_at(x, y, tree)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn node_render(
|
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32, bounds: Option<&Rect>) {
|
||||||
&self,
|
renderer.render_xdg_surface(&self.xdg, x, y, bounds)
|
||||||
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_client(&self) -> Option<Rc<Client>> {
|
fn node_client(&self) -> Option<Rc<Client>> {
|
||||||
|
|
|
||||||
|
|
@ -428,15 +428,8 @@ impl Node for XdgToplevel {
|
||||||
self.xdg.find_tree_at(x, y, tree)
|
self.xdg.find_tree_at(x, y, tree)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn node_render(
|
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32, bounds: Option<&Rect>) {
|
||||||
&self,
|
renderer.render_xdg_surface(&self.xdg, x, y, bounds)
|
||||||
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_client(&self) -> Option<Rc<Client>> {
|
fn node_client(&self) -> Option<Rc<Client>> {
|
||||||
|
|
|
||||||
|
|
@ -394,14 +394,7 @@ impl Node for ZwlrLayerSurfaceV1 {
|
||||||
self.surface.find_tree_at_(x, y, tree)
|
self.surface.find_tree_at_(x, y, tree)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn node_render(
|
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32, _bounds: Option<&Rect>) {
|
||||||
&self,
|
|
||||||
renderer: &mut Renderer,
|
|
||||||
x: i32,
|
|
||||||
y: i32,
|
|
||||||
_max_width: i32,
|
|
||||||
_max_height: i32,
|
|
||||||
) {
|
|
||||||
renderer.render_layer_surface(self, x, y);
|
renderer.render_layer_surface(self, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -221,8 +221,7 @@ impl GuiElement for Button {
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
r.scale(),
|
r.scale(),
|
||||||
i32::MAX,
|
None,
|
||||||
i32::MAX,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -323,8 +322,7 @@ impl GuiElement for Label {
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
r.scale(),
|
r.scale(),
|
||||||
i32::MAX,
|
None,
|
||||||
i32::MAX,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
121
src/renderer.rs
121
src/renderer.rs
|
|
@ -76,7 +76,7 @@ impl Renderer<'_> {
|
||||||
if self.state.lock.locked.get() {
|
if self.state.lock.locked.get() {
|
||||||
if let Some(surface) = output.lock_surface.get() {
|
if let Some(surface) = output.lock_surface.get() {
|
||||||
if surface.surface.buffer.get().is_some() {
|
if surface.surface.buffer.get().is_some() {
|
||||||
self.render_surface(&surface.surface, x, y, i32::MAX, i32::MAX);
|
self.render_surface(&surface.surface, x, y, None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
@ -97,7 +97,7 @@ impl Renderer<'_> {
|
||||||
}
|
}
|
||||||
if let Some(ws) = output.workspace.get() {
|
if let Some(ws) = output.workspace.get() {
|
||||||
if let Some(fs) = ws.fullscreen.get() {
|
if let Some(fs) = ws.fullscreen.get() {
|
||||||
fs.tl_as_node().node_render(self, x, y, i32::MAX, i32::MAX);
|
fs.tl_as_node().node_render(self, x, y, None);
|
||||||
render_layer!(output.layers[2]);
|
render_layer!(output.layers[2]);
|
||||||
render_layer!(output.layers[3]);
|
render_layer!(output.layers[3]);
|
||||||
return;
|
return;
|
||||||
|
|
@ -143,20 +143,12 @@ impl Renderer<'_> {
|
||||||
for title in &rd.titles {
|
for title in &rd.titles {
|
||||||
let (x, y) = self.base.scale_point(x + title.tex_x, y + title.tex_y);
|
let (x, y) = self.base.scale_point(x + title.tex_x, y + title.tex_y);
|
||||||
self.base
|
self.base
|
||||||
.render_texture(&title.tex, x, y, None, None, scale, i32::MAX, i32::MAX);
|
.render_texture(&title.tex, x, y, None, None, scale, None);
|
||||||
}
|
}
|
||||||
if let Some(status) = &rd.status {
|
if let Some(status) = &rd.status {
|
||||||
let (x, y) = self.base.scale_point(x + status.tex_x, y + status.tex_y);
|
let (x, y) = self.base.scale_point(x + status.tex_x, y + status.tex_y);
|
||||||
self.base.render_texture(
|
self.base
|
||||||
&status.tex.texture,
|
.render_texture(&status.tex.texture, x, y, None, None, scale, None);
|
||||||
x,
|
|
||||||
y,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
scale,
|
|
||||||
i32::MAX,
|
|
||||||
i32::MAX,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(ws) = output.workspace.get() {
|
if let Some(ws) = output.workspace.get() {
|
||||||
|
|
@ -168,7 +160,7 @@ impl Renderer<'_> {
|
||||||
let pos = stacked.node_absolute_position();
|
let pos = stacked.node_absolute_position();
|
||||||
if pos.intersects(&opos) {
|
if pos.intersects(&opos) {
|
||||||
let (x, y) = opos.translate(pos.x1(), pos.y1());
|
let (x, y) = opos.translate(pos.x1(), pos.y1());
|
||||||
stacked.node_render(self, x, y, i32::MAX, i32::MAX);
|
stacked.node_render(self, x, y, None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -192,16 +184,8 @@ impl Renderer<'_> {
|
||||||
let (tex_width, tex_height) = tex.texture.size();
|
let (tex_width, tex_height) = tex.texture.size();
|
||||||
let x = x + (pos.width() - tex_width) / 2;
|
let x = x + (pos.width() - tex_width) / 2;
|
||||||
let y = y + (pos.height() - tex_height) / 2;
|
let y = y + (pos.height() - tex_height) / 2;
|
||||||
self.base.render_texture(
|
self.base
|
||||||
&tex.texture,
|
.render_texture(&tex.texture, x, y, None, None, self.base.scale, None);
|
||||||
x,
|
|
||||||
y,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
self.base.scale,
|
|
||||||
i32::MAX,
|
|
||||||
i32::MAX,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -237,8 +221,7 @@ impl Renderer<'_> {
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
self.base.scale,
|
self.base.scale,
|
||||||
i32::MAX,
|
None,
|
||||||
i32::MAX,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -247,13 +230,9 @@ impl Renderer<'_> {
|
||||||
let body = container.mono_body.get().move_(x, y);
|
let body = container.mono_body.get().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();
|
||||||
child.node.node_render(
|
child
|
||||||
self,
|
.node
|
||||||
x + content.x1(),
|
.node_render(self, x + content.x1(), y + content.y1(), Some(&body));
|
||||||
y + content.y1(),
|
|
||||||
body.width(),
|
|
||||||
body.height(),
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
for child in container.children.iter() {
|
for child in container.children.iter() {
|
||||||
let body = child.body.get();
|
let body = child.body.get();
|
||||||
|
|
@ -263,13 +242,9 @@ impl Renderer<'_> {
|
||||||
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();
|
let content = child.content.get();
|
||||||
child.node.node_render(
|
child
|
||||||
self,
|
.node
|
||||||
x + content.x1(),
|
.node_render(self, x + content.x1(), y + content.y1(), Some(&body));
|
||||||
y + content.y1(),
|
|
||||||
body.width(),
|
|
||||||
body.height(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -279,8 +254,7 @@ impl Renderer<'_> {
|
||||||
xdg: &XdgSurface,
|
xdg: &XdgSurface,
|
||||||
mut x: i32,
|
mut x: i32,
|
||||||
mut y: i32,
|
mut y: i32,
|
||||||
max_width: i32,
|
bounds: Option<&Rect>,
|
||||||
max_height: i32,
|
|
||||||
) {
|
) {
|
||||||
let surface = &xdg.surface;
|
let surface = &xdg.surface;
|
||||||
if let Some(geo) = xdg.geometry() {
|
if let Some(geo) = xdg.geometry() {
|
||||||
|
|
@ -288,19 +262,12 @@ impl Renderer<'_> {
|
||||||
x = xt;
|
x = xt;
|
||||||
y = yt;
|
y = yt;
|
||||||
}
|
}
|
||||||
self.render_surface(surface, x, y, max_width, max_height);
|
self.render_surface(surface, x, y, bounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render_surface(
|
pub fn render_surface(&mut self, surface: &WlSurface, x: i32, y: i32, bounds: Option<&Rect>) {
|
||||||
&mut self,
|
|
||||||
surface: &WlSurface,
|
|
||||||
x: i32,
|
|
||||||
y: i32,
|
|
||||||
max_width: i32,
|
|
||||||
max_height: i32,
|
|
||||||
) {
|
|
||||||
let (x, y) = self.base.scale_point(x, y);
|
let (x, y) = self.base.scale_point(x, y);
|
||||||
self.render_surface_scaled(surface, x, y, None, max_width, max_height, false);
|
self.render_surface_scaled(surface, x, y, None, bounds, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render_surface_scaled(
|
pub fn render_surface_scaled(
|
||||||
|
|
@ -309,8 +276,7 @@ impl Renderer<'_> {
|
||||||
x: i32,
|
x: i32,
|
||||||
y: i32,
|
y: i32,
|
||||||
pos_rel: Option<(i32, i32)>,
|
pos_rel: Option<(i32, i32)>,
|
||||||
max_width: i32,
|
bounds: Option<&Rect>,
|
||||||
max_height: i32,
|
|
||||||
is_subsurface: bool,
|
is_subsurface: bool,
|
||||||
) {
|
) {
|
||||||
let children = surface.children.borrow();
|
let children = surface.children.borrow();
|
||||||
|
|
@ -346,18 +312,17 @@ impl Renderer<'_> {
|
||||||
x + x1,
|
x + x1,
|
||||||
y + y1,
|
y + y1,
|
||||||
Some((pos.x1(), pos.y1())),
|
Some((pos.x1(), pos.y1())),
|
||||||
max_width,
|
bounds,
|
||||||
max_height,
|
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
render!(&children.below);
|
render!(&children.below);
|
||||||
self.render_buffer(&buffer, x, y, *tpoints, size, max_width, max_height);
|
self.render_buffer(&buffer, x, y, *tpoints, size, bounds);
|
||||||
render!(&children.above);
|
render!(&children.above);
|
||||||
} else {
|
} else {
|
||||||
self.render_buffer(&buffer, x, y, *tpoints, size, max_width, max_height);
|
self.render_buffer(&buffer, x, y, *tpoints, size, bounds);
|
||||||
}
|
}
|
||||||
if let Some(result) = self.result.as_deref_mut() {
|
if let Some(result) = self.result.as_deref_mut() {
|
||||||
{
|
{
|
||||||
|
|
@ -378,8 +343,7 @@ impl Renderer<'_> {
|
||||||
y: i32,
|
y: i32,
|
||||||
tpoints: BufferPoints,
|
tpoints: BufferPoints,
|
||||||
tsize: (i32, i32),
|
tsize: (i32, i32),
|
||||||
max_width: i32,
|
bounds: Option<&Rect>,
|
||||||
max_height: i32,
|
|
||||||
) {
|
) {
|
||||||
if let Some(tex) = buffer.texture.get() {
|
if let Some(tex) = buffer.texture.get() {
|
||||||
self.base.render_texture(
|
self.base.render_texture(
|
||||||
|
|
@ -389,14 +353,17 @@ impl Renderer<'_> {
|
||||||
Some(tpoints),
|
Some(tpoints),
|
||||||
Some(tsize),
|
Some(tsize),
|
||||||
self.base.scale,
|
self.base.scale,
|
||||||
max_width,
|
bounds,
|
||||||
max_height,
|
|
||||||
);
|
);
|
||||||
} else if let Some(color) = &buffer.color {
|
} else if let Some(color) = &buffer.color {
|
||||||
if let Some(rect) =
|
if let Some(rect) = Rect::new_sized(x, y, tsize.0, tsize.1) {
|
||||||
Rect::new_sized(x, y, tsize.0.min(max_width), tsize.1.min(max_height))
|
let rect = match bounds {
|
||||||
{
|
None => rect,
|
||||||
self.base.fill_boxes(&[rect], color);
|
Some(bounds) => rect.intersect(*bounds),
|
||||||
|
};
|
||||||
|
if !rect.is_empty() {
|
||||||
|
self.base.fill_boxes(&[rect], color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log::info!("live buffer has neither a texture nor is a single-pixel buffer");
|
log::info!("live buffer has neither a texture nor is a single-pixel buffer");
|
||||||
|
|
@ -435,16 +402,8 @@ impl Renderer<'_> {
|
||||||
self.base.fill_boxes(&title_underline, &uc);
|
self.base.fill_boxes(&title_underline, &uc);
|
||||||
if let Some(title) = floating.title_textures.get(&self.base.scale) {
|
if let Some(title) = floating.title_textures.get(&self.base.scale) {
|
||||||
let (x, y) = self.base.scale_point(x + bw, y + bw);
|
let (x, y) = self.base.scale_point(x + bw, y + bw);
|
||||||
self.base.render_texture(
|
self.base
|
||||||
&title.texture,
|
.render_texture(&title.texture, x, y, None, None, self.base.scale, None);
|
||||||
x,
|
|
||||||
y,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
self.base.scale,
|
|
||||||
i32::MAX,
|
|
||||||
i32::MAX,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
let body = Rect::new_sized(
|
let body = Rect::new_sized(
|
||||||
x + bw,
|
x + bw,
|
||||||
|
|
@ -454,18 +413,12 @@ impl Renderer<'_> {
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let scissor_body = self.base.scale_rect(body);
|
let scissor_body = self.base.scale_rect(body);
|
||||||
child.node_render(
|
child.node_render(self, body.x1(), body.y1(), Some(&scissor_body));
|
||||||
self,
|
|
||||||
body.x1(),
|
|
||||||
body.y1(),
|
|
||||||
scissor_body.width(),
|
|
||||||
scissor_body.height(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render_layer_surface(&mut self, surface: &ZwlrLayerSurfaceV1, x: i32, y: i32) {
|
pub fn render_layer_surface(&mut self, surface: &ZwlrLayerSurfaceV1, x: i32, y: i32) {
|
||||||
let body = surface.position().at_point(x, y);
|
let body = surface.position().at_point(x, y);
|
||||||
let body = self.base.scale_rect(body);
|
let body = self.base.scale_rect(body);
|
||||||
self.render_surface(&surface.surface, x, y, body.width(), body.height());
|
self.render_surface(&surface.surface, x, y, Some(&body));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -120,8 +120,7 @@ impl RendererBase<'_> {
|
||||||
tpoints: Option<BufferPoints>,
|
tpoints: Option<BufferPoints>,
|
||||||
tsize: Option<(i32, i32)>,
|
tsize: Option<(i32, i32)>,
|
||||||
tscale: Scale,
|
tscale: Scale,
|
||||||
max_width: i32,
|
bounds: Option<&Rect>,
|
||||||
max_height: i32,
|
|
||||||
) {
|
) {
|
||||||
let mut texcoord = tpoints.unwrap_or(BufferPoints {
|
let mut texcoord = tpoints.unwrap_or(BufferPoints {
|
||||||
top_left: BufferPoint { x: 0.0, y: 0.0 },
|
top_left: BufferPoint { x: 0.0, y: 0.0 },
|
||||||
|
|
@ -142,49 +141,89 @@ impl RendererBase<'_> {
|
||||||
(w, h)
|
(w, h)
|
||||||
};
|
};
|
||||||
|
|
||||||
macro_rules! clamp {
|
let mut target_x = [x, x + twidth];
|
||||||
($desired:ident, $max:ident, $([$far:ident, $near:ident]),*) => {
|
let mut target_y = [y, y + theight];
|
||||||
if $desired > $max {
|
|
||||||
let $desired = $desired as f32;
|
if let Some(bounds) = bounds {
|
||||||
let $max = $max as f32;
|
#[cold]
|
||||||
let factor = $max / $desired;
|
fn cold() {}
|
||||||
$(
|
|
||||||
let dx = (texcoord.$far.x - texcoord.$near.x) * factor;
|
let bounds_x = [bounds.x1(), bounds.x2()];
|
||||||
texcoord.$far.x = texcoord.$near.x + dx;
|
let bounds_y = [bounds.y1(), bounds.y2()];
|
||||||
let dy = (texcoord.$far.y - texcoord.$near.y) * factor;
|
|
||||||
texcoord.$far.y = texcoord.$near.y + dy;
|
macro_rules! clamp {
|
||||||
)*
|
($desired:ident, $bounds:ident, $test_idx:expr, $test_cmp:ident, $test_cmp_eq:ident, $([$modify:ident, $keep:ident],)*) => {{
|
||||||
$max
|
let desired_test = $desired[$test_idx];
|
||||||
} else {
|
let desired_other = $desired[1 - $test_idx];
|
||||||
$desired as f32
|
let bound = $bounds[$test_idx];
|
||||||
}
|
if desired_test.$test_cmp(&bound) {
|
||||||
};
|
cold();
|
||||||
|
if desired_other.$test_cmp_eq(&bound) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let max = (desired_other - bound) as f32;
|
||||||
|
let desired = ($desired[1] - $desired[0]) as f32;
|
||||||
|
let factor = max.abs() / desired;
|
||||||
|
$(
|
||||||
|
let dx = (texcoord.$modify.x - texcoord.$keep.x) * factor;
|
||||||
|
texcoord.$modify.x = texcoord.$keep.x + dx;
|
||||||
|
let dy = (texcoord.$modify.y - texcoord.$keep.y) * factor;
|
||||||
|
texcoord.$modify.y = texcoord.$keep.y + dy;
|
||||||
|
)*
|
||||||
|
$desired[$test_idx] = bound;
|
||||||
|
}
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
|
||||||
|
clamp!(
|
||||||
|
target_x,
|
||||||
|
bounds_x,
|
||||||
|
0,
|
||||||
|
lt,
|
||||||
|
le,
|
||||||
|
[top_left, top_right],
|
||||||
|
[bottom_left, bottom_right],
|
||||||
|
);
|
||||||
|
|
||||||
|
clamp!(
|
||||||
|
target_x,
|
||||||
|
bounds_x,
|
||||||
|
1,
|
||||||
|
gt,
|
||||||
|
ge,
|
||||||
|
[top_right, top_left],
|
||||||
|
[bottom_right, bottom_left],
|
||||||
|
);
|
||||||
|
|
||||||
|
clamp!(
|
||||||
|
target_y,
|
||||||
|
bounds_y,
|
||||||
|
0,
|
||||||
|
lt,
|
||||||
|
le,
|
||||||
|
[top_left, bottom_left],
|
||||||
|
[top_right, bottom_right],
|
||||||
|
);
|
||||||
|
|
||||||
|
clamp!(
|
||||||
|
target_y,
|
||||||
|
bounds_y,
|
||||||
|
1,
|
||||||
|
gt,
|
||||||
|
ge,
|
||||||
|
[bottom_left, top_left],
|
||||||
|
[bottom_right, top_right],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let twidth = clamp!(
|
|
||||||
twidth,
|
|
||||||
max_width,
|
|
||||||
[top_right, top_left],
|
|
||||||
[bottom_right, bottom_left]
|
|
||||||
);
|
|
||||||
let theight = clamp!(
|
|
||||||
theight,
|
|
||||||
max_height,
|
|
||||||
[bottom_left, top_left],
|
|
||||||
[bottom_right, top_right]
|
|
||||||
);
|
|
||||||
|
|
||||||
let x = x as f32;
|
|
||||||
let y = y as f32;
|
|
||||||
|
|
||||||
self.ops.push(GfxApiOpt::CopyTexture(CopyTexture {
|
self.ops.push(GfxApiOpt::CopyTexture(CopyTexture {
|
||||||
tex: texture.clone(),
|
tex: texture.clone(),
|
||||||
source: texcoord,
|
source: texcoord,
|
||||||
target: AbsoluteRect {
|
target: AbsoluteRect {
|
||||||
x1: x,
|
x1: target_x[0] as f32,
|
||||||
y1: y,
|
y1: target_y[0] as f32,
|
||||||
x2: x + twidth,
|
x2: target_x[1] as f32,
|
||||||
y2: y + theight,
|
y2: target_y[1] as f32,
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
12
src/tree.rs
12
src/tree.rs
|
|
@ -137,19 +137,11 @@ pub trait Node: 'static {
|
||||||
let _ = (child, active, depth);
|
let _ = (child, active, depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn node_render(
|
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32, bounds: Option<&Rect>) {
|
||||||
&self,
|
|
||||||
renderer: &mut Renderer,
|
|
||||||
x: i32,
|
|
||||||
y: i32,
|
|
||||||
max_width: i32,
|
|
||||||
max_height: i32,
|
|
||||||
) {
|
|
||||||
let _ = renderer;
|
let _ = renderer;
|
||||||
let _ = x;
|
let _ = x;
|
||||||
let _ = y;
|
let _ = y;
|
||||||
let _ = max_width;
|
let _ = bounds;
|
||||||
let _ = max_height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn node_client(&self) -> Option<Rc<Client>> {
|
fn node_client(&self) -> Option<Rc<Client>> {
|
||||||
|
|
|
||||||
|
|
@ -1140,14 +1140,7 @@ impl Node for ContainerNode {
|
||||||
.node_child_active_changed(self.deref(), active, depth + 1);
|
.node_child_active_changed(self.deref(), active, depth + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn node_render(
|
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32, _bounds: Option<&Rect>) {
|
||||||
&self,
|
|
||||||
renderer: &mut Renderer,
|
|
||||||
x: i32,
|
|
||||||
y: i32,
|
|
||||||
_max_width: i32,
|
|
||||||
_max_height: i32,
|
|
||||||
) {
|
|
||||||
renderer.render_container(self, x, y);
|
renderer.render_container(self, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,14 +111,7 @@ impl Node for DisplayNode {
|
||||||
FindTreeResult::AcceptsInput
|
FindTreeResult::AcceptsInput
|
||||||
}
|
}
|
||||||
|
|
||||||
fn node_render(
|
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32, _bounds: Option<&Rect>) {
|
||||||
&self,
|
|
||||||
renderer: &mut Renderer,
|
|
||||||
x: i32,
|
|
||||||
y: i32,
|
|
||||||
_max_width: i32,
|
|
||||||
_max_height: i32,
|
|
||||||
) {
|
|
||||||
renderer.render_display(self, x, y);
|
renderer.render_display(self, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -446,14 +446,7 @@ impl Node for FloatNode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn node_render(
|
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32, _bounds: Option<&Rect>) {
|
||||||
&self,
|
|
||||||
renderer: &mut Renderer,
|
|
||||||
x: i32,
|
|
||||||
y: i32,
|
|
||||||
_max_width: i32,
|
|
||||||
_max_height: i32,
|
|
||||||
) {
|
|
||||||
renderer.render_floating(self, x, y)
|
renderer.render_floating(self, x, y)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -636,14 +636,7 @@ impl Node for OutputNode {
|
||||||
FindTreeResult::AcceptsInput
|
FindTreeResult::AcceptsInput
|
||||||
}
|
}
|
||||||
|
|
||||||
fn node_render(
|
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32, _bounds: Option<&Rect>) {
|
||||||
&self,
|
|
||||||
renderer: &mut Renderer,
|
|
||||||
x: i32,
|
|
||||||
y: i32,
|
|
||||||
_max_width: i32,
|
|
||||||
_max_height: i32,
|
|
||||||
) {
|
|
||||||
renderer.render_output(self, x, y);
|
renderer.render_output(self, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -123,14 +123,7 @@ impl Node for PlaceholderNode {
|
||||||
FindTreeResult::AcceptsInput
|
FindTreeResult::AcceptsInput
|
||||||
}
|
}
|
||||||
|
|
||||||
fn node_render(
|
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32, _bounds: Option<&Rect>) {
|
||||||
&self,
|
|
||||||
renderer: &mut Renderer,
|
|
||||||
x: i32,
|
|
||||||
y: i32,
|
|
||||||
_max_width: i32,
|
|
||||||
_max_height: i32,
|
|
||||||
) {
|
|
||||||
renderer.render_placeholder(self, x, y);
|
renderer.render_placeholder(self, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -224,14 +224,7 @@ impl Node for WorkspaceNode {
|
||||||
FindTreeResult::AcceptsInput
|
FindTreeResult::AcceptsInput
|
||||||
}
|
}
|
||||||
|
|
||||||
fn node_render(
|
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32, _bounds: Option<&Rect>) {
|
||||||
&self,
|
|
||||||
renderer: &mut Renderer,
|
|
||||||
x: i32,
|
|
||||||
y: i32,
|
|
||||||
_max_width: i32,
|
|
||||||
_max_height: i32,
|
|
||||||
) {
|
|
||||||
renderer.render_workspace(self, x, y);
|
renderer.render_workspace(self, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue