Bug 1058753 - Cap CSS/SVG blur radii to smaller value when rendering in software. r=mstange
authorMax Vujovic <mvujovic@adobe.com>
Wed, 03 Sep 2014 13:31:55 -0700
changeset 203464 3ec65eb63c176923c349b02d4719625a07ac1908
parent 203463 1b4ba4d597ed7f58cf50c0f6f9bda063c789445f
child 203465 0da762e6868a1601e6f78dfe26aa9ccdd1d94d2b
push id27428
push usercbook@mozilla.com
push dateThu, 04 Sep 2014 13:00:04 +0000
treeherdermozilla-central@7bfd030e8fc8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1058753
milestone35.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 1058753 - Cap CSS/SVG blur radii to smaller value when rendering in software. r=mstange
gfx/2d/FilterNodeSoftware.cpp
layout/reftests/svg/filters/css-filters/blur-cap-large-radius-on-software-ref.html
layout/reftests/svg/filters/css-filters/blur-cap-large-radius-on-software.html
layout/reftests/svg/filters/css-filters/reftest.list
layout/reftests/svg/filters/feGaussianBlur-cap-large-directional-radius-on-software-ref.html
layout/reftests/svg/filters/feGaussianBlur-cap-large-directional-radius-on-software.html
layout/reftests/svg/filters/reftest.list
--- a/gfx/2d/FilterNodeSoftware.cpp
+++ b/gfx/2d/FilterNodeSoftware.cpp
@@ -2916,23 +2916,30 @@ FilterNodeBlurXYSoftware::GetOutputRectI
   IntRect srcOutput = GetInputRectInRect(IN_GAUSSIAN_BLUR_IN, srcRequest);
   return InflatedSourceOrDestRect(srcOutput).Intersect(aRect);
 }
 
 FilterNodeGaussianBlurSoftware::FilterNodeGaussianBlurSoftware()
  : mStdDeviation(0)
 {}
 
+static float
+ClampStdDeviation(float aStdDeviation)
+{
+  // Cap software blur radius for performance reasons.
+  return std::min(std::max(0.0f, aStdDeviation), 100.0f);
+}
+
 void
 FilterNodeGaussianBlurSoftware::SetAttribute(uint32_t aIndex,
                                              float aStdDeviation)
 {
   switch (aIndex) {
     case ATT_GAUSSIAN_BLUR_STD_DEVIATION:
-      mStdDeviation = std::max(0.0f, aStdDeviation);
+      mStdDeviation = ClampStdDeviation(aStdDeviation);
       break;
     default:
       MOZ_CRASH();
   }
   Invalidate();
 }
 
 Size
@@ -2946,17 +2953,17 @@ FilterNodeDirectionalBlurSoftware::Filte
 {}
 
 void
 FilterNodeDirectionalBlurSoftware::SetAttribute(uint32_t aIndex,
                                                 Float aStdDeviation)
 {
   switch (aIndex) {
     case ATT_DIRECTIONAL_BLUR_STD_DEVIATION:
-      mStdDeviation = std::max(0.0f, aStdDeviation);
+      mStdDeviation = ClampStdDeviation(aStdDeviation);
       break;
     default:
       MOZ_CRASH();
   }
   Invalidate();
 }
 
 void
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/filters/css-filters/blur-cap-large-radius-on-software-ref.html
@@ -0,0 +1,22 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<!DOCTYPE html>
+<html>
+<head>
+  <title>CSS Filters: Cap Blur Radius When Rendering in Software</title>
+  <style type="text/css">
+    #target {
+      filter: blur(100px);
+      background-color: #0f0;
+      width: 100px;
+      height: 100px;
+    }
+  </style>
+</head>
+<body>
+  <p>You should see a blurred green square.</p>
+  <div id="target"></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/filters/css-filters/blur-cap-large-radius-on-software.html
@@ -0,0 +1,26 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<!DOCTYPE html>
+<html>
+<head>
+  <title>CSS Filters: Cap Blur Radius When Rendering in Software</title>
+  <!--
+    When rendering in software, Firefox should cap large blur radii to a smaller
+    value in order to keep performance acceptable.
+  -->
+  <style type="text/css">
+    #target {
+      filter: blur(1000000px);
+      background-color: #0f0;
+      width: 100px;
+      height: 100px;
+    }
+  </style>
+</head>
+<body>
+  <p>You should see a blurred green square.</p>
+  <div id="target"></div>
+</body>
+</html>
--- a/layout/reftests/svg/filters/css-filters/reftest.list
+++ b/layout/reftests/svg/filters/css-filters/reftest.list
@@ -2,16 +2,17 @@
 # e.g. filter: blur(3px)
 
 default-preferences pref(layout.css.filters.enabled,true)
 
 == blur.html blur-ref.html
 == blur.svg blur-ref.svg
 == blur-calc.html blur-calc-ref.html
 == blur-calc-negative.html blur-calc-negative-ref.html
+skip-if(d2d) pref(layers.acceleration.disabled,true) == blur-cap-large-radius-on-software.html blur-cap-large-radius-on-software-ref.html
 == blur-zero-radius.html blur-zero-radius-ref.html
 == blur-zoomed-page.html blur-zoomed-page-ref.html
 == brightness.html brightness-ref.html
 == brightness-darken.html brightness-darken-ref.html
 == brightness-extreme.html brightness-extreme-ref.html
 == brightness-one.html brightness-one-ref.html
 == brightness-percent.html brightness-percent-ref.html
 == brightness-zero.html brightness-zero-ref.html
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/filters/feGaussianBlur-cap-large-directional-radius-on-software-ref.html
@@ -0,0 +1,12 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg">
+  <filter id="blur">
+    <feGaussianBlur stdDeviation="100 0"/>
+  </filter>
+  <g filter="url(#blur)">
+    <rect x="0" y="0" width="100" height="100" fill="#0f0"/>
+  </g>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/filters/feGaussianBlur-cap-large-directional-radius-on-software.html
@@ -0,0 +1,16 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg">
+  <filter id="blur">
+    <!--
+      When rendering in software, Firefox should cap large blur radii to a
+      smaller value in order to keep performance acceptable.
+    -->
+    <feGaussianBlur stdDeviation="1000000 0"/>
+  </filter>
+  <g filter="url(#blur)">
+    <rect x="0" y="0" width="100" height="100" fill="#0f0"/>
+  </g>
+</svg>
--- a/layout/reftests/svg/filters/reftest.list
+++ b/layout/reftests/svg/filters/reftest.list
@@ -40,16 +40,17 @@ fuzzy-if(d2d,1,6400) == feFlood-1.svg fe
 skip-if(d2d) == feFlood-2.svg feFlood-2-ref.svg
 
 fuzzy(1,6400) == feGaussianBlur-1.svg feGaussianBlur-1-ref.svg
 == feGaussianBlur-2.svg feGaussianBlur-2-ref.svg
 # != feGaussianBlur-3.svg feGaussianBlur-3-ref.svg
 == feGaussianBlur-4.svg feGaussianBlur-4-ref.svg
 == feGaussianBlur-5.svg feGaussianBlur-5-ref.svg
 == feGaussianBlur-6.svg feGaussianBlur-6-ref.svg
+skip-if(d2d) pref(layers.acceleration.disabled,true) == feGaussianBlur-cap-large-directional-radius-on-software.html feGaussianBlur-cap-large-directional-radius-on-software-ref.html
 
 == feImage-1.svg feImage-1-ref.svg
 
 == feMerge-1.svg feMerge-1-ref.svg
 == feMerge-2.svg feMerge-2-ref.svg
 
 == feMorphology-1.svg feMorphology-1-ref.svg
 == feMorphology-2.svg feMorphology-2-ref.svg