Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/trees/layer_tree_settings.h" | 5 #include "cc/trees/layer_tree_settings.h" |
| 6 | 6 |
| 7 #include <GLES2/gl2.h> | 7 #include <GLES2/gl2.h> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "cc/proto/gfx_conversions.h" | |
| 14 #include "cc/proto/gpu_conversions.h" | |
| 15 #include "cc/proto/layer_tree_settings.pb.h" | |
| 13 #include "ui/gfx/buffer_types.h" | 16 #include "ui/gfx/buffer_types.h" |
| 14 | 17 |
| 15 namespace cc { | 18 namespace cc { |
| 16 | 19 |
| 20 namespace { | |
| 21 | |
| 22 proto::LayerTreeSettings_ScrollbarAnimator | |
| 23 LayerTreeSettingsScrollbarAnimatorToProto( | |
| 24 const LayerTreeSettings::ScrollbarAnimator& animator) { | |
| 25 switch (animator) { | |
| 26 case LayerTreeSettings::ScrollbarAnimator::NO_ANIMATOR: | |
| 27 return proto::LayerTreeSettings_ScrollbarAnimator_NO_ANIMATOR; | |
| 28 case LayerTreeSettings::ScrollbarAnimator::LINEAR_FADE: | |
| 29 return proto::LayerTreeSettings_ScrollbarAnimator_LINEAR_FADE; | |
| 30 case LayerTreeSettings::ScrollbarAnimator::THINNING: | |
| 31 return proto::LayerTreeSettings_ScrollbarAnimator_THINNING; | |
| 32 } | |
| 33 NOTREACHED() << "Sending proto::LayerTreeSettings_ScrollbarAnimator_UNKNOWN"; | |
|
vmpstr
2015/12/08 18:26:13
nit: s/Sending //
I'd like to avoid language tha
nyquist
2015/12/08 22:44:58
Done.
| |
| 34 return proto::LayerTreeSettings_ScrollbarAnimator_UNKNOWN; | |
| 35 } | |
| 36 | |
| 37 LayerTreeSettings::ScrollbarAnimator | |
| 38 LayerTreeSettingsScrollbarAnimatorFromProto( | |
| 39 const proto::LayerTreeSettings_ScrollbarAnimator& animator) { | |
| 40 switch (animator) { | |
| 41 case proto::LayerTreeSettings_ScrollbarAnimator_NO_ANIMATOR: | |
| 42 return LayerTreeSettings::ScrollbarAnimator::NO_ANIMATOR; | |
| 43 case proto::LayerTreeSettings_ScrollbarAnimator_LINEAR_FADE: | |
| 44 return LayerTreeSettings::ScrollbarAnimator::LINEAR_FADE; | |
| 45 case proto::LayerTreeSettings_ScrollbarAnimator_THINNING: | |
| 46 return LayerTreeSettings::ScrollbarAnimator::THINNING; | |
| 47 case proto::LayerTreeSettings_ScrollbarAnimator_UNKNOWN: | |
| 48 NOTREACHED() | |
| 49 << "Received proto::LayerTreeSettings_ScrollbarAnimator_UNKNOWN"; | |
|
vmpstr
2015/12/08 18:26:13
nit: s/Received //
nyquist
2015/12/08 22:44:58
Done.
| |
| 50 return LayerTreeSettings::ScrollbarAnimator::NO_ANIMATOR; | |
| 51 } | |
| 52 return LayerTreeSettings::ScrollbarAnimator::NO_ANIMATOR; | |
| 53 } | |
| 54 | |
| 55 } // namespace | |
| 56 | |
| 17 LayerTreeSettings::LayerTreeSettings() | 57 LayerTreeSettings::LayerTreeSettings() |
| 18 : single_thread_proxy_scheduler(true), | 58 : single_thread_proxy_scheduler(true), |
| 19 use_external_begin_frame_source(false), | 59 use_external_begin_frame_source(false), |
| 20 main_frame_before_activation_enabled(false), | 60 main_frame_before_activation_enabled(false), |
| 21 using_synchronous_renderer_compositor(false), | 61 using_synchronous_renderer_compositor(false), |
| 22 accelerated_animation_enabled(true), | 62 accelerated_animation_enabled(true), |
| 23 can_use_lcd_text(true), | 63 can_use_lcd_text(true), |
| 24 use_distance_field_text(false), | 64 use_distance_field_text(false), |
| 25 gpu_rasterization_enabled(false), | 65 gpu_rasterization_enabled(false), |
| 26 gpu_rasterization_forced(false), | 66 gpu_rasterization_forced(false), |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 image_decode_tasks_enabled(false), | 103 image_decode_tasks_enabled(false), |
| 64 use_compositor_animation_timelines(false), | 104 use_compositor_animation_timelines(false), |
| 65 wait_for_beginframe_interval(true), | 105 wait_for_beginframe_interval(true), |
| 66 max_staging_buffer_usage_in_bytes(32 * 1024 * 1024), | 106 max_staging_buffer_usage_in_bytes(32 * 1024 * 1024), |
| 67 memory_policy_(64 * 1024 * 1024, | 107 memory_policy_(64 * 1024 * 1024, |
| 68 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, | 108 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, |
| 69 ManagedMemoryPolicy::kDefaultNumResourcesLimit) {} | 109 ManagedMemoryPolicy::kDefaultNumResourcesLimit) {} |
| 70 | 110 |
| 71 LayerTreeSettings::~LayerTreeSettings() {} | 111 LayerTreeSettings::~LayerTreeSettings() {} |
| 72 | 112 |
| 113 bool LayerTreeSettings::operator==(const LayerTreeSettings& other) const { | |
| 114 bool equals = | |
| 115 renderer_settings == other.renderer_settings && | |
| 116 single_thread_proxy_scheduler == other.single_thread_proxy_scheduler && | |
| 117 use_external_begin_frame_source == | |
| 118 other.use_external_begin_frame_source && | |
| 119 main_frame_before_activation_enabled == | |
| 120 other.main_frame_before_activation_enabled && | |
| 121 using_synchronous_renderer_compositor == | |
| 122 other.using_synchronous_renderer_compositor && | |
| 123 accelerated_animation_enabled == other.accelerated_animation_enabled && | |
| 124 can_use_lcd_text == other.can_use_lcd_text && | |
| 125 use_distance_field_text == other.use_distance_field_text && | |
| 126 gpu_rasterization_enabled == other.gpu_rasterization_enabled && | |
| 127 gpu_rasterization_forced == other.gpu_rasterization_forced && | |
| 128 gpu_rasterization_msaa_sample_count == | |
| 129 other.gpu_rasterization_msaa_sample_count && | |
| 130 create_low_res_tiling == other.create_low_res_tiling && | |
| 131 scrollbar_animator == other.scrollbar_animator && | |
| 132 scrollbar_fade_delay_ms == other.scrollbar_fade_delay_ms && | |
| 133 scrollbar_fade_resize_delay_ms == 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 == other.layers_always_allowed_lcd_text && | |
| 141 minimum_contents_scale == other.minimum_contents_scale && | |
| 142 low_res_contents_scale_factor == other.low_res_contents_scale_factor && | |
| 143 top_controls_show_threshold == other.top_controls_show_threshold && | |
| 144 top_controls_hide_threshold == other.top_controls_hide_threshold && | |
| 145 background_animation_rate == other.background_animation_rate && | |
| 146 default_tile_size == other.default_tile_size && | |
| 147 max_untiled_layer_size == other.max_untiled_layer_size && | |
| 148 minimum_occlusion_tracking_size == | |
| 149 other.minimum_occlusion_tracking_size && | |
| 150 tiling_interest_area_padding == other.tiling_interest_area_padding && | |
| 151 skewport_target_time_in_seconds == | |
| 152 other.skewport_target_time_in_seconds && | |
| 153 skewport_extrapolation_limit_in_content_pixels == | |
| 154 other.skewport_extrapolation_limit_in_content_pixels && | |
| 155 max_memory_for_prepaint_percentage == | |
| 156 other.max_memory_for_prepaint_percentage && | |
| 157 strict_layer_property_change_checking == | |
| 158 other.strict_layer_property_change_checking && | |
| 159 use_zero_copy == other.use_zero_copy && | |
| 160 use_partial_raster == other.use_partial_raster && | |
| 161 enable_elastic_overscroll == other.enable_elastic_overscroll && | |
| 162 use_image_texture_targets.size() == | |
| 163 other.use_image_texture_targets.size() && // See below. | |
|
vmpstr
2015/12/08 18:26:13
std::vector has operator==, you can just compare t
nyquist
2015/12/08 22:44:58
Done.
Also; I'm sorry, because this messed up the
| |
| 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 if (!equals) | |
| 180 return false; | |
| 181 int i = 0; | |
| 182 for (auto u : use_image_texture_targets) { | |
| 183 if (u != other.use_image_texture_targets[i++]) | |
| 184 return false; | |
| 185 } | |
| 186 return true; | |
| 187 } | |
| 188 | |
| 189 void LayerTreeSettings::ToProtobuf(proto::LayerTreeSettings* proto) const { | |
| 190 renderer_settings.ToProtobuf(proto->mutable_renderer_settings()); | |
| 191 proto->set_single_thread_proxy_scheduler(single_thread_proxy_scheduler); | |
| 192 proto->set_use_external_begin_frame_source(use_external_begin_frame_source); | |
| 193 proto->set_main_frame_before_activation_enabled( | |
| 194 main_frame_before_activation_enabled); | |
| 195 proto->set_using_synchronous_renderer_compositor( | |
| 196 using_synchronous_renderer_compositor); | |
| 197 proto->set_accelerated_animation_enabled(accelerated_animation_enabled); | |
| 198 proto->set_can_use_lcd_text(can_use_lcd_text); | |
| 199 proto->set_use_distance_field_text(use_distance_field_text); | |
| 200 proto->set_gpu_rasterization_enabled(gpu_rasterization_enabled); | |
| 201 proto->set_gpu_rasterization_forced(gpu_rasterization_forced); | |
| 202 proto->set_gpu_rasterization_msaa_sample_count( | |
| 203 gpu_rasterization_msaa_sample_count); | |
| 204 proto->set_create_low_res_tiling(create_low_res_tiling); | |
| 205 proto->set_scrollbar_animator( | |
| 206 LayerTreeSettingsScrollbarAnimatorToProto(scrollbar_animator)); | |
| 207 proto->set_scrollbar_fade_delay_ms(scrollbar_fade_delay_ms); | |
| 208 proto->set_scrollbar_fade_resize_delay_ms(scrollbar_fade_resize_delay_ms); | |
| 209 proto->set_scrollbar_fade_duration_ms(scrollbar_fade_duration_ms); | |
| 210 proto->set_solid_color_scrollbar_color(solid_color_scrollbar_color); | |
| 211 proto->set_timeout_and_draw_when_animation_checkerboards( | |
| 212 timeout_and_draw_when_animation_checkerboards); | |
| 213 proto->set_layer_transforms_should_scale_layer_contents( | |
| 214 layer_transforms_should_scale_layer_contents); | |
| 215 proto->set_layers_always_allowed_lcd_text(layers_always_allowed_lcd_text); | |
| 216 proto->set_minimum_contents_scale(minimum_contents_scale); | |
| 217 proto->set_low_res_contents_scale_factor(low_res_contents_scale_factor); | |
| 218 proto->set_top_controls_show_threshold(top_controls_show_threshold); | |
| 219 proto->set_top_controls_hide_threshold(top_controls_hide_threshold); | |
| 220 proto->set_background_animation_rate(background_animation_rate); | |
| 221 SizeToProto(default_tile_size, proto->mutable_default_tile_size()); | |
| 222 SizeToProto(max_untiled_layer_size, proto->mutable_max_untiled_layer_size()); | |
| 223 SizeToProto(minimum_occlusion_tracking_size, | |
| 224 proto->mutable_minimum_occlusion_tracking_size()); | |
| 225 proto->set_tiling_interest_area_padding(tiling_interest_area_padding); | |
| 226 proto->set_skewport_target_time_in_seconds(skewport_target_time_in_seconds); | |
| 227 proto->set_skewport_extrapolation_limit_in_content_pixels( | |
| 228 skewport_extrapolation_limit_in_content_pixels); | |
| 229 proto->set_max_memory_for_prepaint_percentage( | |
| 230 max_memory_for_prepaint_percentage); | |
| 231 proto->set_strict_layer_property_change_checking( | |
| 232 strict_layer_property_change_checking); | |
| 233 proto->set_use_zero_copy(use_zero_copy); | |
| 234 proto->set_use_partial_raster(use_partial_raster); | |
| 235 proto->set_enable_elastic_overscroll(enable_elastic_overscroll); | |
| 236 for (auto u : use_image_texture_targets) | |
|
vmpstr
2015/12/08 18:26:13
can you put this at the end with a blank line befo
nyquist
2015/12/08 22:44:58
Done.
| |
| 237 proto->add_use_image_texture_targets(u); | |
| 238 proto->set_ignore_root_layer_flings(ignore_root_layer_flings); | |
| 239 proto->set_scheduled_raster_task_limit(scheduled_raster_task_limit); | |
| 240 proto->set_use_occlusion_for_tile_prioritization( | |
| 241 use_occlusion_for_tile_prioritization); | |
| 242 proto->set_verify_property_trees(verify_property_trees); | |
| 243 proto->set_use_property_trees(use_property_trees); | |
| 244 proto->set_image_decode_tasks_enabled(image_decode_tasks_enabled); | |
| 245 proto->set_use_compositor_animation_timelines( | |
| 246 use_compositor_animation_timelines); | |
| 247 proto->set_wait_for_beginframe_interval(wait_for_beginframe_interval); | |
| 248 proto->set_max_staging_buffer_usage_in_bytes( | |
| 249 max_staging_buffer_usage_in_bytes); | |
| 250 memory_policy_.ToProtobuf(proto->mutable_memory_policy()); | |
| 251 initial_debug_state.ToProtobuf(proto->mutable_initial_debug_state()); | |
| 252 } | |
| 253 | |
| 254 void LayerTreeSettings::FromProtobuf(const proto::LayerTreeSettings& proto) { | |
| 255 renderer_settings.FromProtobuf(proto.renderer_settings()); | |
| 256 single_thread_proxy_scheduler = proto.single_thread_proxy_scheduler(); | |
| 257 use_external_begin_frame_source = proto.use_external_begin_frame_source(); | |
| 258 main_frame_before_activation_enabled = | |
| 259 proto.main_frame_before_activation_enabled(); | |
| 260 using_synchronous_renderer_compositor = | |
| 261 proto.using_synchronous_renderer_compositor(); | |
| 262 accelerated_animation_enabled = proto.accelerated_animation_enabled(); | |
| 263 can_use_lcd_text = proto.can_use_lcd_text(); | |
| 264 use_distance_field_text = proto.use_distance_field_text(); | |
| 265 gpu_rasterization_enabled = proto.gpu_rasterization_enabled(); | |
| 266 gpu_rasterization_forced = proto.gpu_rasterization_forced(); | |
| 267 gpu_rasterization_msaa_sample_count = | |
| 268 proto.gpu_rasterization_msaa_sample_count(); | |
| 269 create_low_res_tiling = proto.create_low_res_tiling(); | |
| 270 scrollbar_animator = | |
| 271 LayerTreeSettingsScrollbarAnimatorFromProto(proto.scrollbar_animator()); | |
| 272 scrollbar_fade_delay_ms = proto.scrollbar_fade_delay_ms(); | |
| 273 scrollbar_fade_resize_delay_ms = proto.scrollbar_fade_resize_delay_ms(); | |
| 274 scrollbar_fade_duration_ms = proto.scrollbar_fade_duration_ms(); | |
| 275 solid_color_scrollbar_color = proto.solid_color_scrollbar_color(); | |
| 276 timeout_and_draw_when_animation_checkerboards = | |
| 277 proto.timeout_and_draw_when_animation_checkerboards(); | |
| 278 layer_transforms_should_scale_layer_contents = | |
| 279 proto.layer_transforms_should_scale_layer_contents(); | |
| 280 layers_always_allowed_lcd_text = proto.layers_always_allowed_lcd_text(); | |
| 281 minimum_contents_scale = proto.minimum_contents_scale(); | |
| 282 low_res_contents_scale_factor = proto.low_res_contents_scale_factor(); | |
| 283 top_controls_show_threshold = proto.top_controls_show_threshold(); | |
| 284 top_controls_hide_threshold = proto.top_controls_hide_threshold(); | |
| 285 background_animation_rate = proto.background_animation_rate(); | |
| 286 default_tile_size = ProtoToSize(proto.default_tile_size()); | |
| 287 max_untiled_layer_size = ProtoToSize(proto.max_untiled_layer_size()); | |
| 288 minimum_occlusion_tracking_size = | |
| 289 ProtoToSize(proto.minimum_occlusion_tracking_size()); | |
| 290 tiling_interest_area_padding = proto.tiling_interest_area_padding(); | |
| 291 skewport_target_time_in_seconds = proto.skewport_target_time_in_seconds(); | |
| 292 skewport_extrapolation_limit_in_content_pixels = | |
| 293 proto.skewport_extrapolation_limit_in_content_pixels(); | |
| 294 max_memory_for_prepaint_percentage = | |
| 295 proto.max_memory_for_prepaint_percentage(); | |
| 296 strict_layer_property_change_checking = | |
| 297 proto.strict_layer_property_change_checking(); | |
| 298 use_zero_copy = proto.use_zero_copy(); | |
| 299 use_partial_raster = proto.use_partial_raster(); | |
| 300 enable_elastic_overscroll = proto.enable_elastic_overscroll(); | |
| 301 // |use_image_texture_targets| contains default values, so clear first. | |
| 302 use_image_texture_targets.clear(); | |
| 303 for (int i = 0; i < proto.use_image_texture_targets_size(); i++) | |
|
vmpstr
2015/12/08 18:26:13
Can you put this at the end with a blank line befo
nyquist
2015/12/08 22:44:58
Done.
| |
| 304 use_image_texture_targets.push_back(proto.use_image_texture_targets(i)); | |
| 305 ignore_root_layer_flings = proto.ignore_root_layer_flings(); | |
| 306 scheduled_raster_task_limit = proto.scheduled_raster_task_limit(); | |
| 307 use_occlusion_for_tile_prioritization = | |
| 308 proto.use_occlusion_for_tile_prioritization(); | |
| 309 verify_property_trees = proto.verify_property_trees(); | |
| 310 use_property_trees = proto.use_property_trees(); | |
| 311 image_decode_tasks_enabled = proto.image_decode_tasks_enabled(); | |
| 312 use_compositor_animation_timelines = | |
| 313 proto.use_compositor_animation_timelines(); | |
| 314 wait_for_beginframe_interval = proto.wait_for_beginframe_interval(); | |
| 315 max_staging_buffer_usage_in_bytes = proto.max_staging_buffer_usage_in_bytes(); | |
| 316 memory_policy_.FromProtobuf(proto.memory_policy()); | |
| 317 initial_debug_state.FromProtobuf(proto.initial_debug_state()); | |
| 318 } | |
| 319 | |
| 73 SchedulerSettings LayerTreeSettings::ToSchedulerSettings() const { | 320 SchedulerSettings LayerTreeSettings::ToSchedulerSettings() const { |
| 74 SchedulerSettings scheduler_settings; | 321 SchedulerSettings scheduler_settings; |
| 75 scheduler_settings.use_external_begin_frame_source = | 322 scheduler_settings.use_external_begin_frame_source = |
| 76 use_external_begin_frame_source; | 323 use_external_begin_frame_source; |
| 77 scheduler_settings.main_frame_before_activation_enabled = | 324 scheduler_settings.main_frame_before_activation_enabled = |
| 78 main_frame_before_activation_enabled; | 325 main_frame_before_activation_enabled; |
| 79 scheduler_settings.timeout_and_draw_when_animation_checkerboards = | 326 scheduler_settings.timeout_and_draw_when_animation_checkerboards = |
| 80 timeout_and_draw_when_animation_checkerboards; | 327 timeout_and_draw_when_animation_checkerboards; |
| 81 scheduler_settings.using_synchronous_renderer_compositor = | 328 scheduler_settings.using_synchronous_renderer_compositor = |
| 82 using_synchronous_renderer_compositor; | 329 using_synchronous_renderer_compositor; |
| 83 scheduler_settings.throttle_frame_production = wait_for_beginframe_interval; | 330 scheduler_settings.throttle_frame_production = wait_for_beginframe_interval; |
| 84 scheduler_settings.background_frame_interval = | 331 scheduler_settings.background_frame_interval = |
| 85 base::TimeDelta::FromSecondsD(1.0 / background_animation_rate); | 332 base::TimeDelta::FromSecondsD(1.0 / background_animation_rate); |
| 86 return scheduler_settings; | 333 return scheduler_settings; |
| 87 } | 334 } |
| 88 | 335 |
| 89 } // namespace cc | 336 } // namespace cc |
| OLD | NEW |