Bug 1599327 - Use cluster scrollbar flags to select picture cache tile size. r=gw
authorBert Peers <bpeers@mozilla.com>
Wed, 05 Feb 2020 07:39:42 +0000
changeset 512538 269ab6499d32ae39f0626858d05e13403787db69
parent 512537 51b1d5255b96d48273bb458eead12c6be54c1fea
child 512539 8ed35bc11a26529747017450aab8af509f9c9754
push id37092
push userapavel@mozilla.com
push dateWed, 05 Feb 2020 16:27:17 +0000
treeherdermozilla-central@0fa466366383 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgw
bugs1599327
milestone74.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 1599327 - Use cluster scrollbar flags to select picture cache tile size. r=gw (cherry picked from commit 348b45266ac2c2c65dcc26705dc7cf144f5e0051) Differential Revision: https://phabricator.services.mozilla.com/D55555
gfx/wr/webrender/src/picture.rs
gfx/wr/webrender/src/scene_building.rs
gfx/wr/wrench/reftests/snap/preserve-3d.png
--- a/gfx/wr/webrender/src/picture.rs
+++ b/gfx/wr/webrender/src/picture.rs
@@ -131,16 +131,17 @@ use crate::prim_store::picture::Picture;
 use crate::prim_store::text_run::TextRun;
 
 #[cfg(feature = "capture")]
 use std::fs::File;
 #[cfg(feature = "capture")]
 use std::io::prelude::*;
 #[cfg(feature = "capture")]
 use std::path::PathBuf;
+use crate::scene_building::{SliceFlags};
 
 /// Specify whether a surface allows subpixel AA text rendering.
 #[derive(Debug, Copy, Clone, PartialEq)]
 pub enum SubpixelMode {
     /// This surface allows subpixel AA text
     Allow,
     /// Subpixel AA text cannot be drawn on this surface
     Deny,
@@ -1763,16 +1764,18 @@ impl TileCacheLogger {
 pub struct TileCacheInstance {
     /// Index of the tile cache / slice for this frame builder. It's determined
     /// by the setup_picture_caching method during flattening, which splits the
     /// picture tree into multiple slices. It's used as a simple input to the tile
     /// keys. It does mean we invalidate tiles if a new layer gets inserted / removed
     /// between display lists - this seems very unlikely to occur on most pages, but
     /// can be revisited if we ever notice that.
     pub slice: usize,
+    /// Propagated information about the slice
+    pub slice_flags: SliceFlags,
     /// The currently selected tile size to use for this cache
     pub current_tile_size: DeviceIntSize,
     /// The positioning node for this tile cache.
     pub spatial_node_index: SpatialNodeIndex,
     /// Hash of tiles present in this picture.
     pub tiles: FastHashMap<TileOffset, Tile>,
     /// Switch back and forth between old and new tiles hashmaps to avoid re-allocating.
     old_tiles: FastHashMap<TileOffset, Tile>,
@@ -1853,23 +1856,25 @@ pub struct TileCacheInstance {
     /// The currently considered tile size override. Used to check if we should
     /// re-evaluate tile size, even if the frame timer hasn't expired.
     tile_size_override: Option<DeviceIntSize>,
 }
 
 impl TileCacheInstance {
     pub fn new(
         slice: usize,
+        slice_flags: SliceFlags,
         spatial_node_index: SpatialNodeIndex,
         background_color: Option<ColorF>,
         shared_clips: Vec<ClipDataHandle>,
         shared_clip_chain: ClipChainId,
     ) -> Self {
         TileCacheInstance {
             slice,
+            slice_flags,
             spatial_node_index,
             tiles: FastHashMap::default(),
             old_tiles: FastHashMap::default(),
             map_local_to_surface: SpaceMapper::new(
                 ROOT_SPATIAL_NODE_INDEX,
                 PictureRect::zero(),
             ),
             map_child_pic_to_surface: SpaceMapper::new(
@@ -2058,31 +2063,29 @@ impl TileCacheInstance {
             );
         }
 
         // Only evaluate what tile size to use fairly infrequently, so that we don't end
         // up constantly invalidating and reallocating tiles if the picture rect size is
         // changing near a threshold value.
         if self.frames_until_size_eval == 0 ||
            self.tile_size_override != frame_context.config.tile_size_override {
-            const TILE_SIZE_TINY: f32 = 32.0;
 
             // Work out what size tile is appropriate for this picture cache.
             let desired_tile_size = match frame_context.config.tile_size_override {
                 Some(tile_size_override) => {
                     tile_size_override
                 }
                 None => {
-                    // There's no need to check the other dimension. If we encounter a picture
-                    // that is small on one dimension, it's a reasonable choice to use a scrollbar
-                    // sized tile configuration regardless of the other dimension.
-                    if pic_rect.size.width <= TILE_SIZE_TINY {
-                        TILE_SIZE_SCROLLBAR_VERTICAL
-                    } else if pic_rect.size.height <= TILE_SIZE_TINY {
-                        TILE_SIZE_SCROLLBAR_HORIZONTAL
+                    if self.slice_flags.contains(SliceFlags::IS_SCROLLBAR) {
+                        if pic_rect.size.width <= pic_rect.size.height {
+                            TILE_SIZE_SCROLLBAR_VERTICAL
+                        } else {
+                            TILE_SIZE_SCROLLBAR_HORIZONTAL
+                        }
                     } else {
                         TILE_SIZE_DEFAULT
                     }
                 }
             };
 
             // If the desired tile size has changed, then invalidate and drop any
             // existing tiles.
--- a/gfx/wr/webrender/src/scene_building.rs
+++ b/gfx/wr/webrender/src/scene_building.rs
@@ -240,27 +240,37 @@ impl CompositeOps {
 }
 
 /// Information about unpaired Push/Pop clip chain instances that need to be fixed up.
 struct ClipChainPairInfo {
     spatial_node_index: SpatialNodeIndex,
     clip_chain_id: ClipChainId,
 }
 
+bitflags! {
+    /// Slice flags
+    pub struct SliceFlags : u8 {
+        /// Slice created by a cluster that has ClusterFlags::SCROLLBAR_CONTAINER
+        const IS_SCROLLBAR = 1;
+    }
+}
+
 /// Information about a set of primitive clusters that will form a picture cache slice.
 struct Slice {
     /// The spatial node root of the picture cache. If this is None, the slice
     /// will not be cached and instead drawn directly to the parent surface. This
     /// is a temporary measure until we enable caching all slices.
     cache_scroll_root: Option<SpatialNodeIndex>,
     /// List of primitive clusters that make up this slice
     prim_list: PrimitiveList,
     /// A list of clips that are shared by all primitives in the slice. These can be
     /// filtered out and applied when the tile cache is composited rather than per-item.
     shared_clips: Option<Vec<ClipDataHandle>>,
+    /// Various flags describing properties of this slice
+    pub flags: SliceFlags,
 }
 
 impl Slice {
     // Open clip chain instances at the start of a slice
     fn push_clip_instances(
         &mut self,
         stack: &[ClipChainPairInfo],
     ) {
@@ -540,20 +550,26 @@ impl<'a> SceneBuilder<'a> {
             );
 
             if create_slice {
                 // When creating a slice, close off any open clip chains on prev slice.
                 if let Some(prev_slice) = slices.last_mut() {
                     prev_slice.pop_clip_instances(&clip_chain_instance_stack);
                 }
 
+                let slice_flags = if cluster.flags.contains(ClusterFlags::SCROLLBAR_CONTAINER) {
+                    SliceFlags::IS_SCROLLBAR
+                } else {
+                    SliceFlags::empty()
+                };
                 let mut slice = Slice {
                     cache_scroll_root: cluster.cache_scroll_root,
                     prim_list: PrimitiveList::empty(),
                     shared_clips: None,
+                    flags: slice_flags
                 };
 
                 // Open up clip chains on the stack on the new slice
                 slice.push_clip_instances(&clip_chain_instance_stack);
                 slices.push(slice);
                 create_slice = false;
             }
 
@@ -657,16 +673,17 @@ impl<'a> SceneBuilder<'a> {
             // If the cluster specifies a scroll root, use it. Otherwise,
             // just cache assuming no scrolling takes place. Even if that's
             // not true, we still get caching benefits for any changes that
             // occur while not scrolling (such as animation, video etc);
             let scroll_root = slice.cache_scroll_root.unwrap_or(ROOT_SPATIAL_NODE_INDEX);
 
             let instance = create_tile_cache(
                 slice_index,
+                slice.flags,
                 scroll_root,
                 slice.prim_list,
                 background_color,
                 slice.shared_clips.unwrap_or_else(Vec::new),
                 &mut self.interners,
                 &mut self.prim_store,
                 &mut self.clip_store,
                 &mut self.picture_cache_spatial_nodes,
@@ -3989,16 +4006,17 @@ fn process_repeat_size(
         },
     )
 }
 
 /// Given a PrimitiveList and scroll root, construct a tile cache primitive instance
 /// that wraps the primitive list.
 fn create_tile_cache(
     slice: usize,
+    slice_flags: SliceFlags,
     scroll_root: SpatialNodeIndex,
     prim_list: PrimitiveList,
     background_color: Option<ColorF>,
     shared_clips: Vec<ClipDataHandle>,
     interners: &mut Interners,
     prim_store: &mut PrimitiveStore,
     clip_store: &mut ClipStore,
     picture_cache_spatial_nodes: &mut FastHashSet<SpatialNodeIndex>,
@@ -4043,16 +4061,17 @@ fn create_tile_cache(
         parent_clip_chain_id = clip_store.add_clip_chain_node(
             *clip_handle,
             parent_clip_chain_id,
         );
     }
 
     let tile_cache = Box::new(TileCacheInstance::new(
         slice,
+        slice_flags,
         scroll_root,
         background_color,
         shared_clips,
         parent_clip_chain_id,
     ));
 
     let pic_index = prim_store.pictures.alloc().init(PicturePrimitive::new_image(
         Some(PictureCompositeMode::TileCache { }),
index e82e088598ebc877a00b83f4ec31e80d456ad5d6..af6b1a5f519ffb8bdcc7e6d63713b71034f1c65f
GIT binary patch
literal 6808
zc%1E5Yfw{X8vcY@SUaGo1q&gW4&6;V;B5&g5|YxzqUDmEc7<9RP@+V(gb*$Xm~bi9
zRaTR1Wh){Orc4{GDCi=Da0`gdnHGiGR49ata0H4WNsj@NkdW+`R+-NJ*x&AKeq`p!
zIq&(tbKcAIJYU(L<D)$`_-+6IcpN+s^)3LeLioGp{vy1h`{KQ;0QjaHjEekAezkTy
z{0e=hy=00yazQ&V@q+O6E0F=EvUj4kX1LVlZ*+gF?oiJcn^NDr_1&!v)2FwVj=o;!
z?$vqZtan}d5ASSkIFOOLB{HfvY4Zj5x$`YoJtP(7VT|2AWLk5#p4ph~y_0cwcf#u6
zF}QD!J(A=Cz(1k_;Gcs|=!8z_gih#$PUwVA=!E}=@Y*h7eDyYcw?&t4o~b~3Pq|eX
zJ^Vt?^YvZ4g)w<f!Hb|oaqh$?FQ>lYNwr%Im<bh&cPgye`^*h_njztM2T!b3%fyC(
zaQ41+pd>iJ_vq>TmHB!kc#s@iw7N8${!v3>6TT{x^+EUMf|<_}<B0(5qTY9ZDRVw>
z<#9uk$UmGLtDf(GD<EpNB4VhK9?pUx1Q?=gXzKQrjb-<nW-3yo+Qsd3j=*M~LjuI)
zKd!~xk0$u@mlrCfBi9c%r{VVHp7@YEa$E(E8qHgTHy&noVoL05pOjdY0AFO9!fwB`
zGj<CAcjHO7OT&$0In3^mB?W7&jUzCQ^HeW9ed=Q7?ufj{KalP*=Ogz<i}5vo0N_&1
ziBHzcwiY5{Lao#s)YXL5*A`uVc7q4=C+<75k){${lyt6O2!Zx&n-06pf+VrKLgEY~
zGWO(;odpKcI?%Ha6%f?c#W#vr>Q-SnkruDc(6yl=tk;bYq-gd6VD?qtqrKZB?xgi!
z+>Z8bq*k}8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