Bug 1370530 - Convert more CSS filters to WebRender display items. r=jrmuizel
authorMartin Robinson <mrobinson@igalia.com>
Wed, 07 Jun 2017 03:43:00 -0400
changeset 410844 0048424c784a4a549874c10c8da15eb390653092
parent 410843 48078fb0fcc2442748d5ae52adebb2969831c609
child 410845 47ce8dbb036e5452c0dd060c274cef056306d258
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1370530
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1370530 - Convert more CSS filters to WebRender display items. r=jrmuizel Activate WebRender output for filters that introduce only one pixel differences in tests. Since the filters spec does not seem to specify how color values are rounded, this output should be spec compliant.
gfx/layers/LayersTypes.cpp
layout/painting/nsDisplayList.cpp
layout/reftests/svg/filters/css-filters/reftest.list
--- a/gfx/layers/LayersTypes.cpp
+++ b/gfx/layers/LayersTypes.cpp
@@ -20,16 +20,34 @@ CSSFilter ToCSSFilter(const nsStyleFilte
       };
     }
     case NS_STYLE_FILTER_CONTRAST: {
       return {
           CSSFilterType::CONTRAST,
           filter.GetFilterParameter().GetFactorOrPercentValue(),
       };
     }
+    case NS_STYLE_FILTER_GRAYSCALE: {
+      return {
+          CSSFilterType::GRAYSCALE,
+          filter.GetFilterParameter().GetFactorOrPercentValue(),
+      };
+    }
+    case NS_STYLE_FILTER_INVERT: {
+      return {
+          CSSFilterType::INVERT,
+          filter.GetFilterParameter().GetFactorOrPercentValue(),
+      };
+    }
+    case NS_STYLE_FILTER_SEPIA: {
+      return {
+          CSSFilterType::SEPIA,
+          filter.GetFilterParameter().GetFactorOrPercentValue(),
+      };
+    }
     // All other filter types should be prevented by the code which converts
     // display items into layers.
     default:
       MOZ_ASSERT_UNREACHABLE("Tried to convert an unsupported filter");
       return { CSSFilterType::CONTRAST, 0 };
   }
 }
 
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -8681,22 +8681,29 @@ nsDisplayFilter::GetLayerState(nsDisplay
   if (mFrame->IsFrameOfType(nsIFrame::eSVG)) {
     return LAYER_SVG_EFFECTS;
   }
 
   if (!ShouldUseAdvancedLayer(aManager, gfxPrefs::LayersAllowFilterLayers)) {
     return LAYER_SVG_EFFECTS;
   }
 
+  if (mFrame->StyleEffects()->mOpacity != 1.0f) {
+    return LAYER_SVG_EFFECTS;
+  }
+
   // Due to differences in the way that WebRender filters operate
   // only the brightness and contrast filters use that path. We
   // can gradually enable more filters as WebRender bugs are fixed.
   for (const nsStyleFilter& filter : mFrame->StyleEffects()->mFilters) {
     if (filter.GetType() != NS_STYLE_FILTER_BRIGHTNESS &&
-        filter.GetType() != NS_STYLE_FILTER_CONTRAST) {
+        filter.GetType() != NS_STYLE_FILTER_CONTRAST &&
+        filter.GetType() != NS_STYLE_FILTER_GRAYSCALE &&
+        filter.GetType() != NS_STYLE_FILTER_INVERT &&
+        filter.GetType() != NS_STYLE_FILTER_SEPIA) {
       return LAYER_SVG_EFFECTS;
     }
   }
 
   return LAYER_ACTIVE;
 }
 
 bool nsDisplayFilter::ComputeVisibility(nsDisplayListBuilder* aBuilder,
--- a/layout/reftests/svg/filters/css-filters/reftest.list
+++ b/layout/reftests/svg/filters/css-filters/reftest.list
@@ -26,47 +26,47 @@ skip-if(d2d) == blur-cap-large-radius-on
 == contrast-percent.html contrast-percent-ref.html
 == contrast-reduce.html contrast-reduce-ref.html
 == contrast-zero.html contrast-zero-ref.html
 == drop-shadow.html drop-shadow-ref.html
 == drop-shadow-default-color.html drop-shadow-default-color-ref.html
 == drop-shadow-negative-offset.html drop-shadow-negative-offset-ref.html
 == filter-on-huge-bbox.html pass.svg
 == filter-on-outer-svg.html pass.svg
-fuzzy-if(d2d,1,10000) == grayscale.html grayscale-ref.html
-fuzzy-if(d2d,1,10000) == grayscale-one.html grayscale-one-ref.html
-fuzzy-if(d2d,1,10000) == grayscale-over-one.html grayscale-over-one-ref.html
-fuzzy-if(d2d,1,10000) == grayscale-percent.html grayscale-percent-ref.html
-== grayscale-zero.html grayscale-zero-ref.html
+fuzzy-if(webrender,1,10000) fuzzy-if(d2d,1,10000) == grayscale.html grayscale-ref.html
+fuzzy-if(webrender,1,10000) fuzzy-if(d2d,1,10000) == grayscale-one.html grayscale-one-ref.html
+fuzzy-if(webrender,1,10000) fuzzy-if(d2d,1,10000) == grayscale-over-one.html grayscale-over-one-ref.html
+fuzzy-if(webrender,1,10000) fuzzy-if(d2d,1,10000) == grayscale-percent.html grayscale-percent-ref.html
+fuzzy-if(webrender,1,10000) == grayscale-zero.html grayscale-zero-ref.html
 == hue-rotate.html hue-rotate-ref.html
 == hue-rotate-360.html hue-rotate-360-ref.html
 == hue-rotate-grad.html hue-rotate-grad-ref.html
 fuzzy-if(d2d,2,7500) == hue-rotate-multichannel.html hue-rotate-multichannel-ref.html
 == hue-rotate-negative.html hue-rotate-negative-ref.html
 == hue-rotate-over-360.html hue-rotate-over-360-ref.html
 == hue-rotate-rad.html hue-rotate-rad-ref.html
 == hue-rotate-turn.html hue-rotate-turn-ref.html
 == hue-rotate-zero.html hue-rotate-zero-ref.html
-fuzzy-if(d2d,1,10000) == invert.html invert-ref.html
-== invert-half.html invert-half-ref.html
+fuzzy-if(webrender,1,10000) fuzzy-if(d2d,1,10000) == invert.html invert-ref.html
+fuzzy-if(webrender,1,10000) == invert-half.html invert-half-ref.html
 == invert-one.html invert-one-ref.html
 == invert-over-one.html invert-over-one-ref.html
-fuzzy-if(d2d,1,10000) == invert-percent.html invert-percent-ref.html
+fuzzy-if(webrender,1,10000) fuzzy-if(d2d,1,10000) == invert-percent.html invert-percent-ref.html
 == invert-zero.html invert-zero-ref.html
 fuzzy-if(d2d,1,10000) == opacity.html opacity-ref.html
 == opacity-one.html opacity-one-ref.html
 == opacity-over-one.html opacity-over-one-ref.html
 fuzzy-if(skiaContent,1,10000) == opacity-over-one-translucent-source.html opacity-over-one-translucent-source-ref.html
 fuzzy-if(d2d,1,10000) == opacity-percent.html opacity-percent-ref.html
 == opacity-zero.html opacity-zero-ref.html
 == saturate.html saturate-ref.html
 fuzzy-if(d2d,1,10000) == saturate-desaturate.html saturate-desaturate-ref.html
 == saturate-extreme.html saturate-extreme-ref.html
 == saturate-one.html saturate-one-ref.html
 == saturate-percent.html saturate-percent-ref.html
 fuzzy-if(d2d,1,10000) == saturate-zero.html saturate-zero-ref.html
-fuzzy-if(d2d,1,10000) == sepia.html sepia-ref.html
-fuzzy-if(d2d,1,10000) == sepia-one.html sepia-one-ref.html
-fuzzy-if(d2d,1,10000) == sepia-over-one.html sepia-over-one-ref.html
-fuzzy-if(d2d,1,10000) == sepia-percent.html sepia-percent-ref.html
+fuzzy-if(webrender,1,10000) fuzzy-if(d2d,1,10000) == sepia.html sepia-ref.html
+fuzzy-if(webrender,1,10000) fuzzy-if(d2d,1,10000) == sepia-one.html sepia-one-ref.html
+fuzzy-if(webrender,1,10000) fuzzy-if(d2d,1,10000) == sepia-over-one.html sepia-over-one-ref.html
+fuzzy-if(webrender,1,10000) fuzzy-if(d2d,1,10000) == sepia-percent.html sepia-percent-ref.html
 == sepia-zero.html sepia-zero-ref.html
 
 fuzzy(2,125000) == scale-filtered-content-01.html scale-filtered-content-01-ref.html