layer_tree_debug_state.cc 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. #include "cc/debug/layer_tree_debug_state.h"
  5. namespace cc {
  6. // IMPORTANT: new fields must be added to Equal() and Unite()
  7. LayerTreeDebugState::LayerTreeDebugState() = default;
  8. LayerTreeDebugState::LayerTreeDebugState(const LayerTreeDebugState& other) =
  9. default;
  10. LayerTreeDebugState::~LayerTreeDebugState() = default;
  11. void LayerTreeDebugState::SetRecordRenderingStats(bool enabled) {
  12. record_rendering_stats_ = enabled;
  13. }
  14. bool LayerTreeDebugState::RecordRenderingStats() const {
  15. return record_rendering_stats_;
  16. }
  17. bool LayerTreeDebugState::ShouldCreateHudLayer() const {
  18. return ShowDebugRects() || ShouldDrawHudInfo();
  19. }
  20. bool LayerTreeDebugState::ShowDebugRects() const {
  21. return show_paint_rects || show_property_changed_rects ||
  22. show_surface_damage_rects || show_screen_space_rects ||
  23. show_touch_event_handler_rects || show_wheel_event_handler_rects ||
  24. show_scroll_event_handler_rects || show_non_fast_scrollable_rects ||
  25. show_main_thread_scrolling_reason_rects ||
  26. show_layer_animation_bounds_rects || show_layout_shift_regions;
  27. }
  28. bool LayerTreeDebugState::ShowMemoryStats() const {
  29. return show_fps_counter;
  30. }
  31. bool LayerTreeDebugState::ShouldDrawHudInfo() const {
  32. return show_fps_counter || show_web_vital_metrics || show_smoothness_metrics;
  33. }
  34. void LayerTreeDebugState::TurnOffHudInfoDisplay() {
  35. // Turn off all types of HUD info display. ShouldDrawHudInfo() would return
  36. // false after this function.
  37. show_fps_counter = false;
  38. show_web_vital_metrics = false;
  39. show_smoothness_metrics = false;
  40. }
  41. bool LayerTreeDebugState::Equal(const LayerTreeDebugState& a,
  42. const LayerTreeDebugState& b) {
  43. return (
  44. a.show_fps_counter == b.show_fps_counter &&
  45. a.show_debug_borders == b.show_debug_borders &&
  46. a.show_layout_shift_regions == b.show_layout_shift_regions &&
  47. a.show_paint_rects == b.show_paint_rects &&
  48. a.show_property_changed_rects == b.show_property_changed_rects &&
  49. a.show_surface_damage_rects == b.show_surface_damage_rects &&
  50. a.show_screen_space_rects == b.show_screen_space_rects &&
  51. a.show_touch_event_handler_rects == b.show_touch_event_handler_rects &&
  52. a.show_wheel_event_handler_rects == b.show_wheel_event_handler_rects &&
  53. a.show_scroll_event_handler_rects == b.show_scroll_event_handler_rects &&
  54. a.show_non_fast_scrollable_rects == b.show_non_fast_scrollable_rects &&
  55. a.show_main_thread_scrolling_reason_rects ==
  56. b.show_main_thread_scrolling_reason_rects &&
  57. a.show_layer_animation_bounds_rects ==
  58. b.show_layer_animation_bounds_rects &&
  59. a.slow_down_raster_scale_factor == b.slow_down_raster_scale_factor &&
  60. a.rasterize_only_visible_content == b.rasterize_only_visible_content &&
  61. a.highlight_non_lcd_text_layers == b.highlight_non_lcd_text_layers &&
  62. a.show_web_vital_metrics == b.show_web_vital_metrics &&
  63. a.record_rendering_stats_ == b.record_rendering_stats_);
  64. }
  65. } // namespace cc