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

Conversation

@splav
Copy link
Contributor

splav commented Jun 29, 2016

In case of nested clipping regions it is common that external ones do contain the most internal clipping region and essentially only that internal one should be used.
I'm not sure that this is the correct path, but it's rather common (servo/issues/11562, servo/issues/11857) and at least can be used as a fast path if the supposed full of nested clipping regions is rather heavy.

This PR implements this fast path. It relies on the fact that int nested regions list the last is the innermost.

While not sure that it's a good idea at all, looks like a hack, but still...

If there are any thought hot to implement full nested regions support I'll try to implement those (Or may be it will be done in WR2 and there is no need to do this right now).

@splav splav force-pushed the splav:border-radius-clip#11857 branch from a45cc09 to df1f078 Jun 29, 2016
@@ -453,3 +460,30 @@ impl RasterBatch {
false
}
}

trait InsideTest<T> {
fn contains_may_be_false_negative(&self, clip: &T) -> bool;

This comment has been minimized.

@pcwalton

pcwalton Jun 29, 2016

Collaborator

I would just call this might_contain and clarify in the comments that this may be a false negative.


impl InsideTest<ComplexClipRegion> for ComplexClipRegion {
fn contains_may_be_false_negative(&self, clip: &ComplexClipRegion) -> bool {
print!("contains_may_be_false_negative: {:?} {:?}\n", self, clip);

This comment has been minimized.

@pcwalton

pcwalton Jun 29, 2016

Collaborator

Remove this debugging code.

This comment has been minimized.

@glennw

glennw Jun 29, 2016

Member

Remove print

print!("contains_may_be_false_negative: {:?} {:?}\n", self, clip);
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.origin.x + self.rect.size.width - (clip.rect.origin.x + clip.rect.size.width);

This comment has been minimized.

@pcwalton

pcwalton Jun 29, 2016

Collaborator

Could use self.rect.max_x() and clip.rect.max_x() here for brevity

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.origin.x + self.rect.size.width - (clip.rect.origin.x + clip.rect.size.width);
let delta_bottom = self.rect.origin.y + self.rect.size.height - (clip.rect.origin.y + clip.rect.size.height);

This comment has been minimized.

@pcwalton

pcwalton Jun 29, 2016

Collaborator

Could use self.rect.max_y() and clip.rect.max_y() here for brevity

0 => None,
n if n > 1 => {
let internal_clip = clip.last().unwrap();
if clip[..clip.len()].iter().all(|current_clip| current_clip.contains_may_be_false_negative(internal_clip)) {

This comment has been minimized.

@pcwalton

pcwalton Jun 29, 2016

Collaborator

Why not just clip.iter().all(...)?

This comment has been minimized.

@glennw

glennw Jun 29, 2016

Member

Should be able to just us clip.iter()... I think

Some(clip[0])
}
},
_ => Some(clip[0]),

This comment has been minimized.

@pcwalton

pcwalton Jun 29, 2016

Collaborator

Could put this one before the above match and say 1 => Some(clip[0]), then remove the guard

self.complex_clip = None;
self.complex_clip = match clip.len() {
0 => None,
n if n > 1 => {

This comment has been minimized.

@glennw

glennw Jun 29, 2016

Member

Probably clearer to add a condition for 1 => above this and remove the _ => condition.

@@ -453,3 +460,30 @@ impl RasterBatch {
false
}
}

trait InsideTest<T> {

This comment has been minimized.

@glennw

glennw Jun 29, 2016

Member

Could you add a comment here describing exactly what it's checking for?

@splav splav force-pushed the splav:border-radius-clip#11857 branch 2 times, most recently from 6cd0641 to 23b985b Jun 29, 2016
@bors-servo
Copy link
Contributor

bors-servo commented Aug 3, 2016

The latest upstream changes (presumably #319) made this pull request unmergeable. Please resolve the merge conflicts.

@glennw
Copy link
Member

glennw commented Aug 5, 2016

I think this is still relevant but would need to be ported to the wr2 code - thoughts @splav ?

@splav
Copy link
Contributor Author

splav commented Aug 6, 2016

@glennw, sure, I'll port it.

@splav splav force-pushed the splav:border-radius-clip#11857 branch from 23b985b to c70e937 Aug 8, 2016
@glennw
Copy link
Member

glennw commented Aug 8, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Aug 8, 2016

📌 Commit c70e937 has been approved by glennw

@bors-servo
Copy link
Contributor

bors-servo commented Aug 8, 2016

Testing commit c70e937 with merge 648bd6d...

bors-servo added a commit that referenced this pull request Aug 8, 2016
Omit nested clip regions if internal one is their subregion

In case of nested clipping regions it is common that external ones do contain the most internal clipping region and essentially only that internal one should be used.
I'm not sure that this is the correct path, but it's rather common ([servo/issues/11562](servo/servo#11562), [servo/issues/11857](servo/servo#11857)) and at least can be used as a fast path if the supposed full of nested clipping regions is rather heavy.

This PR implements this fast path. It relies on the fact that int nested regions list the last is the innermost.

While not sure that it's a good idea at all, looks like a hack, but still...

If there are any thought hot to implement full nested regions support I'll try to implement those (Or may be it will be done in WR2 and there is no need to do this right now).
@glennw
Copy link
Member

glennw commented Aug 8, 2016

Thanks!

@splav
Copy link
Contributor Author

splav commented Aug 8, 2016

@glennw not at all!

@larsbergstrom
Copy link
Contributor

larsbergstrom commented Aug 9, 2016

@bors-servo bors-servo merged commit 5b0efbc into servo:master Aug 9, 2016
2 of 3 checks passed
2 of 3 checks passed
homu Testing commit c70e937 with merge 648bd6d...
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@splav splav deleted the splav:border-radius-clip#11857 branch Aug 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.