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() << "proto::LayerTreeSettings_ScrollbarAnimator_UNKNOWN"; | |
| 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() << "proto::LayerTreeSettings_ScrollbarAnimator_UNKNOWN"; | |
| 49 return LayerTreeSettings::ScrollbarAnimator::NO_ANIMATOR; | |
| 50 } | |
| 51 return LayerTreeSettings::ScrollbarAnimator::NO_ANIMATOR; | |
| 52 } | |
| 53 | |
| 54 } // namespace | |
| 55 | |
| 17 LayerTreeSettings::LayerTreeSettings() | 56 LayerTreeSettings::LayerTreeSettings() |
| 18 : single_thread_proxy_scheduler(true), | 57 : single_thread_proxy_scheduler(true), |
| 19 use_external_begin_frame_source(false), | 58 use_external_begin_frame_source(false), |
| 20 main_frame_before_activation_enabled(false), | 59 main_frame_before_activation_enabled(false), |
| 21 using_synchronous_renderer_compositor(false), | 60 using_synchronous_renderer_compositor(false), |
| 22 accelerated_animation_enabled(true), | 61 accelerated_animation_enabled(true), |
| 23 can_use_lcd_text(true), | 62 can_use_lcd_text(true), |
| 24 use_distance_field_text(false), | 63 use_distance_field_text(false), |
| 25 gpu_rasterization_enabled(false), | 64 gpu_rasterization_enabled(false), |
| 26 gpu_rasterization_forced(false), | 65 gpu_rasterization_forced(false), |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 image_decode_tasks_enabled(false), | 102 image_decode_tasks_enabled(false), |
| 64 use_compositor_animation_timelines(false), | 103 use_compositor_animation_timelines(false), |
| 65 wait_for_beginframe_interval(true), | 104 wait_for_beginframe_interval(true), |
| 66 max_staging_buffer_usage_in_bytes(32 * 1024 * 1024), | 105 max_staging_buffer_usage_in_bytes(32 * 1024 * 1024), |
| 67 memory_policy_(64 * 1024 * 1024, | 106 memory_policy_(64 * 1024 * 1024, |
| 68 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, | 107 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, |
| 69 ManagedMemoryPolicy::kDefaultNumResourcesLimit) {} | 108 ManagedMemoryPolicy::kDefaultNumResourcesLimit) {} |
| 70 | 109 |
| 71 LayerTreeSettings::~LayerTreeSettings() {} | 110 LayerTreeSettings::~LayerTreeSettings() {} |
| 72 | 111 |
| 112 bool LayerTreeSettings::operator==(const LayerTreeSettings& other) const { | |
| 113 return renderer_settings == other.renderer_settings && | |
| 114 single_thread_proxy_scheduler == other.single_thread_proxy_scheduler && | |
| 115 use_external_begin_frame_source == | |
| 116 other.use_external_begin_frame_source && | |
| 117 main_frame_before_activation_enabled == | |
| 118 other.main_frame_before_activation_enabled && | |
| 119 using_synchronous_renderer_compositor == | |
| 120 other.using_synchronous_renderer_compositor && | |
| 121 accelerated_animation_enabled == other.accelerated_animation_enabled && | |
| 122 can_use_lcd_text == other.can_use_lcd_text && | |
| 123 use_distance_field_text == other.use_distance_field_text && | |
| 124 gpu_rasterization_enabled == other.gpu_rasterization_enabled && | |
| 125 gpu_rasterization_forced == other.gpu_rasterization_forced && | |
| 126 gpu_rasterization_msaa_sample_count == | |
| 127 other.gpu_rasterization_msaa_sample_count && | |
| 128 create_low_res_tiling == other.create_low_res_tiling && | |
| 129 scrollbar_animator == other.scrollbar_animator && | |
| 130 scrollbar_fade_delay_ms == other.scrollbar_fade_delay_ms && | |
| 131 scrollbar_fade_resize_delay_ms == | |
| 132 other.scrollbar_fade_resize_delay_ms && | |
| 133 scrollbar_fade_duration_ms == other.scrollbar_fade_duration_ms && | |
| 134 solid_color_scrollbar_color == other.solid_color_scrollbar_color && | |
| 135 timeout_and_draw_when_animation_checkerboards == | |
| 136 other.timeout_and_draw_when_animation_checkerboards && | |
| 137 layer_transforms_should_scale_layer_contents == | |
| 138 other.layer_transforms_should_scale_layer_contents && | |
| 139 layers_always_allowed_lcd_text == | |
| 140 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 == other.use_image_texture_targets && | |
| 163 ignore_root_layer_flings == other.ignore_root_layer_flings && | |
| 164 scheduled_raster_task_limit == other.scheduled_raster_task_limit && | |
| 165 use_occlusion_for_tile_prioritization == | |
| 166 other.use_occlusion_for_tile_prioritization && | |
| 167 verify_property_trees == other.verify_property_trees && | |
| 168 use_property_trees == other.use_property_trees && | |
| 169 image_decode_tasks_enabled == other.image_decode_tasks_enabled && | |
| 170 use_compositor_animation_timelines == | |
| 171 other.use_compositor_animation_timelines && | |
| 172 wait_for_beginframe_interval == other.wait_for_beginframe_interval && | |
| 173 max_staging_buffer_usage_in_bytes == | |
| 174 other.max_staging_buffer_usage_in_bytes && | |
| 175 memory_policy_ == other.memory_policy_ && | |
| 176 LayerTreeDebugState::Equal(initial_debug_state, | |
| 177 other.initial_debug_state); | |
| 178 } | |
| 179 | |
| 180 void LayerTreeSettings::ToProtobuf(proto::LayerTreeSettings* proto) const { | |
| 181 renderer_settings.ToProtobuf(proto->mutable_renderer_settings()); | |
| 182 proto->set_single_thread_proxy_scheduler(single_thread_proxy_scheduler); | |
| 183 proto->set_use_external_begin_frame_source(use_external_begin_frame_source); | |
| 184 proto->set_main_frame_before_activation_enabled( | |
| 185 main_frame_before_activation_enabled); | |
| 186 proto->set_using_synchronous_renderer_compositor( | |
| 187 using_synchronous_renderer_compositor); | |
| 188 proto->set_accelerated_animation_enabled(accelerated_animation_enabled); | |
| 189 proto->set_can_use_lcd_text(can_use_lcd_text); | |
| 190 proto->set_use_distance_field_text(use_distance_field_text); | |
| 191 proto->set_gpu_rasterization_enabled(gpu_rasterization_enabled); | |
| 192 proto->set_gpu_rasterization_forced(gpu_rasterization_forced); | |
| 193 proto->set_gpu_rasterization_msaa_sample_count( | |
| 194 gpu_rasterization_msaa_sample_count); | |
| 195 proto->set_create_low_res_tiling(create_low_res_tiling); | |
| 196 proto->set_scrollbar_animator( | |
| 197 LayerTreeSettingsScrollbarAnimatorToProto(scrollbar_animator)); | |
| 198 proto->set_scrollbar_fade_delay_ms(scrollbar_fade_delay_ms); | |
| 199 proto->set_scrollbar_fade_resize_delay_ms(scrollbar_fade_resize_delay_ms); | |
| 200 proto->set_scrollbar_fade_duration_ms(scrollbar_fade_duration_ms); | |
| 201 proto->set_solid_color_scrollbar_color(solid_color_scrollbar_color); | |
| 202 proto->set_timeout_and_draw_when_animation_checkerboards( | |
| 203 timeout_and_draw_when_animation_checkerboards); | |
| 204 proto->set_layer_transforms_should_scale_layer_contents( | |
| 205 layer_transforms_should_scale_layer_contents); | |
| 206 proto->set_layers_always_allowed_lcd_text(layers_always_allowed_lcd_text); | |
| 207 proto->set_minimum_contents_scale(minimum_contents_scale); | |
| 208 proto->set_low_res_contents_scale_factor(low_res_contents_scale_factor); | |
| 209 proto->set_top_controls_show_threshold(top_controls_show_threshold); | |
| 210 proto->set_top_controls_hide_threshold(top_controls_hide_threshold); | |
| 211 proto->set_background_animation_rate(background_animation_rate); | |
| 212 SizeToProto(default_tile_size, proto->mutable_default_tile_size()); | |
| 213 SizeToProto(max_untiled_layer_size, proto->mutable_max_untiled_layer_size()); | |
| 214 SizeToProto(minimum_occlusion_tracking_size, | |
| 215 proto->mutable_minimum_occlusion_tracking_size()); | |
| 216 proto->set_tiling_interest_area_padding(tiling_interest_area_padding); | |
| 217 proto->set_skewport_target_time_in_seconds(skewport_target_time_in_seconds); | |
| 218 proto->set_skewport_extrapolation_limit_in_content_pixels( | |
| 219 skewport_extrapolation_limit_in_content_pixels); | |
| 220 proto->set_max_memory_for_prepaint_percentage( | |
| 221 max_memory_for_prepaint_percentage); | |
| 222 proto->set_strict_layer_property_change_checking( | |
| 223 strict_layer_property_change_checking); | |
| 224 proto->set_use_zero_copy(use_zero_copy); | |
| 225 proto->set_use_partial_raster(use_partial_raster); | |
| 226 proto->set_enable_elastic_overscroll(enable_elastic_overscroll); | |
| 227 proto->set_ignore_root_layer_flings(ignore_root_layer_flings); | |
| 228 proto->set_scheduled_raster_task_limit(scheduled_raster_task_limit); | |
| 229 proto->set_use_occlusion_for_tile_prioritization( | |
| 230 use_occlusion_for_tile_prioritization); | |
| 231 proto->set_verify_property_trees(verify_property_trees); | |
| 232 proto->set_use_property_trees(use_property_trees); | |
| 233 proto->set_image_decode_tasks_enabled(image_decode_tasks_enabled); | |
| 234 proto->set_use_compositor_animation_timelines( | |
| 235 use_compositor_animation_timelines); | |
| 236 proto->set_wait_for_beginframe_interval(wait_for_beginframe_interval); | |
| 237 proto->set_max_staging_buffer_usage_in_bytes( | |
| 238 max_staging_buffer_usage_in_bytes); | |
| 239 memory_policy_.ToProtobuf(proto->mutable_memory_policy()); | |
| 240 initial_debug_state.ToProtobuf(proto->mutable_initial_debug_state()); | |
| 241 | |
| 242 for (unsigned u : use_image_texture_targets) | |
| 243 proto->add_use_image_texture_targets(u); | |
| 244 } | |
| 245 | |
| 246 void LayerTreeSettings::FromProtobuf(const proto::LayerTreeSettings& proto) { | |
| 247 renderer_settings.FromProtobuf(proto.renderer_settings()); | |
| 248 single_thread_proxy_scheduler = proto.single_thread_proxy_scheduler(); | |
| 249 use_external_begin_frame_source = proto.use_external_begin_frame_source(); | |
| 250 main_frame_before_activation_enabled = | |
| 251 proto.main_frame_before_activation_enabled(); | |
| 252 using_synchronous_renderer_compositor = | |
| 253 proto.using_synchronous_renderer_compositor(); | |
| 254 accelerated_animation_enabled = proto.accelerated_animation_enabled(); | |
| 255 can_use_lcd_text = proto.can_use_lcd_text(); | |
| 256 use_distance_field_text = proto.use_distance_field_text(); | |
| 257 gpu_rasterization_enabled = proto.gpu_rasterization_enabled(); | |
| 258 gpu_rasterization_forced = proto.gpu_rasterization_forced(); | |
| 259 gpu_rasterization_msaa_sample_count = | |
| 260 proto.gpu_rasterization_msaa_sample_count(); | |
| 261 create_low_res_tiling = proto.create_low_res_tiling(); | |
| 262 scrollbar_animator = | |
| 263 LayerTreeSettingsScrollbarAnimatorFromProto(proto.scrollbar_animator()); | |
| 264 scrollbar_fade_delay_ms = proto.scrollbar_fade_delay_ms(); | |
| 265 scrollbar_fade_resize_delay_ms = proto.scrollbar_fade_resize_delay_ms(); | |
| 266 scrollbar_fade_duration_ms = proto.scrollbar_fade_duration_ms(); | |
| 267 solid_color_scrollbar_color = proto.solid_color_scrollbar_color(); | |
| 268 timeout_and_draw_when_animation_checkerboards = | |
| 269 proto.timeout_and_draw_when_animation_checkerboards(); | |
| 270 layer_transforms_should_scale_layer_contents = | |
| 271 proto.layer_transforms_should_scale_layer_contents(); | |
| 272 layers_always_allowed_lcd_text = proto.layers_always_allowed_lcd_text(); | |
| 273 minimum_contents_scale = proto.minimum_contents_scale(); | |
| 274 low_res_contents_scale_factor = proto.low_res_contents_scale_factor(); | |
| 275 top_controls_show_threshold = proto.top_controls_show_threshold(); | |
| 276 top_controls_hide_threshold = proto.top_controls_hide_threshold(); | |
| 277 background_animation_rate = proto.background_animation_rate(); | |
| 278 default_tile_size = ProtoToSize(proto.default_tile_size()); | |
| 279 max_untiled_layer_size = ProtoToSize(proto.max_untiled_layer_size()); | |
| 280 minimum_occlusion_tracking_size = | |
| 281 ProtoToSize(proto.minimum_occlusion_tracking_size()); | |
| 282 tiling_interest_area_padding = proto.tiling_interest_area_padding(); | |
| 283 skewport_target_time_in_seconds = proto.skewport_target_time_in_seconds(); | |
| 284 skewport_extrapolation_limit_in_content_pixels = | |
| 285 proto.skewport_extrapolation_limit_in_content_pixels(); | |
| 286 max_memory_for_prepaint_percentage = | |
| 287 proto.max_memory_for_prepaint_percentage(); | |
| 288 strict_layer_property_change_checking = | |
| 289 proto.strict_layer_property_change_checking(); | |
| 290 use_zero_copy = proto.use_zero_copy(); | |
| 291 use_partial_raster = proto.use_partial_raster(); | |
| 292 enable_elastic_overscroll = proto.enable_elastic_overscroll(); | |
| 293 // |use_image_texture_targets| contains default values, so clear first. | |
| 294 use_image_texture_targets.clear(); | |
| 295 ignore_root_layer_flings = proto.ignore_root_layer_flings(); | |
| 296 scheduled_raster_task_limit = proto.scheduled_raster_task_limit(); | |
| 297 use_occlusion_for_tile_prioritization = | |
| 298 proto.use_occlusion_for_tile_prioritization(); | |
| 299 verify_property_trees = proto.verify_property_trees(); | |
| 300 use_property_trees = proto.use_property_trees(); | |
| 301 image_decode_tasks_enabled = proto.image_decode_tasks_enabled(); | |
| 302 use_compositor_animation_timelines = | |
| 303 proto.use_compositor_animation_timelines(); | |
| 304 wait_for_beginframe_interval = proto.wait_for_beginframe_interval(); | |
| 305 max_staging_buffer_usage_in_bytes = proto.max_staging_buffer_usage_in_bytes(); | |
| 306 memory_policy_.FromProtobuf(proto.memory_policy()); | |
| 307 initial_debug_state.FromProtobuf(proto.initial_debug_state()); | |
| 308 | |
| 309 for (int i = 0; i < proto.use_image_texture_targets_size(); i++) | |
|
vmpstr
2015/12/10 00:51:24
++i
nyquist
2015/12/10 01:22:56
Done.
| |
| 310 use_image_texture_targets.push_back(proto.use_image_texture_targets(i)); | |
| 311 } | |
| 312 | |
| 73 SchedulerSettings LayerTreeSettings::ToSchedulerSettings() const { | 313 SchedulerSettings LayerTreeSettings::ToSchedulerSettings() const { |
| 74 SchedulerSettings scheduler_settings; | 314 SchedulerSettings scheduler_settings; |
| 75 scheduler_settings.use_external_begin_frame_source = | 315 scheduler_settings.use_external_begin_frame_source = |
| 76 use_external_begin_frame_source; | 316 use_external_begin_frame_source; |
| 77 scheduler_settings.main_frame_before_activation_enabled = | 317 scheduler_settings.main_frame_before_activation_enabled = |
| 78 main_frame_before_activation_enabled; | 318 main_frame_before_activation_enabled; |
| 79 scheduler_settings.timeout_and_draw_when_animation_checkerboards = | 319 scheduler_settings.timeout_and_draw_when_animation_checkerboards = |
| 80 timeout_and_draw_when_animation_checkerboards; | 320 timeout_and_draw_when_animation_checkerboards; |
| 81 scheduler_settings.using_synchronous_renderer_compositor = | 321 scheduler_settings.using_synchronous_renderer_compositor = |
| 82 using_synchronous_renderer_compositor; | 322 using_synchronous_renderer_compositor; |
| 83 scheduler_settings.throttle_frame_production = wait_for_beginframe_interval; | 323 scheduler_settings.throttle_frame_production = wait_for_beginframe_interval; |
| 84 scheduler_settings.background_frame_interval = | 324 scheduler_settings.background_frame_interval = |
| 85 base::TimeDelta::FromSecondsD(1.0 / background_animation_rate); | 325 base::TimeDelta::FromSecondsD(1.0 / background_animation_rate); |
| 86 return scheduler_settings; | 326 return scheduler_settings; |
| 87 } | 327 } |
| 88 | 328 |
| 89 } // namespace cc | 329 } // namespace cc |
| OLD | NEW |