Backed out changeset fed45fbadc26 (bug 1656711) for webrender build bustage

This commit is contained in:
Dorel Luca 2020-08-03 00:59:31 +03:00
Родитель 9db06357a1
Коммит eb411c9e05
9 изменённых файлов: 36 добавлений и 42 удалений

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

@ -70,7 +70,7 @@ const OPACITY_EPSILON: f32 = 0.001;
#[cfg_attr(feature = "replay", derive(Deserialize))] #[cfg_attr(feature = "replay", derive(Deserialize))]
pub enum Filter { pub enum Filter {
Identity, Identity,
Blur(f32, f32), Blur(f32),
Brightness(f32), Brightness(f32),
Contrast(f32), Contrast(f32),
Grayscale(f32), Grayscale(f32),
@ -116,7 +116,7 @@ impl Filter {
pub fn is_noop(&self) -> bool { pub fn is_noop(&self) -> bool {
match *self { match *self {
Filter::Identity => false, // this is intentional Filter::Identity => false, // this is intentional
Filter::Blur(width, height) => width == 0.0 && height == 0.0, Filter::Blur(length) => length == 0.0,
Filter::Brightness(amount) => amount == 1.0, Filter::Brightness(amount) => amount == 1.0,
Filter::Contrast(amount) => amount == 1.0, Filter::Contrast(amount) => amount == 1.0,
Filter::Grayscale(amount) => amount == 0.0, Filter::Grayscale(amount) => amount == 0.0,
@ -179,7 +179,7 @@ impl From<FilterOp> for Filter {
fn from(op: FilterOp) -> Self { fn from(op: FilterOp) -> Self {
match op { match op {
FilterOp::Identity => Filter::Identity, FilterOp::Identity => Filter::Identity,
FilterOp::Blur(w, h) => Filter::Blur(w, h), FilterOp::Blur(r) => Filter::Blur(r),
FilterOp::Brightness(b) => Filter::Brightness(b), FilterOp::Brightness(b) => Filter::Brightness(b),
FilterOp::Contrast(c) => Filter::Contrast(c), FilterOp::Contrast(c) => Filter::Contrast(c),
FilterOp::Grayscale(g) => Filter::Grayscale(g), FilterOp::Grayscale(g) => Filter::Grayscale(g),

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

@ -4138,10 +4138,9 @@ impl PictureCompositeMode {
let mut result_rect = picture_rect; let mut result_rect = picture_rect;
match self { match self {
PictureCompositeMode::Filter(filter) => match filter { PictureCompositeMode::Filter(filter) => match filter {
Filter::Blur(width, height) => { Filter::Blur(blur_radius) => {
let width_factor = clamp_blur_radius(*width, scale_factors).ceil() * BLUR_SAMPLE_SCALE; let inflation_factor = clamp_blur_radius(*blur_radius, scale_factors).ceil() * BLUR_SAMPLE_SCALE;
let height_factor = clamp_blur_radius(*height, scale_factors).ceil() * BLUR_SAMPLE_SCALE; result_rect = picture_rect.inflate(inflation_factor, inflation_factor);
result_rect = picture_rect.inflate(width_factor, height_factor);
}, },
Filter::DropShadows(shadows) => { Filter::DropShadows(shadows) => {
let mut max_inflation: f32 = 0.0; let mut max_inflation: f32 = 0.0;
@ -4159,9 +4158,8 @@ impl PictureCompositeMode {
let output_rect = match primitive.kind { let output_rect = match primitive.kind {
FilterPrimitiveKind::Blur(ref primitive) => { FilterPrimitiveKind::Blur(ref primitive) => {
let input = primitive.input.to_index(cur_index).map(|index| output_rects[index]).unwrap_or(picture_rect); let input = primitive.input.to_index(cur_index).map(|index| output_rects[index]).unwrap_or(picture_rect);
let width_factor = primitive.width.round() * BLUR_SAMPLE_SCALE; let inflation_factor = primitive.radius.round() * BLUR_SAMPLE_SCALE;
let height_factor = primitive.height.round() * BLUR_SAMPLE_SCALE; input.inflate(inflation_factor, inflation_factor)
input.inflate(width_factor, height_factor)
} }
FilterPrimitiveKind::DropShadow(ref primitive) => { FilterPrimitiveKind::DropShadow(ref primitive) => {
let inflation_factor = primitive.shadow.blur_radius.ceil() * BLUR_SAMPLE_SCALE; let inflation_factor = primitive.shadow.blur_radius.ceil() * BLUR_SAMPLE_SCALE;
@ -4888,12 +4886,11 @@ impl PicturePrimitive {
} }
let dep_info = match raster_config.composite_mode { let dep_info = match raster_config.composite_mode {
PictureCompositeMode::Filter(Filter::Blur(width, height)) => { PictureCompositeMode::Filter(Filter::Blur(blur_radius)) => {
let width_std_deviation = clamp_blur_radius(width, scale_factors) * device_pixel_scale.0; let blur_std_deviation = clamp_blur_radius(blur_radius, scale_factors) * device_pixel_scale.0;
let height_std_deviation = clamp_blur_radius(height, scale_factors) * device_pixel_scale.0;
let mut blur_std_deviation = DeviceSize::new( let mut blur_std_deviation = DeviceSize::new(
width_std_deviation * scale_factors.0, blur_std_deviation * scale_factors.0,
height_std_deviation * scale_factors.1 blur_std_deviation * scale_factors.1
); );
let mut device_rect = if self.options.inflate_if_required { let mut device_rect = if self.options.inflate_if_required {
let inflation_factor = frame_state.surfaces[raster_config.surface_index.0].inflation_factor; let inflation_factor = frame_state.surfaces[raster_config.surface_index.0].inflation_factor;
@ -5937,8 +5934,8 @@ impl PicturePrimitive {
let mut inflation_factor = 0.0; let mut inflation_factor = 0.0;
if self.options.inflate_if_required { if self.options.inflate_if_required {
match composite_mode { match composite_mode {
PictureCompositeMode::Filter(Filter::Blur(width, height)) => { PictureCompositeMode::Filter(Filter::Blur(blur_radius)) => {
let blur_radius = f32::max(clamp_blur_radius(width, scale_factors), clamp_blur_radius(height, scale_factors)); let blur_radius = clamp_blur_radius(blur_radius, scale_factors);
// The amount of extra space needed for primitives inside // The amount of extra space needed for primitives inside
// this picture to ensure the visibility check is correct. // this picture to ensure the visibility check is correct.
inflation_factor = blur_radius * BLUR_SAMPLE_SCALE; inflation_factor = blur_radius * BLUR_SAMPLE_SCALE;
@ -5947,8 +5944,7 @@ impl PicturePrimitive {
let mut max = 0.0; let mut max = 0.0;
for primitive in primitives { for primitive in primitives {
if let FilterPrimitiveKind::Blur(ref blur) = primitive.kind { if let FilterPrimitiveKind::Blur(ref blur) = primitive.kind {
max = f32::max(max, blur.width); max = f32::max(max, blur.radius);
max = f32::max(max, blur.height);
} }
} }
inflation_factor = clamp_blur_radius(max, scale_factors) * BLUR_SAMPLE_SCALE; inflation_factor = clamp_blur_radius(max, scale_factors) * BLUR_SAMPLE_SCALE;

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

@ -60,7 +60,7 @@ pub enum FilterPrimitiveKey {
Identity(ColorSpace, FilterPrimitiveInput), Identity(ColorSpace, FilterPrimitiveInput),
Flood(ColorSpace, ColorU), Flood(ColorSpace, ColorU),
Blend(ColorSpace, MixBlendMode, FilterPrimitiveInput, FilterPrimitiveInput), Blend(ColorSpace, MixBlendMode, FilterPrimitiveInput, FilterPrimitiveInput),
Blur(ColorSpace, Au, Au, FilterPrimitiveInput), Blur(ColorSpace, Au, FilterPrimitiveInput),
Opacity(ColorSpace, Au, FilterPrimitiveInput), Opacity(ColorSpace, Au, FilterPrimitiveInput),
ColorMatrix(ColorSpace, [Au; 20], FilterPrimitiveInput), ColorMatrix(ColorSpace, [Au; 20], FilterPrimitiveInput),
DropShadow(ColorSpace, (VectorKey, Au, ColorU), FilterPrimitiveInput), DropShadow(ColorSpace, (VectorKey, Au, ColorU), FilterPrimitiveInput),
@ -79,7 +79,7 @@ pub enum PictureCompositeKey {
Identity, Identity,
// FilterOp // FilterOp
Blur(Au, Au), Blur(Au),
Brightness(Au), Brightness(Au),
Contrast(Au), Contrast(Au),
Grayscale(Au), Grayscale(Au),
@ -140,8 +140,7 @@ impl From<Option<PictureCompositeMode>> for PictureCompositeKey {
} }
Some(PictureCompositeMode::Filter(op)) => { Some(PictureCompositeMode::Filter(op)) => {
match op { match op {
Filter::Blur(width, height) => Filter::Blur(value) => PictureCompositeKey::Blur(Au::from_f32_px(value)),
PictureCompositeKey::Blur(Au::from_f32_px(width), Au::from_f32_px(height)),
Filter::Brightness(value) => PictureCompositeKey::Brightness(Au::from_f32_px(value)), Filter::Brightness(value) => PictureCompositeKey::Brightness(Au::from_f32_px(value)),
Filter::Contrast(value) => PictureCompositeKey::Contrast(Au::from_f32_px(value)), Filter::Contrast(value) => PictureCompositeKey::Contrast(Au::from_f32_px(value)),
Filter::Grayscale(value) => PictureCompositeKey::Grayscale(Au::from_f32_px(value)), Filter::Grayscale(value) => PictureCompositeKey::Grayscale(Au::from_f32_px(value)),
@ -189,8 +188,7 @@ impl From<Option<PictureCompositeMode>> for PictureCompositeKey {
FilterPrimitiveKind::Identity(identity) => FilterPrimitiveKey::Identity(primitive.color_space, identity.input), FilterPrimitiveKind::Identity(identity) => FilterPrimitiveKey::Identity(primitive.color_space, identity.input),
FilterPrimitiveKind::Blend(blend) => FilterPrimitiveKey::Blend(primitive.color_space, blend.mode, blend.input1, blend.input2), FilterPrimitiveKind::Blend(blend) => FilterPrimitiveKey::Blend(primitive.color_space, blend.mode, blend.input1, blend.input2),
FilterPrimitiveKind::Flood(flood) => FilterPrimitiveKey::Flood(primitive.color_space, flood.color.into()), FilterPrimitiveKind::Flood(flood) => FilterPrimitiveKey::Flood(primitive.color_space, flood.color.into()),
FilterPrimitiveKind::Blur(blur) => FilterPrimitiveKind::Blur(blur) => FilterPrimitiveKey::Blur(primitive.color_space, Au::from_f32_px(blur.radius), blur.input),
FilterPrimitiveKey::Blur(primitive.color_space, Au::from_f32_px(blur.width), Au::from_f32_px(blur.height), blur.input),
FilterPrimitiveKind::Opacity(opacity) => FilterPrimitiveKind::Opacity(opacity) =>
FilterPrimitiveKey::Opacity(primitive.color_space, Au::from_f32_px(opacity.opacity), opacity.input), FilterPrimitiveKey::Opacity(primitive.color_space, Au::from_f32_px(opacity.opacity), opacity.input),
FilterPrimitiveKind::ColorMatrix(color_matrix) => { FilterPrimitiveKind::ColorMatrix(color_matrix) => {

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

@ -946,8 +946,7 @@ impl RenderTask {
)) ))
} }
FilterPrimitiveKind::Blur(ref blur) => { FilterPrimitiveKind::Blur(ref blur) => {
let width_std_deviation = blur.width * device_pixel_scale.0; let blur_std_deviation = blur.radius * device_pixel_scale.0;
let height_std_deviation = blur.height * device_pixel_scale.0;
let input_task_id = get_task_input( let input_task_id = get_task_input(
&blur.input, &blur.input,
filter_primitives, filter_primitives,
@ -959,7 +958,7 @@ impl RenderTask {
); );
RenderTask::new_blur( RenderTask::new_blur(
DeviceSize::new(width_std_deviation, height_std_deviation), DeviceSize::new(blur_std_deviation, blur_std_deviation),
// TODO: This is a hack to ensure that a blur task's input is always // TODO: This is a hack to ensure that a blur task's input is always
// in the blur's previous pass. // in the blur's previous pass.
render_tasks.add().init(RenderTask::new_svg_filter_primitive( render_tasks.add().init(RenderTask::new_svg_filter_primitive(

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

@ -2329,7 +2329,7 @@ impl<'a> SceneBuilder<'a> {
// blur radius is 0, the code in Picture::prepare_for_render will // blur radius is 0, the code in Picture::prepare_for_render will
// detect this and mark the picture to be drawn directly into the // detect this and mark the picture to be drawn directly into the
// parent picture, which avoids an intermediate surface and blur. // parent picture, which avoids an intermediate surface and blur.
let blur_filter = Filter::Blur(std_deviation, std_deviation); let blur_filter = Filter::Blur(std_deviation);
let composite_mode = if blur_filter.is_noop() { let composite_mode = if blur_filter.is_noop() {
None None
} else { } else {

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

@ -934,8 +934,7 @@ impl FloodPrimitive {
#[derive(Clone, Copy, Debug, Default, Deserialize, PartialEq, Serialize, PeekPoke)] #[derive(Clone, Copy, Debug, Default, Deserialize, PartialEq, Serialize, PeekPoke)]
pub struct BlurPrimitive { pub struct BlurPrimitive {
pub input: FilterPrimitiveInput, pub input: FilterPrimitiveInput,
pub width: f32, pub radius: f32,
pub height: f32,
} }
#[repr(C)] #[repr(C)]
@ -1062,7 +1061,7 @@ pub enum FilterOp {
/// Filter that does no transformation of the colors, needed for /// Filter that does no transformation of the colors, needed for
/// debug purposes only. /// debug purposes only.
Identity, Identity,
Blur(f32, f32), Blur(f32),
Brightness(f32), Brightness(f32),
Contrast(f32), Contrast(f32),
Grayscale(f32), Grayscale(f32),

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

@ -573,8 +573,8 @@ impl YamlHelper for Yaml {
("component-transfer", _, _) => { ("component-transfer", _, _) => {
Some(FilterOp::ComponentTransfer) Some(FilterOp::ComponentTransfer)
} }
("blur", ref args, _) if args.len() == 2 => { ("blur", ref args, _) if args.len() == 1 => {
Some(FilterOp::Blur(args[0].parse().unwrap(), args[1].parse().unwrap())) Some(FilterOp::Blur(args[0].parse().unwrap()))
} }
("brightness", ref args, _) if args.len() == 1 => { ("brightness", ref args, _) if args.len() == 1 => {
Some(FilterOp::Brightness(args[0].parse().unwrap())) Some(FilterOp::Brightness(args[0].parse().unwrap()))
@ -729,8 +729,7 @@ impl YamlHelper for Yaml {
"blur" => { "blur" => {
FilterPrimitiveKind::Blur(BlurPrimitive { FilterPrimitiveKind::Blur(BlurPrimitive {
input: self["in"].as_filter_input().unwrap(), input: self["in"].as_filter_input().unwrap(),
width: self["width"].as_f32().unwrap(), radius: self["radius"].as_f32().unwrap(),
height: self["height"].as_f32().unwrap(),
}) })
} }
"opacity" => { "opacity" => {

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

@ -230,9 +230,13 @@ bool FilterInstance::BuildWebRenderFilters(nsIFrame* aFilteredFrame,
const GaussianBlurAttributes& blur = attr.as<GaussianBlurAttributes>(); const GaussianBlurAttributes& blur = attr.as<GaussianBlurAttributes>();
const Size& stdDev = blur.mStdDeviation; const Size& stdDev = blur.mStdDeviation;
if (stdDev.width != 0.0 || stdDev.height != 0.0) { if (stdDev.width != stdDev.height) {
aWrFilters.filters.AppendElement( return false;
wr::FilterOp::Blur(stdDev.width, stdDev.height)); }
float radius = stdDev.width;
if (radius != 0.0) {
aWrFilters.filters.AppendElement(wr::FilterOp::Blur(radius));
} else { } else {
filterIsNoop = true; filterIsNoop = true;
} }

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

@ -1163,9 +1163,8 @@ bool SVGIntegrationUtils::CreateWebRenderCSSFilters(
// TODO(emilio): we should go directly from css pixels -> device pixels. // TODO(emilio): we should go directly from css pixels -> device pixels.
float appUnitsPerDevPixel = float appUnitsPerDevPixel =
aFrame->PresContext()->AppUnitsPerDevPixel(); aFrame->PresContext()->AppUnitsPerDevPixel();
float radius = NSAppUnitsToFloatPixels(filter.AsBlur().ToAppUnits(), wrFilters.AppendElement(wr::FilterOp::Blur(NSAppUnitsToFloatPixels(
appUnitsPerDevPixel); filter.AsBlur().ToAppUnits(), appUnitsPerDevPixel)));
wrFilters.AppendElement(wr::FilterOp::Blur(radius, radius));
break; break;
} }
case StyleFilter::Tag::DropShadow: { case StyleFilter::Tag::DropShadow: {