Bug 1497239 - Properly apply inherited scale to filters. r=jrmuizel
authorEmilio Cobos Álvarez <emilio@crisal.io>
Wed, 10 Oct 2018 14:49:15 +0000
changeset 498981 45261374e05f4a047667ac21a813084dc9a90a2b
parent 498980 493e812d03421d640f1111e57373d6c4d777f789
child 498982 32e2b80f655599a3db1d0a9d5c128e1ab5f42dbd
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1497239
milestone64.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 1497239 - Properly apply inherited scale to filters. r=jrmuizel I'll file a followup bug to deal with the fallback transition going wrong. I don't know why it'd be fine to not apply the scale to SVG wrappers, but on my quick testing I didn't manage to break it, so I'll spend a bit more time trying to do that... Differential Revision: https://phabricator.services.mozilla.com/D8013
gfx/layers/wr/WebRenderCommandBuilder.cpp
testing/web-platform/tests/css/filter-effects/filter-scale-001-ref.html
testing/web-platform/tests/css/filter-effects/filter-scale-001.html
--- a/gfx/layers/wr/WebRenderCommandBuilder.cpp
+++ b/gfx/layers/wr/WebRenderCommandBuilder.cpp
@@ -1742,26 +1742,27 @@ PaintItemByDrawTarget(nsDisplayItem* aIt
   switch (aItem->GetType()) {
   case DisplayItemType::TYPE_MASK:
     context->SetMatrix(context->CurrentMatrix().PreScale(aScale.width, aScale.height).PreTranslate(-aOffset.x, -aOffset.y));
     static_cast<nsDisplayMasksAndClipPaths*>(aItem)->
       PaintMask(aDisplayListBuilder, context, &isInvalidated);
     break;
   case DisplayItemType::TYPE_SVG_WRAPPER:
     {
+      // XXX Why doesn't this need the scaling applied?
       context->SetMatrix(context->CurrentMatrix().PreTranslate(-aOffset.x, -aOffset.y));
       isInvalidated = PaintByLayer(aItem, aDisplayListBuilder, aManager, context, aScale, [&]() {
         aManager->EndTransaction(FrameLayerBuilder::DrawPaintedLayer, aDisplayListBuilder);
       });
       break;
     }
 
   case DisplayItemType::TYPE_FILTER:
     {
-      context->SetMatrix(context->CurrentMatrix().PreTranslate(-aOffset.x, -aOffset.y));
+      context->SetMatrix(context->CurrentMatrix().PreScale(aScale.width, aScale.height).PreTranslate(-aOffset.x, -aOffset.y));
       isInvalidated = PaintByLayer(aItem, aDisplayListBuilder, aManager, context, aScale, [&]() {
         static_cast<nsDisplayFilters*>(aItem)->PaintAsLayer(aDisplayListBuilder,
                                                             context, aManager);
       });
       break;
     }
 
   default:
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/filter-effects/filter-scale-001-ref.html
@@ -0,0 +1,10 @@
+<!doctype html>
+<title>CSS Test Reference</title>
+<style>
+  div {
+    width: 150px;
+    height: 150px;
+    background: green;
+  }
+</style>
+<div></div>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/filter-effects/filter-scale-001.html
@@ -0,0 +1,31 @@
+<!doctype html>
+<title>CSS Filter Effects test: Scaling is properly accounted for.</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=1497239">
+<link rel="match" href="filter-scale-001-ref.html">
+<style>
+  #outer {
+    width: 15px;
+    height: 15px;
+    transform: scale(10);
+    transform-origin: 0 0;
+  }
+  #inner {
+    filter: url(#blur);
+    width: 15px;
+    height: 15px;
+    background: green;
+  }
+</style>
+<div id="outer">
+  <div id="inner"></div>
+</div>
+<svg xmlns="http://www.w3.org/2000/svg">
+  <defs>
+    <filter id="blur">
+      <feGaussianBlur in="SourceGraphic" stdDeviation="0,0"></feGaussianBlur>
+    </filter>
+  </defs>
+</svg>