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.
5 #include "cc/debug/layer_tree_debug_state.h"
7 #include "base/logging.h"
11 // IMPORTANT: new fields must be added to Equal() and Unite()
12 LayerTreeDebugState::LayerTreeDebugState()
13 : show_fps_counter(false),
14 show_platform_layer_tree(false),
15 show_debug_borders(false),
16 continuous_painting(false),
17 show_paint_rects(false),
18 show_property_changed_rects(false),
19 show_surface_damage_rects(false),
20 show_screen_space_rects(false),
21 show_replica_screen_space_rects(false),
22 show_occluding_rects(false),
23 show_non_occluding_rects(false),
24 slow_down_raster_scale_factor(0),
25 rasterize_only_visible_content(false),
26 show_picture_borders(false),
27 record_rendering_stats_(false) {}
29 LayerTreeDebugState::~LayerTreeDebugState() {}
31 void LayerTreeDebugState::SetRecordRenderingStats(bool enabled
) {
32 record_rendering_stats_
= enabled
;
35 bool LayerTreeDebugState::RecordRenderingStats() const {
36 return record_rendering_stats_
|| continuous_painting
;
39 bool LayerTreeDebugState::ShowHudInfo() const {
40 return show_fps_counter
|| show_platform_layer_tree
|| continuous_painting
||
44 bool LayerTreeDebugState::ShowHudRects() const {
45 return show_paint_rects
|| show_property_changed_rects
||
46 show_surface_damage_rects
|| show_screen_space_rects
||
47 show_replica_screen_space_rects
|| show_occluding_rects
||
48 show_non_occluding_rects
;
51 bool LayerTreeDebugState::ShowMemoryStats() const {
52 return show_fps_counter
|| continuous_painting
;
55 bool LayerTreeDebugState::Equal(const LayerTreeDebugState
& a
,
56 const LayerTreeDebugState
& b
) {
57 return (a
.show_fps_counter
== b
.show_fps_counter
&&
58 a
.show_platform_layer_tree
== b
.show_platform_layer_tree
&&
59 a
.show_debug_borders
== b
.show_debug_borders
&&
60 a
.continuous_painting
== b
.continuous_painting
&&
61 a
.show_paint_rects
== b
.show_paint_rects
&&
62 a
.show_property_changed_rects
== b
.show_property_changed_rects
&&
63 a
.show_surface_damage_rects
== b
.show_surface_damage_rects
&&
64 a
.show_screen_space_rects
== b
.show_screen_space_rects
&&
65 a
.show_replica_screen_space_rects
==
66 b
.show_replica_screen_space_rects
&&
67 a
.show_occluding_rects
== b
.show_occluding_rects
&&
68 a
.show_non_occluding_rects
== b
.show_non_occluding_rects
&&
69 a
.slow_down_raster_scale_factor
== b
.slow_down_raster_scale_factor
&&
70 a
.rasterize_only_visible_content
==
71 b
.rasterize_only_visible_content
&&
72 a
.show_picture_borders
== b
.show_picture_borders
&&
73 a
.record_rendering_stats_
== b
.record_rendering_stats_
);
76 LayerTreeDebugState
LayerTreeDebugState::Unite(const LayerTreeDebugState
& a
,
77 const LayerTreeDebugState
& b
) {
78 LayerTreeDebugState
r(a
);
80 r
.show_fps_counter
|= b
.show_fps_counter
;
81 r
.show_platform_layer_tree
|= b
.show_platform_layer_tree
;
82 r
.show_debug_borders
|= b
.show_debug_borders
;
83 r
.continuous_painting
|= b
.continuous_painting
;
85 r
.show_paint_rects
|= b
.show_paint_rects
;
86 r
.show_property_changed_rects
|= b
.show_property_changed_rects
;
87 r
.show_surface_damage_rects
|= b
.show_surface_damage_rects
;
88 r
.show_screen_space_rects
|= b
.show_screen_space_rects
;
89 r
.show_replica_screen_space_rects
|= b
.show_replica_screen_space_rects
;
90 r
.show_occluding_rects
|= b
.show_occluding_rects
;
91 r
.show_non_occluding_rects
|= b
.show_non_occluding_rects
;
93 if (b
.slow_down_raster_scale_factor
)
94 r
.slow_down_raster_scale_factor
= b
.slow_down_raster_scale_factor
;
95 r
.rasterize_only_visible_content
|= b
.rasterize_only_visible_content
;
96 r
.show_picture_borders
|= b
.show_picture_borders
;
98 r
.record_rendering_stats_
|= b
.record_rendering_stats_
;