CSS reference filter with feDisplacementMap shows buffer corruption on Retina displays
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Sep 2018 18:20:22 +0000 (18:20 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Sep 2018 18:20:22 +0000 (18:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=188486
<rdar://problem/43189750>

Reviewed by Dean Jackson.
Source/WebCore:

The paintSize needs to be scaled by filterScale on Retina displays.

Test: css3/filters/hidpi-feDisplacementMap.html

* platform/graphics/filters/FEDisplacementMap.cpp:
(WebCore::FEDisplacementMap::platformApplySoftware):
* platform/graphics/filters/FEDisplacementMap.h:

LayoutTests:

* css3/filters/hidpi-feDisplacementMap-expected.html: Added.
* css3/filters/hidpi-feDisplacementMap.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236415 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/css3/filters/hidpi-feDisplacementMap-expected.html [new file with mode: 0644]
LayoutTests/css3/filters/hidpi-feDisplacementMap.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/filters/FEDisplacementMap.cpp
Source/WebCore/platform/graphics/filters/FEDisplacementMap.h

index 055aa70..ae8dfc1 100644 (file)
@@ -1,5 +1,16 @@
 2018-09-24  Simon Fraser  <simon.fraser@apple.com>
 
+        CSS reference filter with feDisplacementMap shows buffer corruption on Retina displays
+        https://bugs.webkit.org/show_bug.cgi?id=188486
+        <rdar://problem/43189750>
+
+        Reviewed by Dean Jackson.
+
+        * css3/filters/hidpi-feDisplacementMap-expected.html: Added.
+        * css3/filters/hidpi-feDisplacementMap.html: Added.
+
+2018-09-24  Simon Fraser  <simon.fraser@apple.com>
+
         Garbled rendering of image when applied feConvolveMatrix to it, on Retina display
         https://bugs.webkit.org/show_bug.cgi?id=189748
         <rdar://problem/44621494>
diff --git a/LayoutTests/css3/filters/hidpi-feDisplacementMap-expected.html b/LayoutTests/css3/filters/hidpi-feDisplacementMap-expected.html
new file mode 100644 (file)
index 0000000..d04b01c
--- /dev/null
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <style>
+    .box {
+        margin: 10px;
+        width: 200px;
+        height: 200px;
+        background-color: green;
+    }
+    .obscurer {
+        position: absolute;
+        background-color: gray;
+    }
+    </style>
+</head>
+<body>
+    <div class="box"></div>
+    <div class="obscurer" style="height: 20px; width: 210px; left: 18px; top: 200px;"></div>
+    <div class="obscurer" style="height: 210px; width: 20px; left: 210px; top: 10px;"></div>
+</body>
+</html>
diff --git a/LayoutTests/css3/filters/hidpi-feDisplacementMap.html b/LayoutTests/css3/filters/hidpi-feDisplacementMap.html
new file mode 100644 (file)
index 0000000..07ee5ed
--- /dev/null
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <style>
+    .box {
+        margin: 10px;
+        width: 200px;
+        height: 200px;
+        background-color: green;
+        filter: url(#filter);
+    }
+    .obscurer {
+        position: absolute;
+        background-color: gray;
+    }
+    </style>
+</head>
+<body>
+    <svg style="display:none">
+        <filter id="filter">
+            <feFlood flood-color="black" flood-opacity="1"/>
+            <feDisplacementmap in="SourceGraphic" scale="10"/>
+        </filter>
+    </svg>
+    <div class="box"></div>
+    <div class="obscurer" style="height: 20px; width: 210px; left: 18px; top: 200px;"></div>
+    <div class="obscurer" style="height: 210px; width: 20px; left: 210px; top: 10px;"></div>
+</body>
+</html>
index 143d441..8c290e2 100644 (file)
@@ -1,5 +1,21 @@
 2018-09-24  Simon Fraser  <simon.fraser@apple.com>
 
+        CSS reference filter with feDisplacementMap shows buffer corruption on Retina displays
+        https://bugs.webkit.org/show_bug.cgi?id=188486
+        <rdar://problem/43189750>
+
+        Reviewed by Dean Jackson.
+        
+        The paintSize needs to be scaled by filterScale on Retina displays.
+
+        Test: css3/filters/hidpi-feDisplacementMap.html
+
+        * platform/graphics/filters/FEDisplacementMap.cpp:
+        (WebCore::FEDisplacementMap::platformApplySoftware):
+        * platform/graphics/filters/FEDisplacementMap.h:
+
+2018-09-24  Simon Fraser  <simon.fraser@apple.com>
+
         ReferenceFilterOperation doesn't need to store the FilterEffect
         https://bugs.webkit.org/show_bug.cgi?id=189904
 
index b4fd50b..0e944df 100644 (file)
@@ -112,6 +112,8 @@ void FEDisplacementMap::platformApplySoftware()
 
     Filter& filter = this->filter();
     IntSize paintSize = absolutePaintRect().size();
+    paintSize.scale(filter.filterScale());
+
     FloatSize scale = filter.scaledByFilterResolution({ m_scale, m_scale });
     float scaleForColorX = scale.width() / 255.0;
     float scaleForColorY = scale.height() / 255.0;
index e69ec71..8b611da 100644 (file)
@@ -37,7 +37,7 @@ enum ChannelSelectorType {
 
 class FEDisplacementMap : public FilterEffect {
 public:
-    static Ref<FEDisplacementMap> create(Filter&, ChannelSelectorType xChannelSelector, ChannelSelectorType yChannelSelector, float);
+    static Ref<FEDisplacementMap> create(Filter&, ChannelSelectorType xChannelSelector, ChannelSelectorType yChannelSelector, float scale);
 
     ChannelSelectorType xChannelSelector() const { return m_xChannelSelector; }
     bool setXChannelSelector(const ChannelSelectorType);