Bug 1498221 - Don't apply layer scaling to fallback filters. r=mattwoodrow
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 22 Oct 2018 23:41:30 +0000
changeset 490830 3ef66c8d682c099b0ccb8bc41d2fd678dc39d29a
parent 490829 29c73665ba1923bbb91cebfc3f785e8c7471522b
child 490831 9140cba9a8f80c392dd57d7a89aa85baca30547d
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersmattwoodrow
bugs1498221, 1497239, 1224207
milestone65.0a1
Bug 1498221 - Don't apply layer scaling to fallback filters. r=mattwoodrow Using layer scaling confuses the filter code (see bug 1497239). Right now we're sort-of double-scaling. Looks like what the filter code expects is just getting the scaling passed down, see bug 1224207. Differential Revision: https://phabricator.services.mozilla.com/D8910
gfx/layers/wr/WebRenderCommandBuilder.cpp
testing/web-platform/tests/css/filter-effects/filter-scaling-001-ref.html
testing/web-platform/tests/css/filter-effects/filter-scaling-001.html
--- a/gfx/layers/wr/WebRenderCommandBuilder.cpp
+++ b/gfx/layers/wr/WebRenderCommandBuilder.cpp
@@ -1753,17 +1753,17 @@ PaintItemByDrawTarget(nsDisplayItem* aIt
         aManager->EndTransaction(FrameLayerBuilder::DrawPaintedLayer, aDisplayListBuilder);
       });
       break;
     }
 
   case DisplayItemType::TYPE_FILTER:
     {
       context->SetMatrix(context->CurrentMatrix().PreScale(aScale.width, aScale.height).PreTranslate(-aOffset.x, -aOffset.y));
-      isInvalidated = PaintByLayer(aItem, aDisplayListBuilder, aManager, context, aScale, [&]() {
+      isInvalidated = PaintByLayer(aItem, aDisplayListBuilder, aManager, context, { 1, 1 }, [&]() {
         static_cast<nsDisplayFilters*>(aItem)->PaintAsLayer(aDisplayListBuilder,
                                                             context, aManager);
       });
       break;
     }
 
   default:
     context->SetMatrix(context->CurrentMatrix().PreScale(aScale.width, aScale.height).PreTranslate(-aOffset.x, -aOffset.y));
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/filter-effects/filter-scaling-001-ref.html
@@ -0,0 +1,36 @@
+<!doctype html>
+<title>CSS Test Reference.</title>
+<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
+<link rel="author" title="Mozilla" href="https://mozilla.org">
+<style>
+  * {
+    margin: 0;
+    padding: 0;
+  }
+
+  :root, #outer {
+    width: 100vw;
+    height: 100vh;
+    overflow: hidden;
+  }
+
+  #outer {
+    transform-origin: 0 0;
+    transform: scale(5);
+  }
+
+  #pad {
+    /* So that scaling by five it takes half of the viewport */
+    height: 10vh;
+  }
+
+  #filtered {
+    width: 100%;
+    height: 10vh;
+    background: green;
+  }
+</style>
+<div id="outer">
+  <div id="pad"></div>
+  <div id="filtered"></div>
+</div>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/filter-effects/filter-scaling-001.html
@@ -0,0 +1,47 @@
+<!doctype html>
+<title>CSS Test: Blur filter scaling.</title>
+<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
+<link rel="author" title="Mozilla" href="https://mozilla.org">
+<link rel="help" href="https://drafts.fxtf.org/filter-effects/#FilterProperty">
+<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1224207">
+<link rel="match" href="filter-scaling-001-ref.html">
+<style>
+  * {
+    margin: 0;
+    padding: 0;
+  }
+
+  :root, #outer {
+    width: 100vw;
+    height: 100vh;
+    overflow: hidden;
+  }
+
+  #outer {
+    transform-origin: 0 0;
+    transform: scale(5);
+  }
+
+  #pad {
+    /* So that scaling by five it takes half of the viewport */
+    height: 10vh;
+  }
+
+  #filtered {
+    filter: url(#blur);
+    width: 100%;
+    height: 10vh;
+    background: green;
+  }
+</style>
+<div id="outer">
+  <div id="pad"></div>
+  <div id="filtered"></div>
+  <svg xmlns="http://www.w3.org/2000/svg" version="1.1">
+    <defs>
+      <filter id="blur">
+        <feGaussianBlur in="SourceGraphic" stdDeviation="0,0"></feGaussianBlur>
+      </filter>
+    </defs>
+  </svg>
+</div>