diff --git a/webrender/src/frame_builder.rs b/webrender/src/frame_builder.rs index bdad0d3dd6..5ba50b80e6 100644 --- a/webrender/src/frame_builder.rs +++ b/webrender/src/frame_builder.rs @@ -2037,7 +2037,8 @@ impl<'a> LayerRectCalculationAndCullingPass<'a> { let clip_task = RenderTask::new_mask(cache_key, mask_rect, &self.current_clip_stack, - extra); + extra, + prim_screen_rect); let render_tasks = &mut self.render_tasks; prim_metadata.clip_task_id = clip_task.map(|clip_task| { render_tasks.add(clip_task) diff --git a/webrender/src/render_task.rs b/webrender/src/render_task.rs index 18106ed726..cc64c857b3 100644 --- a/webrender/src/render_task.rs +++ b/webrender/src/render_task.rs @@ -244,7 +244,8 @@ impl RenderTask { pub fn new_mask(key: Option, task_rect: DeviceIntRect, raw_clips: &[ClipWorkItem], - extra_clip: Option) + extra_clip: Option, + prim_rect: DeviceIntRect) -> Option { // Filter out all the clip instances that don't contribute to the result let mut inner_rect = Some(task_rect); @@ -283,13 +284,20 @@ impl RenderTask { // In the future, we'll expand this to handle the // more complex types of clip mask geometry. let mut geometry_kind = MaskGeometryKind::Default; - if inner_rect.is_some() && clips.len() == 1 { - let (_, ref info) = clips[0]; - if info.border_corners.is_empty() && - info.image.is_none() && - info.complex_clip_range.get_count() == 1 && - info.layer_clip_range.get_count() == 0 { - geometry_kind = MaskGeometryKind::CornersOnly; + if let Some(inner_rect) = inner_rect { + // If the inner rect completely contains the primitive + // rect, then this mask can't affect the primitive. + if inner_rect.contains_rect(&prim_rect) { + return None; + } + if clips.len() == 1 { + let (_, ref info) = clips[0]; + if info.border_corners.is_empty() && + info.image.is_none() && + info.complex_clip_range.get_count() == 1 && + info.layer_clip_range.get_count() == 0 { + geometry_kind = MaskGeometryKind::CornersOnly; + } } }