Browse Source

Tesselator: ignore non-positive clip rectangles

Closes https://github.com/emilk/egui/issues/328
pull/333/head
Emil Ernerfeldt 4 years ago
parent
commit
0f1df90d90
  1. 3
      emath/src/rect.rs
  2. 4
      epaint/src/tessellator.rs

3
emath/src/rect.rs

@ -304,16 +304,19 @@ impl Rect {
}
/// `min.x <= max.x && min.y <= max.y`.
#[inline(always)]
pub fn is_non_negative(&self) -> bool {
self.min.x <= self.max.x && self.min.y <= self.max.y
}
/// True if all members are also finite.
#[inline(always)]
pub fn is_finite(&self) -> bool {
self.min.is_finite() && self.max.is_finite()
}
/// True if any member is NaN.
#[inline(always)]
pub fn any_nan(self) -> bool {
self.min.any_nan() || self.max.any_nan()
}

4
epaint/src/tessellator.rs

@ -742,6 +742,10 @@ pub fn tessellate_shapes(
let mut clipped_meshes: Vec<ClippedMesh> = Vec::default();
for ClippedShape(clip_rect, shape) in shapes {
if !clip_rect.is_non_negative() {
continue; // skip empty clip rectangles
}
let start_new_mesh = match clipped_meshes.last() {
None => true,
Some(cm) => cm.0 != clip_rect || cm.1.texture_id != shape.texture_id(),

Loading…
Cancel
Save