Backed out 2 changesets (bug 1571974) for turning bug 1518179 into perma bc failures. on a CLOSED TREE

Backed out changeset dfb21632ea19 (bug 1571974)
Backed out changeset 3549dd471446 (bug 1571974)
This commit is contained in:
Oana Pop Rus 2020-02-03 22:00:29 +02:00
parent 68a2a76615
commit 96b8905f87
5 changed files with 52 additions and 66 deletions

View File

@ -9,37 +9,41 @@
#define LINE_STYLE_DASHED 2
#define LINE_STYLE_WAVY 3
// Fragment position in the coordinate system used for positioning decorations.
// To keep the code independent of whether the line is horizontal or vertical,
// vLocalPos.x is always parallel, and .y always perpendicular, to the line
// being decorated.
// Local space position
varying vec2 vLocalPos;
flat varying float vAxisSelect;
flat varying int vStyle;
flat varying vec4 vParams;
#ifdef WR_VERTEX_SHADER
// The size of the mask tile we're rendering, in pixels.
#define LINE_ORIENTATION_VERTICAL 0
#define LINE_ORIENTATION_HORIZONTAL 1
in vec4 aTaskRect;
// The size of the mask tile. aLocalSize.x is always horizontal and .y vertical,
// regardless of the line's orientation. The size is chosen by
// prim_store::get_line_decoration_sizes.
in vec2 aLocalSize;
// A LINE_STYLE_* value, indicating what sort of line to draw.
in int aStyle;
// 0.0 for a horizontal line, 1.0 for a vertical line.
in float aAxisSelect;
// The thickness of the wavy line itself, not the amplitude of the waves (i.e.,
// the thickness of the final decorated line).
in int aOrientation;
in float aWavyLineThickness;
void main(void) {
vec2 size = mix(aLocalSize, aLocalSize.yx, aAxisSelect);
vec2 size;
switch (aOrientation) {
case LINE_ORIENTATION_HORIZONTAL:
vAxisSelect = 0.0;
size = aLocalSize;
break;
case LINE_ORIENTATION_VERTICAL:
vAxisSelect = 1.0;
size = aLocalSize.yx;
break;
default:
vAxisSelect = 0.0;
size = vec2(0.0);
}
vStyle = aStyle;
switch (vStyle) {
@ -82,7 +86,7 @@ void main(void) {
vParams = vec4(0.0);
}
vLocalPos = mix(aPosition.xy, aPosition.yx, aAxisSelect) * size;
vLocalPos = aPosition.xy * aLocalSize;
gl_Position = uTransform * vec4(aTaskRect.xy + aTaskRect.zw * aPosition.xy, 0.0, 1.0);
}
@ -94,10 +98,13 @@ void main(void) {
void main(void) {
// Find the appropriate distance to apply the step over.
vec2 pos = vLocalPos;
float aa_range = compute_aa_range(pos);
vec2 local_pos = vLocalPos;
float aa_range = compute_aa_range(local_pos);
float alpha = 1.0;
// Select the x/y coord, depending on which axis this edge is.
vec2 pos = mix(local_pos.xy, local_pos.yx, vAxisSelect);
switch (vStyle) {
case LINE_STYLE_SOLID: {
break;

View File

@ -4129,32 +4129,14 @@ pub fn get_raster_rects(
Some((clipped.to_i32(), unclipped))
}
/// Choose the decoration mask tile size for a given line.
///
/// Given a line with overall size `rect_size` and the given `orientation`,
/// return the dimensions of a single mask tile for the decoration pattern
/// described by `style` and `wavy_line_thickness`.
///
/// If `style` is `Solid`, no mask tile is necessary; return `None`. The other
/// styles each have their own characteristic periods of repetition, so for each
/// one, this function returns a `LayoutSize` with the right aspect ratio and
/// whose specific size is convenient for the `cs_line_decoration.glsl` fragment
/// shader to work with. The shader uses a local coordinate space in which the
/// tile fills a rectangle with one corner at the origin, and with the size this
/// function returns.
///
/// The returned size is not necessarily in pixels; device scaling and other
/// concerns can still affect the actual task size.
///
/// Regardless of whether `orientation` is `Vertical` or `Horizontal`, the
/// `width` and `height` of the returned size are always horizontal and
/// vertical, respectively.
pub fn get_line_decoration_size(
/// Get the inline (horizontal) and block (vertical) sizes
/// for a given line decoration.
pub fn get_line_decoration_sizes(
rect_size: &LayoutSize,
orientation: LineOrientation,
style: LineStyle,
wavy_line_thickness: f32,
) -> Option<LayoutSize> {
) -> Option<(f32, f32)> {
let h = match orientation {
LineOrientation::Horizontal => rect_size.height,
LineOrientation::Vertical => rect_size.width,
@ -4166,20 +4148,20 @@ pub fn get_line_decoration_size(
// quality on a wider range of inputs!
// See nsCSSRendering::PaintDecorationLine in Gecko.
let (parallel, perpendicular) = match style {
match style {
LineStyle::Solid => {
return None;
None
}
LineStyle::Dashed => {
let dash_length = (3.0 * h).min(64.0).max(1.0);
(2.0 * dash_length, 4.0)
Some((2.0 * dash_length, 4.0))
}
LineStyle::Dotted => {
let diameter = h.min(64.0).max(1.0);
let period = 2.0 * diameter;
(period, diameter)
Some((period, diameter))
}
LineStyle::Wavy => {
let line_thickness = wavy_line_thickness.max(1.0);
@ -4187,14 +4169,9 @@ pub fn get_line_decoration_size(
let flat_length = ((line_thickness - 1.0) * 2.0).max(1.0);
let approx_period = 2.0 * (slope_length + flat_length);
(approx_period, h)
Some((approx_period, h))
}
};
Some(match orientation {
LineOrientation::Horizontal => LayoutSize::new(parallel, perpendicular),
LineOrientation::Vertical => LayoutSize::new(perpendicular, parallel),
})
}
}
fn update_opacity_binding(

View File

@ -773,10 +773,7 @@ impl TextureCacheRenderTarget {
task_rect: target_rect.0.to_f32(),
local_size: info.local_size,
style: info.style as i32,
axis_select: match info.orientation {
LineOrientation::Horizontal => 0.0,
LineOrientation::Vertical => 1.0,
},
orientation: info.orientation as i32,
wavy_line_thickness: info.wavy_line_thickness,
});
}
@ -1059,7 +1056,7 @@ pub struct LineDecorationJob {
pub local_size: LayoutSize,
pub wavy_line_thickness: f32,
pub style: i32,
pub axis_select: f32,
pub orientation: i32,
}
#[cfg_attr(feature = "capture", derive(Serialize))]

View File

@ -454,9 +454,9 @@ pub(crate) mod desc {
kind: VertexAttributeKind::I32,
},
VertexAttribute {
name: "aAxisSelect",
name: "aOrientation",
count: 1,
kind: VertexAttributeKind::F32,
kind: VertexAttributeKind::I32,
},
],
};

View File

@ -27,7 +27,7 @@ use crate::prim_store::{PrimitiveInstance, PrimitiveSceneData};
use crate::prim_store::{PrimitiveInstanceKind, NinePatchDescriptor, PrimitiveStore};
use crate::prim_store::{ScrollNodeAndClipChain, PictureIndex};
use crate::prim_store::{InternablePrimitive, SegmentInstanceIndex};
use crate::prim_store::{register_prim_chase_id, get_line_decoration_size};
use crate::prim_store::{register_prim_chase_id, get_line_decoration_sizes};
use crate::prim_store::{SpaceSnapper};
use crate::prim_store::backdrop::Backdrop;
use crate::prim_store::borders::{ImageBorder, NormalBorderPrim};
@ -2749,28 +2749,33 @@ impl<'a> SceneBuilder<'a> {
// pixel ratio or transform.
let mut info = info.clone();
let size = get_line_decoration_size(
let size = get_line_decoration_sizes(
&info.rect.size,
orientation,
style,
wavy_line_thickness,
);
let cache_key = size.map(|size| {
let cache_key = size.map(|(inline_size, block_size)| {
let size = match orientation {
LineOrientation::Horizontal => LayoutSize::new(inline_size, block_size),
LineOrientation::Vertical => LayoutSize::new(block_size, inline_size),
};
// If dotted, adjust the clip rect to ensure we don't draw a final
// partial dot.
if style == LineStyle::Dotted {
let clip_size = match orientation {
LineOrientation::Horizontal => {
LayoutSize::new(
size.width * (info.rect.size.width / size.width).floor(),
inline_size * (info.rect.size.width / inline_size).floor(),
info.rect.size.height,
)
}
LineOrientation::Vertical => {
LayoutSize::new(
info.rect.size.width,
size.height * (info.rect.size.height / size.height).floor(),
inline_size * (info.rect.size.height / inline_size).floor(),
)
}
};