• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "cc/debug/layer_tree_debug_state.h"
6 
7 #include "base/logging.h"
8 
9 namespace cc {
10 
11 // IMPORTANT: new fields must be added to Equal() and Unite()
LayerTreeDebugState()12 LayerTreeDebugState::LayerTreeDebugState()
13     : show_fps_counter(false),
14       show_debug_borders(false),
15       continuous_painting(false),
16       show_paint_rects(false),
17       show_property_changed_rects(false),
18       show_surface_damage_rects(false),
19       show_screen_space_rects(false),
20       show_replica_screen_space_rects(false),
21       show_occluding_rects(false),
22       show_non_occluding_rects(false),
23       show_touch_event_handler_rects(false),
24       show_wheel_event_handler_rects(false),
25       show_non_fast_scrollable_rects(false),
26       show_layer_animation_bounds_rects(false),
27       slow_down_raster_scale_factor(0),
28       rasterize_only_visible_content(false),
29       show_picture_borders(false),
30       record_rendering_stats_(false) {}
31 
~LayerTreeDebugState()32 LayerTreeDebugState::~LayerTreeDebugState() {}
33 
SetRecordRenderingStats(bool enabled)34 void LayerTreeDebugState::SetRecordRenderingStats(bool enabled) {
35   record_rendering_stats_ = enabled;
36 }
37 
RecordRenderingStats() const38 bool LayerTreeDebugState::RecordRenderingStats() const {
39   return record_rendering_stats_ || continuous_painting;
40 }
41 
ShowHudInfo() const42 bool LayerTreeDebugState::ShowHudInfo() const {
43   return show_fps_counter || continuous_painting ||
44          ShowHudRects();
45 }
46 
ShowHudRects() const47 bool LayerTreeDebugState::ShowHudRects() const {
48   return show_paint_rects || show_property_changed_rects ||
49          show_surface_damage_rects || show_screen_space_rects ||
50          show_replica_screen_space_rects || show_occluding_rects ||
51          show_non_occluding_rects || show_touch_event_handler_rects ||
52          show_wheel_event_handler_rects || show_non_fast_scrollable_rects ||
53          show_layer_animation_bounds_rects;
54 }
55 
ShowMemoryStats() const56 bool LayerTreeDebugState::ShowMemoryStats() const {
57   return show_fps_counter || continuous_painting;
58 }
59 
Equal(const LayerTreeDebugState & a,const LayerTreeDebugState & b)60 bool LayerTreeDebugState::Equal(const LayerTreeDebugState& a,
61                                 const LayerTreeDebugState& b) {
62   return (a.show_fps_counter == b.show_fps_counter &&
63           a.show_debug_borders == b.show_debug_borders &&
64           a.continuous_painting == b.continuous_painting &&
65           a.show_paint_rects == b.show_paint_rects &&
66           a.show_property_changed_rects == b.show_property_changed_rects &&
67           a.show_surface_damage_rects == b.show_surface_damage_rects &&
68           a.show_screen_space_rects == b.show_screen_space_rects &&
69           a.show_replica_screen_space_rects ==
70           b.show_replica_screen_space_rects &&
71           a.show_occluding_rects == b.show_occluding_rects &&
72           a.show_non_occluding_rects == b.show_non_occluding_rects &&
73           a.show_touch_event_handler_rects ==
74           b.show_touch_event_handler_rects &&
75           a.show_wheel_event_handler_rects ==
76           b.show_wheel_event_handler_rects &&
77           a.show_non_fast_scrollable_rects ==
78           b.show_non_fast_scrollable_rects &&
79           a.show_layer_animation_bounds_rects ==
80           b.show_layer_animation_bounds_rects &&
81           a.slow_down_raster_scale_factor == b.slow_down_raster_scale_factor &&
82           a.rasterize_only_visible_content ==
83           b.rasterize_only_visible_content &&
84           a.show_picture_borders == b.show_picture_borders &&
85           a.record_rendering_stats_ == b.record_rendering_stats_);
86 }
87 
Unite(const LayerTreeDebugState & a,const LayerTreeDebugState & b)88 LayerTreeDebugState LayerTreeDebugState::Unite(const LayerTreeDebugState& a,
89                                                const LayerTreeDebugState& b) {
90   LayerTreeDebugState r(a);
91 
92   r.show_fps_counter |= b.show_fps_counter;
93   r.show_debug_borders |= b.show_debug_borders;
94   r.continuous_painting |= b.continuous_painting;
95 
96   r.show_paint_rects |= b.show_paint_rects;
97   r.show_property_changed_rects |= b.show_property_changed_rects;
98   r.show_surface_damage_rects |= b.show_surface_damage_rects;
99   r.show_screen_space_rects |= b.show_screen_space_rects;
100   r.show_replica_screen_space_rects |= b.show_replica_screen_space_rects;
101   r.show_occluding_rects |= b.show_occluding_rects;
102   r.show_non_occluding_rects |= b.show_non_occluding_rects;
103   r.show_touch_event_handler_rects |= b.show_touch_event_handler_rects;
104   r.show_wheel_event_handler_rects |= b.show_wheel_event_handler_rects;
105   r.show_non_fast_scrollable_rects |= b.show_non_fast_scrollable_rects;
106   r.show_layer_animation_bounds_rects |= b.show_layer_animation_bounds_rects;
107 
108   if (b.slow_down_raster_scale_factor)
109     r.slow_down_raster_scale_factor = b.slow_down_raster_scale_factor;
110   r.rasterize_only_visible_content |= b.rasterize_only_visible_content;
111   r.show_picture_borders |= b.show_picture_borders;
112 
113   r.record_rendering_stats_ |= b.record_rendering_stats_;
114 
115   return r;
116 }
117 
118 }  // namespace cc
119