Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omit nested clip regions if internal one is their subregion #299

Merged
merged 1 commit into from Aug 9, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Omit nested clip regions if internal one is their subregion

  • Loading branch information
splav committed Aug 8, 2016
commit c70e93771c78d24b31270267290beab5c4ad21db
@@ -16,7 +16,7 @@ use scene::{SceneStackingContext, ScenePipeline, Scene, SceneItem, SpecificScene
use scoped_threadpool;
use std::collections::{HashMap, HashSet};
use std::hash::BuildHasherDefault;
use tiling::{Clip, FrameBuilder, FrameBuilderConfig};
use tiling::{Clip, FrameBuilder, FrameBuilderConfig, InsideTest};
use util::{MatrixHelpers};
use webrender_traits::{AuxiliaryLists, PipelineId, Epoch, ScrollPolicy, ScrollLayerId};
use webrender_traits::{StackingContext, FilterOp, MixBlendMode};
@@ -495,10 +495,17 @@ impl Frame {

for item in &draw_list.items {
let clips = auxiliary_lists.complex_clip_regions(&item.clip.complex);
let clip = if clips.is_empty() {
None
} else {
Some(Box::new(Clip::from_clip_region(&clips[0])))
let clip = match clips.len() {
0 => None,
1 => Some(Box::new(Clip::from_clip_region(&clips[0]))),
_ => {
let internal_clip = clips.last().unwrap();
if clips.iter().all(|current_clip| current_clip.might_contain(internal_clip)) {
Some(Box::new(Clip::from_clip_region(internal_clip)))
} else {
Some(Box::new(Clip::from_clip_region(&clips[0])))
}
},
};

match item.item {
@@ -933,4 +940,3 @@ impl Frame {
}
}
}

@@ -2934,3 +2934,31 @@ impl PackedPrimitiveCache {
}
}

//Test for one clip region contains another
pub trait InsideTest<T> {
fn might_contain(&self, clip: &T) -> bool;
}

impl InsideTest<ComplexClipRegion> for ComplexClipRegion {
// Returns true if clip is inside self, can return false negative
fn might_contain(&self, clip: &ComplexClipRegion) -> bool {
let delta_left = clip.rect.origin.x - self.rect.origin.x;
let delta_top = clip.rect.origin.y - self.rect.origin.y;
let delta_right = self.rect.max_x() - clip.rect.max_x();
let delta_bottom = self.rect.max_y() - clip.rect.max_y();

delta_left >= 0f32 &&
delta_top >= 0f32 &&
delta_right >= 0f32 &&
delta_bottom >= 0f32 &&
clip.radii.top_left.width >= self.radii.top_left.width - delta_left &&
clip.radii.top_left.height >= self.radii.top_left.height - delta_top &&
clip.radii.top_right.width >= self.radii.top_right.width - delta_right &&
clip.radii.top_right.height >= self.radii.top_right.height - delta_top &&
clip.radii.bottom_left.width >= self.radii.bottom_left.width - delta_left &&
clip.radii.bottom_left.height >= self.radii.bottom_left.height - delta_bottom &&
clip.radii.bottom_right.width >= self.radii.bottom_right.width - delta_right &&
clip.radii.bottom_right.height >= self.radii.bottom_right.height - delta_bottom
}
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.