blob: ee0c957990fc686acc518ad0515015d8f56abe37 [file] [log] [blame]
[email protected]ff762fb2012-12-12 19:18:371// 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
[email protected]556fd292013-03-18 08:03:045#include "cc/trees/layer_tree_settings.h"
[email protected]ff762fb2012-12-12 19:18:376
dongseong.hwang72183b02014-12-08 10:41:557#include <GLES2/gl2.h>
avi02a4d172015-12-21 06:14:368#include <stddef.h>
[email protected]ff762fb2012-12-12 19:18:379#include <limits>
10
11#include "base/command_line.h"
12#include "base/logging.h"
[email protected]8e61d4b2013-06-10 22:11:4813#include "base/strings/string_number_conversions.h"
nyquist2fe752c2015-12-10 20:12:5114#include "cc/proto/gfx_conversions.h"
15#include "cc/proto/gpu_conversions.h"
16#include "cc/proto/layer_tree_settings.pb.h"
jie.a.chen0ffadce32015-08-07 12:59:2317#include "ui/gfx/buffer_types.h"
[email protected]ff762fb2012-12-12 19:18:3718
19namespace cc {
20
nyquist2fe752c2015-12-10 20:12:5121namespace {
22
23proto::LayerTreeSettings_ScrollbarAnimator
24LayerTreeSettingsScrollbarAnimatorToProto(
25 const LayerTreeSettings::ScrollbarAnimator& animator) {
26 switch (animator) {
27 case LayerTreeSettings::ScrollbarAnimator::NO_ANIMATOR:
28 return proto::LayerTreeSettings_ScrollbarAnimator_NO_ANIMATOR;
29 case LayerTreeSettings::ScrollbarAnimator::LINEAR_FADE:
30 return proto::LayerTreeSettings_ScrollbarAnimator_LINEAR_FADE;
31 case LayerTreeSettings::ScrollbarAnimator::THINNING:
32 return proto::LayerTreeSettings_ScrollbarAnimator_THINNING;
33 }
34 NOTREACHED() << "proto::LayerTreeSettings_ScrollbarAnimator_UNKNOWN";
35 return proto::LayerTreeSettings_ScrollbarAnimator_UNKNOWN;
36}
37
38LayerTreeSettings::ScrollbarAnimator
39LayerTreeSettingsScrollbarAnimatorFromProto(
40 const proto::LayerTreeSettings_ScrollbarAnimator& animator) {
41 switch (animator) {
42 case proto::LayerTreeSettings_ScrollbarAnimator_NO_ANIMATOR:
43 return LayerTreeSettings::ScrollbarAnimator::NO_ANIMATOR;
44 case proto::LayerTreeSettings_ScrollbarAnimator_LINEAR_FADE:
45 return LayerTreeSettings::ScrollbarAnimator::LINEAR_FADE;
46 case proto::LayerTreeSettings_ScrollbarAnimator_THINNING:
47 return LayerTreeSettings::ScrollbarAnimator::THINNING;
48 case proto::LayerTreeSettings_ScrollbarAnimator_UNKNOWN:
49 NOTREACHED() << "proto::LayerTreeSettings_ScrollbarAnimator_UNKNOWN";
50 return LayerTreeSettings::ScrollbarAnimator::NO_ANIMATOR;
51 }
52 return LayerTreeSettings::ScrollbarAnimator::NO_ANIMATOR;
53}
54
55} // namespace
56
[email protected]ff762fb2012-12-12 19:18:3757LayerTreeSettings::LayerTreeSettings()
danakj13597522015-06-20 05:01:1758 : single_thread_proxy_scheduler(true),
simonhong2880b8e2014-11-11 23:25:3659 use_external_begin_frame_source(false),
[email protected]0c7a5612014-03-12 21:58:2260 main_frame_before_activation_enabled(false),
[email protected]c8cbae72013-05-23 10:45:0361 using_synchronous_renderer_compositor(false),
[email protected]8e0176d2013-03-21 03:14:5262 accelerated_animation_enabled(true),
[email protected]8e0176d2013-03-21 03:14:5263 can_use_lcd_text(true),
hendrikwcb143682014-09-25 18:03:0164 use_distance_field_text(false),
[email protected]7e03a262014-05-01 20:26:2465 gpu_rasterization_enabled(false),
66 gpu_rasterization_forced(false),
senorblancob60ba952015-01-27 19:12:3667 gpu_rasterization_msaa_sample_count(0),
hendrikw59d449482015-04-04 00:44:3268 gpu_rasterization_skewport_target_time_in_seconds(0.2f),
danakj07551552014-09-11 19:59:2769 create_low_res_tiling(false),
ericrk7c030992015-02-20 01:39:3870 scrollbar_animator(NO_ANIMATOR),
[email protected]930ff43b2014-05-02 05:24:0071 scrollbar_fade_delay_ms(0),
sataya.m07f11a82014-10-07 14:29:1872 scrollbar_fade_resize_delay_ms(0),
[email protected]930ff43b2014-05-02 05:24:0073 scrollbar_fade_duration_ms(0),
[email protected]8e0176d2013-03-21 03:14:5274 solid_color_scrollbar_color(SK_ColorWHITE),
[email protected]545dd7212013-04-09 04:37:3575 timeout_and_draw_when_animation_checkerboards(true),
[email protected]35a99a12013-05-09 23:52:2976 layer_transforms_should_scale_layer_contents(false),
danakj3f76ace2014-11-18 16:56:0077 layers_always_allowed_lcd_text(false),
[email protected]8e0176d2013-03-21 03:14:5278 minimum_contents_scale(0.0625f),
[email protected]ce07b782013-10-02 00:54:5079 low_res_contents_scale_factor(0.25f),
[email protected]8e0176d2013-03-21 03:14:5280 top_controls_show_threshold(0.5f),
81 top_controls_hide_threshold(0.5f),
mithro719bf6792014-11-10 15:36:4782 background_animation_rate(1.0),
[email protected]8e0176d2013-03-21 03:14:5283 default_tile_size(gfx::Size(256, 256)),
84 max_untiled_layer_size(gfx::Size(512, 512)),
85 minimum_occlusion_tracking_size(gfx::Size(160, 160)),
vmpstr6c0087b2015-07-21 18:32:3686 // 3000 pixels should give sufficient area for prepainting.
87 tiling_interest_area_padding(3000),
vmpstrabd4d0ce32014-12-09 20:24:3888 skewport_target_time_in_seconds(1.0f),
[email protected]42f14bf2014-02-13 16:55:4289 skewport_extrapolation_limit_in_content_pixels(2000),
[email protected]25489c02014-02-13 23:18:4190 max_memory_for_prepaint_percentage(100),
enne92761802016-01-06 19:18:4091 strict_layer_property_change_checking(false),
[email protected]2cccfef2014-05-01 06:05:1692 use_zero_copy(false),
ericrk1d17f752015-10-20 03:03:0793 use_partial_raster(false),
ccamerona7644752014-12-30 01:16:3194 enable_elastic_overscroll(false),
jie.a.chen0ffadce32015-08-07 12:59:2395 use_image_texture_targets(
96 static_cast<size_t>(gfx::BufferFormat::LAST) + 1,
97 GL_TEXTURE_2D),
[email protected]27a41fe2013-09-19 05:05:1498 ignore_root_layer_flings(false),
enne06a2caf2014-10-23 20:34:2699 scheduled_raster_task_limit(32),
[email protected]8a592802014-07-02 07:31:33100 use_occlusion_for_tile_prioritization(false),
reveman34b7a1522015-03-23 20:27:47101 verify_property_trees(false),
ajumab6adea92015-12-06 17:19:15102 use_property_trees(true),
vmpstrdfd22862015-09-25 17:42:41103 image_decode_tasks_enabled(false),
loyso13efd6282016-01-06 23:56:02104 use_compositor_animation_timelines(true),
reveman91d23272015-08-20 13:41:38105 wait_for_beginframe_interval(true),
sohan.jyoti127a06b42015-10-05 08:23:34106 max_staging_buffer_usage_in_bytes(32 * 1024 * 1024),
107 memory_policy_(64 * 1024 * 1024,
108 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING,
109 ManagedMemoryPolicy::kDefaultNumResourcesLimit) {}
[email protected]ff762fb2012-12-12 19:18:37110
[email protected]8e0176d2013-03-21 03:14:52111LayerTreeSettings::~LayerTreeSettings() {}
[email protected]ff762fb2012-12-12 19:18:37112
nyquist2fe752c2015-12-10 20:12:51113bool LayerTreeSettings::operator==(const LayerTreeSettings& other) const {
114 return renderer_settings == other.renderer_settings &&
115 single_thread_proxy_scheduler == other.single_thread_proxy_scheduler &&
116 use_external_begin_frame_source ==
117 other.use_external_begin_frame_source &&
118 main_frame_before_activation_enabled ==
119 other.main_frame_before_activation_enabled &&
120 using_synchronous_renderer_compositor ==
121 other.using_synchronous_renderer_compositor &&
122 accelerated_animation_enabled == other.accelerated_animation_enabled &&
123 can_use_lcd_text == other.can_use_lcd_text &&
124 use_distance_field_text == other.use_distance_field_text &&
125 gpu_rasterization_enabled == other.gpu_rasterization_enabled &&
126 gpu_rasterization_forced == other.gpu_rasterization_forced &&
127 gpu_rasterization_msaa_sample_count ==
128 other.gpu_rasterization_msaa_sample_count &&
129 create_low_res_tiling == other.create_low_res_tiling &&
130 scrollbar_animator == other.scrollbar_animator &&
131 scrollbar_fade_delay_ms == other.scrollbar_fade_delay_ms &&
132 scrollbar_fade_resize_delay_ms ==
133 other.scrollbar_fade_resize_delay_ms &&
134 scrollbar_fade_duration_ms == other.scrollbar_fade_duration_ms &&
135 solid_color_scrollbar_color == other.solid_color_scrollbar_color &&
136 timeout_and_draw_when_animation_checkerboards ==
137 other.timeout_and_draw_when_animation_checkerboards &&
138 layer_transforms_should_scale_layer_contents ==
139 other.layer_transforms_should_scale_layer_contents &&
140 layers_always_allowed_lcd_text ==
141 other.layers_always_allowed_lcd_text &&
142 minimum_contents_scale == other.minimum_contents_scale &&
143 low_res_contents_scale_factor == other.low_res_contents_scale_factor &&
144 top_controls_show_threshold == other.top_controls_show_threshold &&
145 top_controls_hide_threshold == other.top_controls_hide_threshold &&
146 background_animation_rate == other.background_animation_rate &&
147 default_tile_size == other.default_tile_size &&
148 max_untiled_layer_size == other.max_untiled_layer_size &&
149 minimum_occlusion_tracking_size ==
150 other.minimum_occlusion_tracking_size &&
151 tiling_interest_area_padding == other.tiling_interest_area_padding &&
152 skewport_target_time_in_seconds ==
153 other.skewport_target_time_in_seconds &&
154 skewport_extrapolation_limit_in_content_pixels ==
155 other.skewport_extrapolation_limit_in_content_pixels &&
156 max_memory_for_prepaint_percentage ==
157 other.max_memory_for_prepaint_percentage &&
158 strict_layer_property_change_checking ==
159 other.strict_layer_property_change_checking &&
160 use_zero_copy == other.use_zero_copy &&
161 use_partial_raster == other.use_partial_raster &&
162 enable_elastic_overscroll == other.enable_elastic_overscroll &&
163 use_image_texture_targets == other.use_image_texture_targets &&
164 ignore_root_layer_flings == other.ignore_root_layer_flings &&
165 scheduled_raster_task_limit == other.scheduled_raster_task_limit &&
166 use_occlusion_for_tile_prioritization ==
167 other.use_occlusion_for_tile_prioritization &&
168 verify_property_trees == other.verify_property_trees &&
169 use_property_trees == other.use_property_trees &&
170 image_decode_tasks_enabled == other.image_decode_tasks_enabled &&
171 use_compositor_animation_timelines ==
172 other.use_compositor_animation_timelines &&
173 wait_for_beginframe_interval == other.wait_for_beginframe_interval &&
174 max_staging_buffer_usage_in_bytes ==
175 other.max_staging_buffer_usage_in_bytes &&
176 memory_policy_ == other.memory_policy_ &&
177 LayerTreeDebugState::Equal(initial_debug_state,
178 other.initial_debug_state);
179}
180
181void LayerTreeSettings::ToProtobuf(proto::LayerTreeSettings* proto) const {
182 renderer_settings.ToProtobuf(proto->mutable_renderer_settings());
183 proto->set_single_thread_proxy_scheduler(single_thread_proxy_scheduler);
184 proto->set_use_external_begin_frame_source(use_external_begin_frame_source);
185 proto->set_main_frame_before_activation_enabled(
186 main_frame_before_activation_enabled);
187 proto->set_using_synchronous_renderer_compositor(
188 using_synchronous_renderer_compositor);
189 proto->set_accelerated_animation_enabled(accelerated_animation_enabled);
190 proto->set_can_use_lcd_text(can_use_lcd_text);
191 proto->set_use_distance_field_text(use_distance_field_text);
192 proto->set_gpu_rasterization_enabled(gpu_rasterization_enabled);
193 proto->set_gpu_rasterization_forced(gpu_rasterization_forced);
194 proto->set_gpu_rasterization_msaa_sample_count(
195 gpu_rasterization_msaa_sample_count);
196 proto->set_create_low_res_tiling(create_low_res_tiling);
197 proto->set_scrollbar_animator(
198 LayerTreeSettingsScrollbarAnimatorToProto(scrollbar_animator));
199 proto->set_scrollbar_fade_delay_ms(scrollbar_fade_delay_ms);
200 proto->set_scrollbar_fade_resize_delay_ms(scrollbar_fade_resize_delay_ms);
201 proto->set_scrollbar_fade_duration_ms(scrollbar_fade_duration_ms);
202 proto->set_solid_color_scrollbar_color(solid_color_scrollbar_color);
203 proto->set_timeout_and_draw_when_animation_checkerboards(
204 timeout_and_draw_when_animation_checkerboards);
205 proto->set_layer_transforms_should_scale_layer_contents(
206 layer_transforms_should_scale_layer_contents);
207 proto->set_layers_always_allowed_lcd_text(layers_always_allowed_lcd_text);
208 proto->set_minimum_contents_scale(minimum_contents_scale);
209 proto->set_low_res_contents_scale_factor(low_res_contents_scale_factor);
210 proto->set_top_controls_show_threshold(top_controls_show_threshold);
211 proto->set_top_controls_hide_threshold(top_controls_hide_threshold);
212 proto->set_background_animation_rate(background_animation_rate);
213 SizeToProto(default_tile_size, proto->mutable_default_tile_size());
214 SizeToProto(max_untiled_layer_size, proto->mutable_max_untiled_layer_size());
215 SizeToProto(minimum_occlusion_tracking_size,
216 proto->mutable_minimum_occlusion_tracking_size());
217 proto->set_tiling_interest_area_padding(tiling_interest_area_padding);
218 proto->set_skewport_target_time_in_seconds(skewport_target_time_in_seconds);
219 proto->set_skewport_extrapolation_limit_in_content_pixels(
220 skewport_extrapolation_limit_in_content_pixels);
221 proto->set_max_memory_for_prepaint_percentage(
222 max_memory_for_prepaint_percentage);
223 proto->set_strict_layer_property_change_checking(
224 strict_layer_property_change_checking);
225 proto->set_use_zero_copy(use_zero_copy);
226 proto->set_use_partial_raster(use_partial_raster);
227 proto->set_enable_elastic_overscroll(enable_elastic_overscroll);
228 proto->set_ignore_root_layer_flings(ignore_root_layer_flings);
229 proto->set_scheduled_raster_task_limit(scheduled_raster_task_limit);
230 proto->set_use_occlusion_for_tile_prioritization(
231 use_occlusion_for_tile_prioritization);
232 proto->set_verify_property_trees(verify_property_trees);
233 proto->set_use_property_trees(use_property_trees);
234 proto->set_image_decode_tasks_enabled(image_decode_tasks_enabled);
235 proto->set_use_compositor_animation_timelines(
236 use_compositor_animation_timelines);
237 proto->set_wait_for_beginframe_interval(wait_for_beginframe_interval);
238 proto->set_max_staging_buffer_usage_in_bytes(
239 max_staging_buffer_usage_in_bytes);
240 memory_policy_.ToProtobuf(proto->mutable_memory_policy());
241 initial_debug_state.ToProtobuf(proto->mutable_initial_debug_state());
242
243 for (unsigned u : use_image_texture_targets)
244 proto->add_use_image_texture_targets(u);
245}
246
247void LayerTreeSettings::FromProtobuf(const proto::LayerTreeSettings& proto) {
248 renderer_settings.FromProtobuf(proto.renderer_settings());
249 single_thread_proxy_scheduler = proto.single_thread_proxy_scheduler();
250 use_external_begin_frame_source = proto.use_external_begin_frame_source();
251 main_frame_before_activation_enabled =
252 proto.main_frame_before_activation_enabled();
253 using_synchronous_renderer_compositor =
254 proto.using_synchronous_renderer_compositor();
255 accelerated_animation_enabled = proto.accelerated_animation_enabled();
256 can_use_lcd_text = proto.can_use_lcd_text();
257 use_distance_field_text = proto.use_distance_field_text();
258 gpu_rasterization_enabled = proto.gpu_rasterization_enabled();
259 gpu_rasterization_forced = proto.gpu_rasterization_forced();
260 gpu_rasterization_msaa_sample_count =
261 proto.gpu_rasterization_msaa_sample_count();
262 create_low_res_tiling = proto.create_low_res_tiling();
263 scrollbar_animator =
264 LayerTreeSettingsScrollbarAnimatorFromProto(proto.scrollbar_animator());
265 scrollbar_fade_delay_ms = proto.scrollbar_fade_delay_ms();
266 scrollbar_fade_resize_delay_ms = proto.scrollbar_fade_resize_delay_ms();
267 scrollbar_fade_duration_ms = proto.scrollbar_fade_duration_ms();
268 solid_color_scrollbar_color = proto.solid_color_scrollbar_color();
269 timeout_and_draw_when_animation_checkerboards =
270 proto.timeout_and_draw_when_animation_checkerboards();
271 layer_transforms_should_scale_layer_contents =
272 proto.layer_transforms_should_scale_layer_contents();
273 layers_always_allowed_lcd_text = proto.layers_always_allowed_lcd_text();
274 minimum_contents_scale = proto.minimum_contents_scale();
275 low_res_contents_scale_factor = proto.low_res_contents_scale_factor();
276 top_controls_show_threshold = proto.top_controls_show_threshold();
277 top_controls_hide_threshold = proto.top_controls_hide_threshold();
278 background_animation_rate = proto.background_animation_rate();
279 default_tile_size = ProtoToSize(proto.default_tile_size());
280 max_untiled_layer_size = ProtoToSize(proto.max_untiled_layer_size());
281 minimum_occlusion_tracking_size =
282 ProtoToSize(proto.minimum_occlusion_tracking_size());
283 tiling_interest_area_padding = proto.tiling_interest_area_padding();
284 skewport_target_time_in_seconds = proto.skewport_target_time_in_seconds();
285 skewport_extrapolation_limit_in_content_pixels =
286 proto.skewport_extrapolation_limit_in_content_pixels();
287 max_memory_for_prepaint_percentage =
288 proto.max_memory_for_prepaint_percentage();
289 strict_layer_property_change_checking =
290 proto.strict_layer_property_change_checking();
291 use_zero_copy = proto.use_zero_copy();
292 use_partial_raster = proto.use_partial_raster();
293 enable_elastic_overscroll = proto.enable_elastic_overscroll();
294 // |use_image_texture_targets| contains default values, so clear first.
295 use_image_texture_targets.clear();
296 ignore_root_layer_flings = proto.ignore_root_layer_flings();
297 scheduled_raster_task_limit = proto.scheduled_raster_task_limit();
298 use_occlusion_for_tile_prioritization =
299 proto.use_occlusion_for_tile_prioritization();
300 verify_property_trees = proto.verify_property_trees();
301 use_property_trees = proto.use_property_trees();
302 image_decode_tasks_enabled = proto.image_decode_tasks_enabled();
303 use_compositor_animation_timelines =
304 proto.use_compositor_animation_timelines();
305 wait_for_beginframe_interval = proto.wait_for_beginframe_interval();
306 max_staging_buffer_usage_in_bytes = proto.max_staging_buffer_usage_in_bytes();
307 memory_policy_.FromProtobuf(proto.memory_policy());
308 initial_debug_state.FromProtobuf(proto.initial_debug_state());
309
310 for (int i = 0; i < proto.use_image_texture_targets_size(); ++i)
311 use_image_texture_targets.push_back(proto.use_image_texture_targets(i));
312}
313
jamesr6f64ab72015-03-18 20:29:03314SchedulerSettings LayerTreeSettings::ToSchedulerSettings() const {
315 SchedulerSettings scheduler_settings;
316 scheduler_settings.use_external_begin_frame_source =
317 use_external_begin_frame_source;
318 scheduler_settings.main_frame_before_activation_enabled =
319 main_frame_before_activation_enabled;
jamesr6f64ab72015-03-18 20:29:03320 scheduler_settings.timeout_and_draw_when_animation_checkerboards =
321 timeout_and_draw_when_animation_checkerboards;
jamesr6f64ab72015-03-18 20:29:03322 scheduler_settings.using_synchronous_renderer_compositor =
323 using_synchronous_renderer_compositor;
jincheol.jo5899bd552015-07-15 02:06:46324 scheduler_settings.throttle_frame_production = wait_for_beginframe_interval;
jamesr6f64ab72015-03-18 20:29:03325 scheduler_settings.background_frame_interval =
326 base::TimeDelta::FromSecondsD(1.0 / background_animation_rate);
327 return scheduler_settings;
328}
329
[email protected]ff762fb2012-12-12 19:18:37330} // namespace cc