Bug 1514383 - Only clip the outermost Picture in a stacking context, since we sometimes need the inner pixels for filter rendering. r=gw
authorMatt Woodrow <mwoodrow@mozilla.com>
Fri, 25 Jan 2019 19:32:20 +0000
changeset 515498 06704e4ba49c262dc96bd2c0c1c84355e5d3dde3
parent 515497 da2115631f1b4b216f69296761f0c9e2795aef8f
child 515499 1efd079a7f7a5dee46fa6b5fdd135524410a54ca
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgw
bugs1514383
milestone66.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 1514383 - Only clip the outermost Picture in a stacking context, since we sometimes need the inner pixels for filter rendering. r=gw Differential Revision: https://phabricator.services.mozilla.com/D17595
gfx/wr/webrender/src/display_list_flattener.rs
gfx/wr/wrench/reftests/filters/filter-drop-shadow-clip.png
gfx/wr/wrench/reftests/filters/filter-drop-shadow-clip.yaml
--- a/gfx/wr/webrender/src/display_list_flattener.rs
+++ b/gfx/wr/webrender/src/display_list_flattener.rs
@@ -1375,25 +1375,27 @@ impl<'a> DisplayListFlattener<'a> {
         // Create a chain of pictures based on presence of filters,
         // mix-blend-mode and/or 3d rendering context containers.
 
         let mut current_pic_index = leaf_pic_index;
         let mut cur_instance = create_prim_instance(
             leaf_pic_index,
             leaf_composite_mode.into(),
             stacking_context.is_backface_visible,
-            stacking_context.clip_chain_id,
+            ClipChainId::NONE,
             stacking_context.spatial_node_index,
             &mut self.interners,
         );
 
         if cur_instance.is_chased() {
             println!("\tis a leaf primitive for a stacking context");
         }
 
+        let mut clip_chain = Some(stacking_context.clip_chain_id);
+
         // If establishing a 3d context, the `cur_instance` represents
         // a picture with all the *trailing* immediate children elements.
         // We append this to the preserve-3D picture set and make a container picture of them.
         if let Picture3DContext::In { root_data: Some(mut prims), ancestor_index } = stacking_context.context_3d {
             prims.push(cur_instance);
 
             // This is the acttual picture representing our 3D hierarchy root.
             current_pic_index = PictureIndex(self.prim_store.pictures
@@ -1415,21 +1417,31 @@ impl<'a> DisplayListFlattener<'a> {
                     stacking_context.spatial_node_index,
                     max_clip,
                     &self.clip_store,
                     None,
                     PictureOptions::default(),
                 ))
             );
 
+            // If this is going to be the last picture for the stacking context,
+            // then put the clip onto the leaf picture, since this one uses
+            // PictureCompositeKey::Identity and won't have a surface to be
+            // clipped.
+            if stacking_context.composite_ops.filters.is_empty() &&
+               stacking_context.composite_ops.mix_blend_mode.is_none() {
+                cur_instance.clip_chain_id = clip_chain.take().unwrap();
+            }
+
+
             cur_instance = create_prim_instance(
                 current_pic_index,
                 PictureCompositeKey::Identity,
                 stacking_context.is_backface_visible,
-                stacking_context.clip_chain_id,
+                ClipChainId::NONE,
                 stacking_context.spatial_node_index,
                 &mut self.interners,
             );
         }
 
         // For each filter, create a new image with that composite mode.
         for filter in &stacking_context.composite_ops.filters {
             let filter = filter.sanitize();
@@ -1456,17 +1468,17 @@ impl<'a> DisplayListFlattener<'a> {
                 ))
             );
 
             current_pic_index = filter_pic_index;
             cur_instance = create_prim_instance(
                 current_pic_index,
                 composite_mode.into(),
                 stacking_context.is_backface_visible,
-                stacking_context.clip_chain_id,
+                ClipChainId::NONE,
                 stacking_context.spatial_node_index,
                 &mut self.interners,
             );
 
             if cur_instance.is_chased() {
                 println!("\tis a composite picture for a stacking context with {:?}", filter);
             }
 
@@ -1500,26 +1512,30 @@ impl<'a> DisplayListFlattener<'a> {
                 ))
             );
 
             current_pic_index = blend_pic_index;
             cur_instance = create_prim_instance(
                 blend_pic_index,
                 composite_mode.into(),
                 stacking_context.is_backface_visible,
-                stacking_context.clip_chain_id,
+                ClipChainId::NONE,
                 stacking_context.spatial_node_index,
                 &mut self.interners,
             );
 
             if cur_instance.is_chased() {
                 println!("\tis a mix-blend picture for a stacking context with {:?}", mix_blend_mode);
             }
         }
 
+        // Set the stacking context clip on the outermost picture in the chain,
+        // unless we already set it on the leaf picture.
+        cur_instance.clip_chain_id = clip_chain.unwrap_or(ClipChainId::NONE);
+
         let has_mix_blend_on_secondary_framebuffer =
             stacking_context.composite_ops.mix_blend_mode.is_some() &&
             self.sc_stack.len() > 2;
 
         // The primitive instance for the remainder of flat children of this SC
         // if it's a part of 3D hierarchy but not the root of it.
         let trailing_children_instance = match self.sc_stack.last_mut() {
             // Preserve3D path (only relevant if there are no filters/mix-blend modes)
index 538a53636170a4b3951c5c041864069caa0b2d1e..c35b7f65495a9ddc228c4224b83b5d5fe6bde277
GIT binary patch
literal 10427
zc%1E6dsLHmwzUja#I}w>tK6xA3ZwxoNTg~ZiCQWUQz+pjtt8SyqUe+<R6-z+Le&{8
zBPaw3LQ;i*JPK;G7Nbe6RVgHV1+j_(@j(($OduhIyyy1?Y|*)Q?z(?pT*zXvINv$@
zoPEyTUkW~o413-6zg*|cne%!?cqnnsoLAW3f4Ix5;5R=6+cM_Nc{@KMbW3b@<+IA|
z9sBowTqSAv>++C?D-S<<Wzm*GPnT`0mhE#n<nr!5msbe^o@bM<9eREKyRW%iJ@gOf
zzr4He?w`HZZ8?)%?CFBovTB*j%3|CuzxjI<zcw^AHXM56ra45%dwO5w<M!JRgC9Q@
z-w_U^<8-Ml(bt=OaTDBm8azsHdGT615l`Rpu}x5_%|CD1j#A9sV?0i5U(l`f7nClo
zQIPQ{|L_h;DUnoM#s&eNvjMXK|Azp1VG+jGQrb8vt-~6#nWJZK%4vvj<5&^<9YI#q
zxI1q0L1uw8(BN-6b+G{ZnR*zB9c%3y#<lcj)~TNsV4wCTY?@zlfH3Nw5p_scW|!?Y
z9{1a0{6yWu#B@<HW?y7pY4LpQ`|4l*HlUTbueE1*uVr^sU1~v^ny6%jS1}^+Dzy#c
z-ua1bL$!k3T%$;DjWOs$`TCK@N@wC$pUKx+k=N)QcFK862j{$HE$xYzHzedSIVGF%
zZO;6ahLnxz07V(Q^;nri5!rvojrp6f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=-jr=l&7(z`X9MRR|HaY}9f8^f5Tr
zG?ofDn;)mj!^*t!>lO^UU-=uKiyrGWG7nN?LPVO4=GNEY#SuvyivzKYI$fA!<#q_b
zUki(w!1Yq`a`4i?UlM*mh~o7ZWh;dX;O84y8u0uG-rBD$40W+)4-OAR$XJ-z*;+ji
z1CRta4+Q%ayFjqvz>bZm91OI|*_TT*@~L7=BgCUe!FPC3n_+*#Z#iU#_QX34I~4?Y
z?~Xs*m#iN+LdA+sf?HyHun@Sc%k!wN4~NinC73=41A8{k&6t2pmowgr$|GELTj>@r
zL@=_lG{IDC<}o<iH5>y_)++`TlB*UesR&?BSv!QkX0pk7U*?65hJN(ZdcTCXs;+)%
z^Mbn&#vTV<ct3#ivru(Ujs!=?S=(0BFbdQl+&Rh_aS(bSa;RZ>C%*<RYqAKOxXVbY
z>!Yc%P<e@9qgKox9OSZJnWGJdHK;MPZLwHGp&G=QN_5n(KoHnkBoKswuZ4;;=AB}V
zIjz%K<^|&Lo-v*{d>#Q*xvB}VGUlyk;Qc5pMAz#E^MG#~hIv4*T^7%m85jol^Hd=F
zh^sN6W5#4aY$Ckv8}ZJ9jrW*``j9-UWi!muUOqT%^kdX-R^sg9T%X-Oi{eorL$fpd
zX(n8t*H1#2Z|0wcd<RK!b{!z8=BiLp%!ih1G4de4Ekfi^;IPe4ajjV}I2GhnFuD(R
zQ)hD0Z=(5_2sqVsGH@kEmyI#YM9`o)4DL8wUOp9s)xfmPmct8sUCmTUsRJeUh1aXA
WjvX3bL7M~qMSKt$+PrmF{=Wbx;#55V
--- a/gfx/wr/wrench/reftests/filters/filter-drop-shadow-clip.yaml
+++ b/gfx/wr/wrench/reftests/filters/filter-drop-shadow-clip.yaml
@@ -1,22 +1,25 @@
 ---
 root:
   items:
     - type: clip
-      id: 2
+      id: 3
+      bounds: [0, 0, 256, 256]
+      complex:
+        - rect: [0, 0, 256, 256]
+          radius: 16
+    - type: clip-chain
+      id: 5
+      clips: [3]
+    - type: clip
+      id: 4
       bounds: [100, 100, 2000, 2000]
-      clip-rect: [100, 100, 2000, 2000]
       items:
         - type: stacking-context
           bounds: [10, 10, 0, 0]
-          filters: drop-shadow([10, 10], 20, red)
-          clip-node: 2
+          filters: drop-shadow([50, 50], 25, red)
+          clip-node: 4
           items:
-          - type: clip
-            bounds: [0, 0, 256, 256]
-            complex:
-              - rect: [0, 0, 256, 256]
-                radius: 16
-            items:
-              - type: rect
-                bounds: 0 0 256 256
-                color: green
+            - type: rect
+              bounds: 0 0 256 256
+              color: green
+              clip-and-scroll: [root-scroll-node, 5]