1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef CC_TREES_LAYER_TREE_SETTINGS_H_
6 #define CC_TREES_LAYER_TREE_SETTINGS_H_
7 
8 #include <stddef.h>
9 
10 #include <vector>
11 
12 #include "base/time/time.h"
13 #include "cc/cc_export.h"
14 #include "cc/debug/layer_tree_debug_state.h"
15 #include "cc/scheduler/scheduler_settings.h"
16 #include "cc/tiles/tile_manager_settings.h"
17 #include "cc/trees/managed_memory_policy.h"
18 #include "components/viz/common/display/renderer_settings.h"
19 #include "components/viz/common/resources/resource_format.h"
20 #include "components/viz/common/resources/resource_settings.h"
21 #include "third_party/skia/include/core/SkColor.h"
22 #include "ui/gfx/geometry/size.h"
23 
24 namespace cc {
25 
26 class CC_EXPORT LayerTreeSettings {
27  public:
28   LayerTreeSettings();
29   LayerTreeSettings(const LayerTreeSettings& other);
30   virtual ~LayerTreeSettings();
31 
32   SchedulerSettings ToSchedulerSettings() const;
33   TileManagerSettings ToTileManagerSettings() const;
34 
35   viz::ResourceSettings resource_settings;
36   bool single_thread_proxy_scheduler = true;
37   bool main_frame_before_activation_enabled = false;
38   bool using_synchronous_renderer_compositor = false;
39   bool enable_early_damage_check = false;
40   // When |enable_early_damage_check| is true, the early damage check is
41   // performed if one of the last |damaged_frame_limit| frames had no damage.
42   int damaged_frame_limit = 3;
43   bool enable_impl_latency_recovery = true;
44   bool enable_main_latency_recovery = true;
45   bool can_use_lcd_text = true;
46   bool gpu_rasterization_disabled = false;
47   int gpu_rasterization_msaa_sample_count = -1;
48   float gpu_rasterization_skewport_target_time_in_seconds = 0.2f;
49   bool create_low_res_tiling = false;
50   bool use_stream_video_draw_quad = false;
51 
52   enum ScrollbarAnimator {
53     NO_ANIMATOR,
54     ANDROID_OVERLAY,
55     AURA_OVERLAY,
56   };
57   ScrollbarAnimator scrollbar_animator = NO_ANIMATOR;
58   base::TimeDelta scrollbar_fade_delay;
59   base::TimeDelta scrollbar_fade_duration;
60   base::TimeDelta scrollbar_thinning_duration;
61   bool scrollbar_flash_after_any_scroll_update = false;
62   bool scrollbar_flash_when_mouse_enter = false;
63   SkColor solid_color_scrollbar_color = SK_ColorWHITE;
64   base::TimeDelta scroll_animation_duration_for_testing;
65   bool timeout_and_draw_when_animation_checkerboards = true;
66   bool layers_always_allowed_lcd_text = false;
67   float minimum_contents_scale = 0.0625f;
68   float low_res_contents_scale_factor = 0.25f;
69   float top_controls_show_threshold = 0.5f;
70   float top_controls_hide_threshold = 0.5f;
71   gfx::Size default_tile_size;
72   gfx::Size max_untiled_layer_size;
73   // If set, indicates the largest tile size we will use for GPU Raster. If not
74   // set, no limit is enforced.
75   gfx::Size max_gpu_raster_tile_size;
76   // Even for really wide viewports, at some point GPU raster should use
77   // less than 4 tiles to fill the viewport. This is set to 256 as a
78   // sane minimum for now, but we might want to tune this for low-end.
79   int min_height_for_gpu_raster_tile = 256;
80   gfx::Size minimum_occlusion_tracking_size;
81   // 3000 pixels should give sufficient area for prepainting.
82   // Note this value is specified with an ideal contents scale in mind. That
83   // is, the ideal tiling would use this value as the padding.
84   // TODO(vmpstr): Figure out a better number that doesn't depend on scale.
85   int tiling_interest_area_padding = 3000;
86   float skewport_target_time_in_seconds = 1.0f;
87   int skewport_extrapolation_limit_in_screen_pixels = 2000;
88   size_t max_memory_for_prepaint_percentage = 100;
89   bool use_zero_copy = false;
90   bool use_partial_raster = false;
91   bool enable_elastic_overscroll = false;
92   bool ignore_root_layer_flings = false;
93   size_t scheduled_raster_task_limit = 32;
94   bool use_occlusion_for_tile_prioritization = false;
95   bool use_layer_lists = false;
96   int max_staging_buffer_usage_in_bytes = 32 * 1024 * 1024;
97   ManagedMemoryPolicy memory_policy;
98   size_t decoded_image_working_set_budget_bytes = 128 * 1024 * 1024;
99   int max_preraster_distance_in_screen_pixels = 1000;
100   bool use_rgba_4444 = false;
101   bool unpremultiply_and_dither_low_bit_depth_tiles = false;
102 
103   // If set to true, the compositor may selectively defer image decodes to the
104   // Image Decode Service and raster tiles without images until the decode is
105   // ready.
106   bool enable_checker_imaging = false;
107 
108   // When content needs a wide color gamut, raster in wide if available.
109   // But when the content is sRGB, some situations prefer to raster in
110   // wide while others prefer to raster in sRGB.
111   bool prefer_raster_in_srgb = false;
112 
113   // The minimum size of an image we should considering decoding using the
114   // deferred path.
115   size_t min_image_bytes_to_checker = 1 * 1024 * 1024;  // 1MB.
116 
117   // Disables checkering of images when not using gpu rasterization.
118   bool only_checker_images_with_gpu_raster = false;
119 
120   LayerTreeDebugState initial_debug_state;
121 
122   // Indicates the case when a sub-frame gets its own LayerTree because it's
123   // rendered in a different process from its ancestor frames.
124   bool is_layer_tree_for_subframe = false;
125 
126   // Determines whether we disallow non-exact matches when finding resources
127   // in ResourcePool. Only used for layout or pixel tests, as non-deterministic
128   // resource sizes can lead to floating point error and noise in these tests.
129   bool disallow_non_exact_resource_reuse = false;
130 
131   // Whether the Scheduler should wait for all pipeline stages before attempting
132   // to draw. If |true|, they will block indefinitely until all stages have
133   // completed the current BeginFrame before triggering their own BeginFrame
134   // deadlines.
135   bool wait_for_all_pipeline_stages_before_draw = false;
136 
137   // Determines whether the zoom needs to be applied to the device scale factor.
138   bool use_zoom_for_dsf = false;
139 
140   // Determines whether mouse interactions on composited scrollbars are handled
141   // on the compositor thread.
142   bool compositor_threaded_scrollbar_scrolling = true;
143 
144   // If enabled, the scroll deltas will be a percentage of the target scroller.
145   bool percent_based_scrolling = false;
146 
147   // Determines whether animated scrolling is supported. If true, and the
148   // incoming gesture scroll is of a type that would normally be animated (e.g.
149   // coarse granularity scrolls like those coming from an external mouse wheel),
150   // the scroll will be performed smoothly using the animation system rather
151   // than instantly.
152   bool enable_smooth_scroll = false;
153 
154   // Whether layer tree commits should be made directly to the active
155   // tree on the impl thread. If |false| LayerTreeHostImpl creates a
156   // pending layer tree and produces that as the 'sync tree' with
157   // which LayerTreeHost synchronizes. If |true| LayerTreeHostImpl
158   // produces the active tree as its 'sync tree'.
159   bool commit_to_active_tree = true;
160 
161   // Whether image animations can be reset to the beginning to avoid skipping
162   // many frames.
163   bool enable_image_animation_resync = true;
164 
165   // Whether to use edge anti-aliasing for all layer types that supports it.
166   bool enable_edge_anti_aliasing = true;
167 
168   // Whether SetViewportRectAndScale should update the painted scale factor or
169   // the device scale factor.
170   bool use_painted_device_scale_factor = false;
171 
172   // When true, LayerTreeHostImplClient will be posting a task to call
173   // DidReceiveCompositorFrameAck, used by the Compositor but not the
174   // LayerTreeView.
175   bool send_compositor_frame_ack = true;
176 
177   // When false, scroll deltas accumulated on the impl thread are rounded to
178   // integer values when sent to Blink on commit. This flag should eventually
179   // go away and CC should send Blink fractional values:
180   // https://crbug.com/414283.
181   bool commit_fractional_scroll_deltas = false;
182 
183   // When false, we do not check for occlusion and all quads are drawn.
184   // Defaults to true.
185   bool enable_occlusion = true;
186 
187   // Whether experimental de-jelly effect is allowed.
188   bool allow_de_jelly_effect = false;
189 
190 #if DCHECK_IS_ON()
191   // Whether to check if any double blur exists.
192   bool log_on_ui_double_background_blur = false;
193 #endif
194 };
195 
196 class CC_EXPORT LayerListSettings : public LayerTreeSettings {
197  public:
LayerListSettings()198   LayerListSettings() { use_layer_lists = true; }
199 };
200 
201 }  // namespace cc
202 
203 #endif  // CC_TREES_LAYER_TREE_SETTINGS_H_
204