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

Clip stack collapse path #595

Merged
merged 5 commits into from Nov 28, 2016
Prev

Traversing the clip stack for the bounding box calculations

  • Loading branch information
kvark committed Nov 28, 2016
commit 03ce061f1bbf9d13be31a4b012f7b69a722f33c4
@@ -102,15 +102,11 @@ fn main() {

let bounds = Rect::new(Point2D::new(0.0, 0.0), Size2D::new(width as f32, height as f32));
let clip_region = {
let radius = webrender_traits::BorderRadius::uniform(20.0);
let complex = webrender_traits::ComplexClipRegion::new(
Rect::new(Point2D::new(50.0, 50.0), Size2D::new(100.0, 100.0)),
radius);
webrender_traits::BorderRadius::uniform(20.0));

webrender_traits::ClipRegion::new(&bounds,
vec![complex],
None,
&mut auxiliary_lists_builder)
builder.new_clip_region(&bounds, vec![complex], None)
};

builder.push_stacking_context(webrender_traits::ScrollPolicy::Scrollable,
@@ -128,10 +124,9 @@ fn main() {
rect: Rect::new(Point2D::new(75.0, 75.0), Size2D::new(100.0, 100.0)),
repeat: false,
};
let radius = webrender_traits::BorderRadius::uniform(20.0);
let complex = webrender_traits::ComplexClipRegion::new(
Rect::new(Point2D::new(50.0, 50.0), Size2D::new(100.0, 100.0)),
radius);
webrender_traits::BorderRadius::uniform(20.0));

builder.new_clip_region(&bounds, vec![complex], Some(mask))
};
@@ -218,8 +213,7 @@ fn main() {
font_key,
ColorF::new(1.0, 1.0, 0.0, 1.0),
Au::from_px(32),
Au::from_px(0),
&mut auxiliary_lists_builder);
Au::from_px(0));
}

builder.pop_stacking_context();
@@ -46,6 +46,11 @@ use webrender_traits::{WorldPoint4D, ScrollLayerPixel, as_scroll_parent_rect};
// Removes the clip task dependencies and instead
// draws all the clip instances that affect a primitive
const CLIP_TASK_COLLAPSE: bool = true;

// Special sentinel value recognized by the shader. It is considered to be
// a dummy task that doesn't mask out anything.
const OPAQUE_TASK_INDEX: RenderTaskIndex = RenderTaskIndex(i32::MAX as usize);

const FLOATS_PER_RENDER_TASK_INFO: usize = 8;

pub type LayerMap = HashMap<ScrollLayerId,
@@ -613,7 +618,7 @@ impl AlphaBatcher {
AlphaRenderItem::Primitive(sc_index, prim_index) => {
let mask_task_index = match ctx.layer_masks_tasks.get(&(task.tile_id, sc_index)) {
Some(ref mask_task_id) => render_tasks.get_task_index(mask_task_id, child_pass_index),
None => RenderTaskIndex(i32::MAX as usize), // special sentinel value recognized by the shader
None => OPAQUE_TASK_INDEX,
};
ctx.prim_store.add_prim_to_batch(prim_index,
batch,
@@ -1059,17 +1064,29 @@ impl RenderTask {
layer_clips: &[(StackingContextIndex, MaskCacheInfo)],
tile_id: TileUniqueId)
-> MaskResult {
//CLIP_TODO: combine the clip stack rectangles, not just use the last one
let task_rect = match actual_rect.intersection(&top_clip.1.outer_rect) {

let extra = (top_clip.0, top_clip.1.clone());

// We scan through the clip stack and detect if our actual rectangle
// is in the intersection of all of all the outer bounds,
// and if it's completely inside the intersection of all of the inner bounds.
let result = layer_clips.iter().chain(Some(&extra))
.fold(Some((actual_rect, true)), |current, clip| {
current.and_then(|(rect, covering)|
rect.intersection(&clip.1.outer_rect)
.map(|r| (r, covering & clip.1.inner_rect.contains_rect(&actual_rect))))
});

let task_rect = match result {
None => return MaskResult::Outside,
Some(_) if top_clip.1.inner_rect.contains_rect(&actual_rect) => return MaskResult::Covering,
Some(rect) => rect,
Some((_, true)) => return MaskResult::Covering,
Some((rect, false)) => rect,
};
let extra = (top_clip.0, top_clip.1.clone());
let clips = layer_clips.iter()
.map(|lc| lc.clone())
.chain(Some(extra))
.collect();

MaskResult::Inside(RenderTask {
id: RenderTaskId::Dynamic(RenderTaskKey::CacheMask(mask_key, tile_id)),
children: match dependent {
@@ -1735,7 +1752,6 @@ impl CompiledScreenTile {
}

fn build(self, passes: &mut Vec<RenderPass>) {
//println!("{:#?}", self.main_render_task);
self.main_render_task.assign_to_passes(passes.len() - 1,
passes);
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.