Bug 1493890. Update webrender to commit 2549b791abb3a24c115d03616ddd82e14727b5a1

This commit is contained in:
Jeff Muizelaar 2018-09-25 13:04:02 -04:00
Родитель b23dc7de44
Коммит d830219951
8 изменённых файлов: 51 добавлений и 8 удалений

Просмотреть файл

@ -152,7 +152,7 @@ void main(void) {
int segment = aFlags & 0xff;
int style0 = (aFlags >> 8) & 0xff;
int style1 = (aFlags >> 16) & 0xff;
int clip_mode = (aFlags >> 24) & 0xff;
int clip_mode = (aFlags >> 24) & 0x0f;
vec2 outer_scale = get_outer_corner_scale(segment);
vec2 outer = outer_scale * aRect.zw;

Просмотреть файл

@ -4,6 +4,10 @@
#include shared,ellipse
#define DONT_MIX 0
#define MIX_AA 1
#define MIX_NO_AA 2
// For edges, the colors are the same. For corners, these
// are the colors of each edge making up the corner.
flat varying vec4 vColor0;
@ -70,6 +74,7 @@ vec2 get_outer_corner_scale(int segment) {
void main(void) {
int segment = aFlags & 0xff;
bool do_aa = ((aFlags >> 24) & 0xf0) != 0;
vec2 outer_scale = get_outer_corner_scale(segment);
vec2 outer = outer_scale * aRect.zw;
@ -81,10 +86,10 @@ void main(void) {
case SEGMENT_TOP_RIGHT:
case SEGMENT_BOTTOM_RIGHT:
case SEGMENT_BOTTOM_LEFT:
mix_colors = 1;
mix_colors = do_aa ? MIX_AA : MIX_NO_AA;
break;
default:
mix_colors = 0;
mix_colors = DONT_MIX;
break;
}
@ -104,11 +109,16 @@ void main(void) {
#ifdef WR_FRAGMENT_SHADER
void main(void) {
float aa_range = compute_aa_range(vPos);
bool do_aa = vMixColors != MIX_NO_AA;
float mix_factor = 0.0;
if (vMixColors != 0) {
if (vMixColors != DONT_MIX) {
float d_line = distance_to_line(vColorLine.xy, vColorLine.zw, vPos);
mix_factor = distance_aa(aa_range, -d_line);
if (do_aa) {
mix_factor = distance_aa(aa_range, -d_line);
} else {
mix_factor = d_line + EPSILON >= 0. ? 1.0 : 0.0;
}
}
// Check if inside corner clip-region
@ -122,7 +132,7 @@ void main(void) {
d = max(d_radii_a, -d_radii_b);
}
float alpha = distance_aa(aa_range, d);
float alpha = do_aa ? distance_aa(aa_range, d) : 1.0;
vec4 color = mix(vColor0, vColor1, mix_factor);
oFragColor = color * alpha;
}

Просмотреть файл

@ -103,6 +103,7 @@ pub struct BorderCacheKey {
pub bottom: BorderSideAu,
pub radius: BorderRadiusAu,
pub widths: SideOffsets2D<Au>,
pub do_aa: bool,
pub scale: Au,
}
@ -120,6 +121,7 @@ impl BorderCacheKey {
Au::from_f32_px(widths.left),
),
radius: border.radius.into(),
do_aa: border.do_aa,
scale: Au(0),
}
}
@ -574,6 +576,7 @@ pub struct BorderRenderTaskInfo {
pub border_segments: Vec<BorderSegmentInfo>,
pub size: DeviceIntSize,
pub available_size_dependence: AvailableSizeDependence,
do_aa: bool,
}
#[derive(PartialEq, Eq)]
@ -961,6 +964,7 @@ impl BorderRenderTaskInfo {
border_segments,
size: size.to_i32(),
available_size_dependence: size_dependence,
do_aa: border.do_aa,
})
}
@ -1026,6 +1030,7 @@ impl BorderRenderTaskInfo {
&mut instances,
info.widths,
info.radius,
self.do_aa,
);
}
@ -1094,10 +1099,12 @@ fn add_segment(
instances: &mut Vec<BorderInstance>,
widths: DeviceSize,
radius: DeviceSize,
do_aa: bool,
) {
let base_flags = (segment as i32) |
((style0 as i32) << 8) |
((style1 as i32) << 16);
((style1 as i32) << 16) |
((do_aa as i32) << 28);
let base_instance = BorderInstance {
task_origin: DevicePoint::zero(),

Просмотреть файл

@ -262,6 +262,11 @@ pub struct NormalBorder {
pub top: BorderSide,
pub bottom: BorderSide,
pub radius: BorderRadius,
/// Whether to apply anti-aliasing on the border corners.
///
/// Note that for this to be `false` and work, this requires the borders to
/// be solid, and no border-radius.
pub do_aa: bool,
}
impl NormalBorder {
@ -275,10 +280,27 @@ impl NormalBorder {
b
}
fn can_disable_antialiasing(&self) -> bool {
fn is_valid(style: BorderStyle) -> bool {
style == BorderStyle::Solid || style == BorderStyle::None
}
self.radius.is_zero() &&
is_valid(self.top.style) &&
is_valid(self.left.style) &&
is_valid(self.bottom.style) &&
is_valid(self.right.style)
}
/// Normalizes a border so that we don't render disallowed stuff, like inset
/// borders that are less than two pixels wide.
#[inline]
pub fn normalize(&mut self, widths: &LayoutSideOffsets) {
debug_assert!(
self.do_aa || self.can_disable_antialiasing(),
"Unexpected disabled-antialising in a border, likely won't work or will be ignored"
);
#[inline]
fn renders_small_border_solid(style: BorderStyle) -> bool {
match style {

Просмотреть файл

@ -1 +1 @@
b83ec3fd994b69f31e9c6b6ffa19426b2b98c66a
2549b791abb3a24c115d03616ddd82e14727b5a1

Просмотреть файл

@ -870,12 +870,14 @@ impl YamlFrameReader {
color: colors[3],
style: styles[3],
};
let do_aa = item["do_aa"].as_bool().unwrap_or(true);
Some(BorderDetails::Normal(NormalBorder {
top,
left,
bottom,
right,
radius,
do_aa,
}))
}
"image" | "gradient" | "radial-gradient" => {

Просмотреть файл

@ -869,6 +869,7 @@ impl YamlFrameWriter {
str_node(&mut v, "border-type", "normal");
yaml_node(&mut v, "color", string_vec_yaml(&colors, true));
yaml_node(&mut v, "style", string_vec_yaml(&styles, true));
bool_node(&mut v, "do_aa", details.do_aa);
if let Some(radius_node) = maybe_radius_yaml(&details.radius) {
yaml_node(&mut v, "radius", radius_node);
}

Просмотреть файл

@ -46,6 +46,7 @@ fn string_to_color(color: &str) -> Option<ColorF> {
"white" => Some(ColorF::new(1.0, 1.0, 1.0, 1.0)),
"black" => Some(ColorF::new(0.0, 0.0, 0.0, 1.0)),
"yellow" => Some(ColorF::new(1.0, 1.0, 0.0, 1.0)),
"transparent" => Some(ColorF::new(1.0, 1.0, 1.0, 0.0)),
s => {
let items: Vec<f32> = s.split_whitespace()
.map(|s| f32::from_str(s).unwrap())