Bug 1499113 - Multiply transform scales into the blur radius for blur filters. r=kvark
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 25 Feb 2019 17:12:17 +0000
changeset 460933 ffe37ad57ad711ab7c0b4f51defe40d48bf87bf8
parent 460932 da356c59e50db348e0a6ed391e7ab6fc3ef1606f
child 460934 96e76fdfd8b247997bbf9545ca043934f7279608
push id35613
push usernerli@mozilla.com
push dateTue, 26 Feb 2019 03:52:35 +0000
treeherdermozilla-central@faec87a80ed1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskvark
bugs1499113
milestone67.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 1499113 - Multiply transform scales into the blur radius for blur filters. r=kvark Without this patch any enclosing scale transform between a blurred picture and the nearest raster root was being ignored entirely for the purposes of blur. Also includes a couple of reftests to exercise this code. Differential Revision: https://phabricator.services.mozilla.com/D20908
gfx/wr/webrender/src/picture.rs
gfx/wr/wrench/reftests/filters/filter-blur-scaled-ref.yaml
gfx/wr/wrench/reftests/filters/filter-blur-scaled-xonly.png
gfx/wr/wrench/reftests/filters/filter-blur-scaled-xonly.yaml
gfx/wr/wrench/reftests/filters/filter-blur-scaled.yaml
gfx/wr/wrench/reftests/filters/reftest.list
--- a/gfx/wr/webrender/src/picture.rs
+++ b/gfx/wr/webrender/src/picture.rs
@@ -31,17 +31,17 @@ use render_task::{RenderTaskId, RenderTa
 use resource_cache::ResourceCache;
 use scene::{FilterOpHelpers, SceneProperties};
 use scene_builder::Interners;
 use smallvec::SmallVec;
 use std::{mem, u16};
 use std::sync::atomic::{AtomicUsize, Ordering};
 use texture_cache::TextureCacheHandle;
 use tiling::RenderTargetKind;
-use util::{ComparableVec, TransformedRectKind, MatrixHelpers, MaxRect};
+use util::{ComparableVec, TransformedRectKind, MatrixHelpers, MaxRect, scale_factors};
 
 /*
  A picture represents a dynamically rendered image. It consists of:
 
  * A number of primitives that are drawn onto the picture.
  * A composite operation describing how to composite this
    picture into its parent.
  * A configuration describing how to draw the primitives on
@@ -2922,17 +2922,21 @@ impl PicturePrimitive {
                 // blits up to the parent surface.
                 let surface = &mut surfaces[surface_index.0];
                 surface.tasks.extend(child_tasks);
 
                 return true;
             }
             PictureCompositeMode::Filter(FilterOp::Blur(blur_radius)) => {
                 let blur_std_deviation = blur_radius * device_pixel_scale.0;
-                let blur_std_deviation = DeviceSize::new(blur_std_deviation, blur_std_deviation);
+                let scale_factors = scale_factors(&transform);
+                let blur_std_deviation = DeviceSize::new(
+                    blur_std_deviation * scale_factors.0,
+                    blur_std_deviation * scale_factors.1
+                );
                 let inflation_factor = surfaces[raster_config.surface_index.0].inflation_factor;
                 let inflation_factor = (inflation_factor * device_pixel_scale.0).ceil() as i32;
 
                 // The clipped field is the part of the picture that is visible
                 // on screen. The unclipped field is the screen-space rect of
                 // the complete picture, if no screen / clip-chain was applied
                 // (this includes the extra space for blur region). To ensure
                 // that we draw a large enough part of the picture to get correct
new file mode 100644
--- /dev/null
+++ b/gfx/wr/wrench/reftests/filters/filter-blur-scaled-ref.yaml
@@ -0,0 +1,11 @@
+# Ensure scales from enclosing SCs get applied to blurs
+---
+root:
+  items:
+    - type: stacking-context
+      bounds: [0, 0, 500, 500]
+      filters: blur(10)
+      items:
+        - type: rect
+          bounds: [50, 50, 250, 250]
+          color: 0 255 0 1.0
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..6bb0834bc3624e7399e4bba6dfad75853ec3d764
GIT binary patch
literal 3214
zc%1E5Sy)ro77n>l8LEw_MJr+mgQAcFR<vOV(W2r-f}oaB!VsVk0+<8{G6m-uMI{Id
z4p=NT2?-GJizL)rNlOZ`SQ1FA@PRQ1M5tlP0J$e<+xzvt+?V^-{cz6Od;e?wd+oE<
z-s_y*kK41<@>5F)1hRB*fPW|iVs;sn3FeEz=L2z44)`*ogzni1VRhNQ0p*C4gW=Th
zpnYBm86;F3At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i<aL7Dl7IN1RJdUflT1Vi|KH+5*bv4}%x19`m^N;7X)654hwk~$M>!nZZf3DA*
z{WXTol$Hu)r%tv#gyokt73neG@&rGT3JMFfqqch2KwDQw@QiD;YjE53bZ7jxIeEUk
zt{d`eVhidjxYJVxb8bsWQ%&k6-7Q)XVZJ^TJ{GujEYPu=vA-tsnlMIs;$Ot(RWBz2
zQRfQy>Z{l)qMn=BM1Q5ld0aU&{J6Hf2H*tT3Fwz-1ru}jmE&%*8s0h5oArye2b?lB
zvj^)OmU@c=Wu!i?ZcA{bjiAVLw*Sb@hNE4Ybq+&vKz5sVju~=|G?QQtDQ4Kz(`I+F
z4)^BXQAn)t$jeXSLmos(#Hw|lkx1(v;Z)B?v)A%*1Dl|OG7zgsQ6~2|fp>-8b8~U{
zT8eOpkgt!tXJ|aVdy;?gBm^e4xb^|Hi=7=a>xoB(j7l(~zg(Ji&{FYliE2TbB6xHE
zAxUrZ^?=@HW+w$N?`Ajk>?wx8P!0oPd2phlFjC7p+Ad(8cp@N?s`TAug-j-<qY!%7
zxbBBXi5s;<Cz0b~RMfn*W$=})$X8ZPnE<`=bGV%B?T~0J6MC{*(8+4wz7pd$=(saN
zNtRhxX}UTiR-DR@nSYt9q%?x?LRi-=bv|)4cg<QO8M=NqR$3;QIUbQG7|U44z7V_?
z3LoA>*C<NVQOF{iSs&j8^RTt1d<j_S++JGzyr@;?Y!|Xn9>rQi&3|w_n^Xy>Ltv3$
zhDWY&vIDE5;=N$PUUjS>fi(sED=@=Tg09g_7-xGreP8KUJPVU8PcvAJXUO0V5L12v
v0^PFrZlAMBSqdH@Qvb6{{wDYz35;gAfHn_mPL!AF&tdN_oIh)4?6H3XM}K!M
new file mode 100644
--- /dev/null
+++ b/gfx/wr/wrench/reftests/filters/filter-blur-scaled-xonly.yaml
@@ -0,0 +1,16 @@
+# Ensure scales from enclosing SCs get applied to blurs. This one
+# applies a mixed-dimension scale by scaling the x-axis only.
+---
+root:
+  items:
+    - type: reference-frame
+      bounds: [0, 0, 100, 100]
+      transform: [5, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]
+      items:
+        - type: stacking-context
+          bounds: [0, 0, 100, 100]
+          filters: blur(2)
+          items:
+            - type: rect
+              bounds: [10, 10, 50, 50]
+              color: 0 255 0 1.0
new file mode 100644
--- /dev/null
+++ b/gfx/wr/wrench/reftests/filters/filter-blur-scaled.yaml
@@ -0,0 +1,15 @@
+# Ensure scales from enclosing SCs get applied to blurs
+---
+root:
+  items:
+    - type: reference-frame
+      bounds: [0, 0, 100, 100]
+      transform: [5, 0, 0, 0, 0, 5, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]
+      items:
+        - type: stacking-context
+          bounds: [0, 0, 100, 100]
+          filters: blur(2)
+          items:
+            - type: rect
+              bounds: [10, 10, 50, 50]
+              color: 0 255 0 1.0
--- a/gfx/wr/wrench/reftests/filters/reftest.list
+++ b/gfx/wr/wrench/reftests/filters/reftest.list
@@ -36,8 +36,10 @@ platform(linux,mac) == blend-clipped.yam
 platform(linux,mac) == filter-drop-shadow-clip.yaml filter-drop-shadow-clip.png
 == filter-segments.yaml filter-segments-ref.yaml
 == iframe-dropshadow.yaml iframe-dropshadow-ref.yaml
 == filter-mix-blend-mode.yaml filter-mix-blend-mode-ref.yaml
 == fuzzy(3,20000) srgb-to-linear.yaml srgb-to-linear-ref.yaml
 != srgb-to-linear-2.yaml srgb-to-linear-ref.yaml
 != filter-blur-huge.yaml blank.yaml
 != filter-drop-shadow-huge.yaml blank.yaml
+== filter-blur-scaled.yaml filter-blur-scaled-ref.yaml
+== filter-blur-scaled-xonly.yaml filter-blur-scaled-xonly.png