Remove CompletelyEncloses

This commit is contained in:
Anthony Ramine 2019-01-14 12:03:52 +01:00
parent 495a0dd41a
commit 9825b85acd

View file

@ -565,11 +565,11 @@ impl ClippingRegion {
// //
// http://www.inrg.csie.ntu.edu.tw/algorithm2014/presentation/D&C%20Lee-84.pdf // http://www.inrg.csie.ntu.edu.tw/algorithm2014/presentation/D&C%20Lee-84.pdf
for existing_complex_region in &mut self.complex { for existing_complex_region in &mut self.complex {
if existing_complex_region.completely_encloses(&new_complex_region) { if completely_encloses(&existing_complex_region, &new_complex_region) {
*existing_complex_region = new_complex_region; *existing_complex_region = new_complex_region;
return; return;
} }
if new_complex_region.completely_encloses(existing_complex_region) { if completely_encloses(&new_complex_region, &existing_complex_region) {
return; return;
} }
} }
@ -618,38 +618,32 @@ impl fmt::Debug for ClippingRegion {
} }
} }
pub trait CompletelyEncloses { // TODO(pcwalton): This could be more aggressive by considering points that touch the inside of
fn completely_encloses(&self, other: &Self) -> bool; // the border radius ellipse.
} fn completely_encloses(this: &ComplexClipRegion, other: &ComplexClipRegion) -> bool {
let left = this.radii.top_left.width.max(this.radii.bottom_left.width);
impl CompletelyEncloses for ComplexClipRegion { let top = this.radii.top_left.height.max(this.radii.top_right.height);
// TODO(pcwalton): This could be more aggressive by considering points that touch the inside of let right = this
// the border radius ellipse.
fn completely_encloses(&self, other: &Self) -> bool {
let left = self.radii.top_left.width.max(self.radii.bottom_left.width);
let top = self.radii.top_left.height.max(self.radii.top_right.height);
let right = self
.radii .radii
.top_right .top_right
.width .width
.max(self.radii.bottom_right.width); .max(this.radii.bottom_right.width);
let bottom = self let bottom = this
.radii .radii
.bottom_left .bottom_left
.height .height
.max(self.radii.bottom_right.height); .max(this.radii.bottom_right.height);
let interior = LayoutRect::new( let interior = LayoutRect::new(
LayoutPoint::new(self.rect.origin.x + left, self.rect.origin.y + top), LayoutPoint::new(this.rect.origin.x + left, this.rect.origin.y + top),
LayoutSize::new( LayoutSize::new(
self.rect.size.width - left - right, this.rect.size.width - left - right,
self.rect.size.height - top - bottom, this.rect.size.height - top - bottom,
), ),
); );
interior.origin.x <= other.rect.origin.x && interior.origin.x <= other.rect.origin.x &&
interior.origin.y <= other.rect.origin.y && interior.origin.y <= other.rect.origin.y &&
interior.max_x() >= other.rect.max_x() && interior.max_x() >= other.rect.max_x() &&
interior.max_y() >= other.rect.max_y() interior.max_y() >= other.rect.max_y()
}
} }
/// Metadata attached to each display item. This is useful for performing auxiliary threads with /// Metadata attached to each display item. This is useful for performing auxiliary threads with