diff --git a/webrender/src/border.rs b/webrender/src/border.rs index a249148f9d..1e01e9d20e 100644 --- a/webrender/src/border.rs +++ b/webrender/src/border.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use api::{BorderRadius, BorderSide, BorderStyle, BorderWidths, ColorF, LayerPoint}; +use api::{BorderRadius, BorderSide, BorderStyle, BorderWidths, ClipMode, ColorF, LayerPoint}; use api::{LayerPrimitiveInfo, LayerRect, LayerSize, NormalBorder, RepeatMode, TexelRect}; use clip::ClipSource; use ellipse::Ellipse; @@ -373,6 +373,63 @@ impl<'a> DisplayListFlattener<'a> { let top = &border.top; let bottom = &border.bottom; + let constant_color = left.color; + let is_simple_border = [left, top, right, bottom].iter().all(|edge| { + edge.style == BorderStyle::Solid && + edge.color == constant_color + }); + + if is_simple_border { + let extra_clips = vec![ + ClipSource::new_rounded_rect( + info.rect, + border.radius, + ClipMode::Clip, + ), + ClipSource::new_rounded_rect( + LayerRect::new( + LayerPoint::new( + info.rect.origin.x + widths.left, + info.rect.origin.y + widths.top, + ), + LayerSize::new( + info.rect.size.width - widths.left - widths.right, + info.rect.size.height - widths.top - widths.bottom, + ), + ), + BorderRadius { + top_left: LayerSize::new( + (border.radius.top_left.width - widths.left).max(0.0), + (border.radius.top_left.height - widths.top).max(0.0), + ), + top_right: LayerSize::new( + (border.radius.top_right.width - widths.right).max(0.0), + (border.radius.top_right.height - widths.top).max(0.0), + ), + bottom_left: LayerSize::new( + (border.radius.bottom_left.width - widths.left).max(0.0), + (border.radius.bottom_left.height - widths.bottom).max(0.0), + ), + bottom_right: LayerSize::new( + (border.radius.bottom_right.width - widths.right).max(0.0), + (border.radius.bottom_right.height - widths.bottom).max(0.0), + ), + }, + ClipMode::ClipOut, + ), + ]; + + self.add_solid_rectangle( + clip_and_scroll, + info, + border.top.color, + None, + extra_clips, + ); + + return; + } + let corners = [ border.get_corner( left, @@ -465,6 +522,7 @@ impl<'a> DisplayListFlattener<'a> { info, border.top.color, Some(descriptor), + Vec::new(), ); } @@ -481,6 +539,7 @@ impl<'a> DisplayListFlattener<'a> { info, border.left.color, Some(descriptor), + Vec::new(), ); } @@ -497,6 +556,7 @@ impl<'a> DisplayListFlattener<'a> { info, border.right.color, Some(descriptor), + Vec::new(), ); } @@ -515,6 +575,7 @@ impl<'a> DisplayListFlattener<'a> { info, border.bottom.color, Some(descriptor), + Vec::new(), ); } } else { diff --git a/webrender/src/display_list_flattener.rs b/webrender/src/display_list_flattener.rs index ed4d110c3f..9f8630b1f8 100644 --- a/webrender/src/display_list_flattener.rs +++ b/webrender/src/display_list_flattener.rs @@ -349,6 +349,7 @@ impl<'a> DisplayListFlattener<'a> { &info, bg_color, None, + Vec::new(), ); } } @@ -700,6 +701,7 @@ impl<'a> DisplayListFlattener<'a> { &prim_info, info.color, None, + Vec::new(), ); } SpecificDisplayItem::ClearRectangle => { @@ -1512,6 +1514,7 @@ impl<'a> DisplayListFlattener<'a> { info: &LayerPrimitiveInfo, color: ColorF, segments: Option, + extra_clips: Vec, ) { if color.a == 0.0 { // Don't add transparent rectangles to the draw list, but do consider them for hit @@ -1530,7 +1533,7 @@ impl<'a> DisplayListFlattener<'a> { self.add_primitive( clip_and_scroll, info, - Vec::new(), + extra_clips, PrimitiveContainer::Brush(prim), ); } diff --git a/wrench/reftests/border/border-clamp-corner-radius-ref.png b/wrench/reftests/border/border-clamp-corner-radius-ref.png deleted file mode 100644 index 69c73c92b2..0000000000 Binary files a/wrench/reftests/border/border-clamp-corner-radius-ref.png and /dev/null differ diff --git a/wrench/reftests/border/border-clamp-corner-radius.png b/wrench/reftests/border/border-clamp-corner-radius.png new file mode 100644 index 0000000000..bdeda43864 Binary files /dev/null and b/wrench/reftests/border/border-clamp-corner-radius.png differ diff --git a/wrench/reftests/border/border-radii.png b/wrench/reftests/border/border-radii.png index 87d5b674fd..5e72e1646a 100644 Binary files a/wrench/reftests/border/border-radii.png and b/wrench/reftests/border/border-radii.png differ diff --git a/wrench/reftests/border/reftest.list b/wrench/reftests/border/reftest.list index 485ea50ebd..c6de4090f9 100644 --- a/wrench/reftests/border/reftest.list +++ b/wrench/reftests/border/reftest.list @@ -1,4 +1,4 @@ -== border-clamp-corner-radius.yaml border-clamp-corner-radius-ref.png +== border-clamp-corner-radius.yaml border-clamp-corner-radius.png == border-gradient-simple.yaml border-gradient-simple-ref.yaml == border-radial-gradient-simple.yaml border-radial-gradient-simple-ref.yaml == border-radii.yaml border-radii.png diff --git a/wrench/reftests/clip/border-with-rounded-clip-ref.png b/wrench/reftests/clip/border-with-rounded-clip-ref.png deleted file mode 100644 index dc775d6e44..0000000000 Binary files a/wrench/reftests/clip/border-with-rounded-clip-ref.png and /dev/null differ diff --git a/wrench/reftests/clip/border-with-rounded-clip.png b/wrench/reftests/clip/border-with-rounded-clip.png new file mode 100644 index 0000000000..676f206991 Binary files /dev/null and b/wrench/reftests/clip/border-with-rounded-clip.png differ diff --git a/wrench/reftests/clip/reftest.list b/wrench/reftests/clip/reftest.list index 942fc7c256..4250f1ca17 100644 --- a/wrench/reftests/clip/reftest.list +++ b/wrench/reftests/clip/reftest.list @@ -1,4 +1,4 @@ -== border-with-rounded-clip.yaml border-with-rounded-clip-ref.png +== border-with-rounded-clip.yaml border-with-rounded-clip.png == clip-mode.yaml clip-mode.png == clip-ellipse.yaml clip-ellipse.png == clip-45-degree-rotation.yaml clip-45-degree-rotation-ref.png diff --git a/wrench/reftests/mask/rounded-corners.png b/wrench/reftests/mask/rounded-corners.png index b55f7baba7..3acf447cd1 100644 Binary files a/wrench/reftests/mask/rounded-corners.png and b/wrench/reftests/mask/rounded-corners.png differ diff --git a/wrench/reftests/transforms/rotated-image.png b/wrench/reftests/transforms/rotated-image.png index f19eaa04c9..8e58ae42ad 100644 Binary files a/wrench/reftests/transforms/rotated-image.png and b/wrench/reftests/transforms/rotated-image.png differ