Fix integer overflow with nested clip primitives
This commit is contained in:
parent
efa8d267b8
commit
8074bca8a0
1 changed files with 22 additions and 15 deletions
|
|
@ -254,24 +254,31 @@ impl Renderer {
|
||||||
offset,
|
offset,
|
||||||
content,
|
content,
|
||||||
} => {
|
} => {
|
||||||
let clip_layer = Layer::new(
|
let x = bounds.x - layer.offset.x as f32;
|
||||||
Rectangle {
|
let y = bounds.y - layer.offset.y as f32;
|
||||||
x: bounds.x as u32 - layer.offset.x,
|
let width = (bounds.width + x).min(bounds.width);
|
||||||
y: bounds.y as u32 - layer.offset.y,
|
let height = (bounds.height + y).min(bounds.height);
|
||||||
width: bounds.width as u32,
|
|
||||||
height: bounds.height as u32,
|
|
||||||
},
|
|
||||||
layer.offset + *offset,
|
|
||||||
);
|
|
||||||
|
|
||||||
let new_layer = Layer::new(layer.bounds, layer.offset);
|
// Only draw visible content on-screen
|
||||||
|
// TODO: Also, check for parent layer bounds to avoid further
|
||||||
|
// drawing in some circumstances.
|
||||||
|
if width > 0.0 && height > 0.0 {
|
||||||
|
let clip_layer = Layer::new(
|
||||||
|
Rectangle {
|
||||||
|
x: x.max(0.0).ceil() as u32,
|
||||||
|
y: y.max(0.0).ceil() as u32,
|
||||||
|
width: width.ceil() as u32,
|
||||||
|
height: height.ceil() as u32,
|
||||||
|
},
|
||||||
|
layer.offset + *offset,
|
||||||
|
);
|
||||||
|
|
||||||
layers.push(clip_layer);
|
let new_layer = Layer::new(layer.bounds, layer.offset);
|
||||||
|
|
||||||
// TODO: Primitive culling
|
layers.push(clip_layer);
|
||||||
self.draw_primitive(content, layers);
|
self.draw_primitive(content, layers);
|
||||||
|
layers.push(new_layer);
|
||||||
layers.push(new_layer);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue