• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2013 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 "ash/debug.h"
6 
7 #include "ash/shell.h"
8 #include "cc/debug/layer_tree_debug_state.h"
9 #include "ui/aura/window_tree_host.h"
10 #include "ui/compositor/compositor.h"
11 
12 namespace ash {
13 namespace debug {
14 
ToggleShowDebugBorders()15 void ToggleShowDebugBorders() {
16   aura::Window::Windows root_windows =
17       Shell::GetInstance()->GetAllRootWindows();
18   scoped_ptr<bool> value;
19   for (aura::Window::Windows::iterator it = root_windows.begin();
20        it != root_windows.end(); ++it) {
21     ui::Compositor* compositor = (*it)->GetHost()->compositor();
22     cc::LayerTreeDebugState state = compositor->GetLayerTreeDebugState();
23     if (!value.get())
24       value.reset(new bool(!state.show_debug_borders));
25     state.show_debug_borders = *value.get();
26     compositor->SetLayerTreeDebugState(state);
27   }
28 }
29 
ToggleShowFpsCounter()30 void ToggleShowFpsCounter() {
31   aura::Window::Windows root_windows =
32       Shell::GetInstance()->GetAllRootWindows();
33   scoped_ptr<bool> value;
34   for (aura::Window::Windows::iterator it = root_windows.begin();
35        it != root_windows.end(); ++it) {
36     ui::Compositor* compositor = (*it)->GetHost()->compositor();
37     cc::LayerTreeDebugState state = compositor->GetLayerTreeDebugState();
38     if (!value.get())
39       value.reset(new bool(!state.show_fps_counter));
40     state.show_fps_counter = *value.get();
41     compositor->SetLayerTreeDebugState(state);
42   }
43 }
44 
ToggleShowPaintRects()45 void ToggleShowPaintRects() {
46   aura::Window::Windows root_windows =
47       Shell::GetInstance()->GetAllRootWindows();
48   scoped_ptr<bool> value;
49   for (aura::Window::Windows::iterator it = root_windows.begin();
50        it != root_windows.end(); ++it) {
51     ui::Compositor* compositor = (*it)->GetHost()->compositor();
52     cc::LayerTreeDebugState state = compositor->GetLayerTreeDebugState();
53     if (!value.get())
54       value.reset(new bool(!state.show_paint_rects));
55     state.show_paint_rects = *value.get();
56     compositor->SetLayerTreeDebugState(state);
57   }
58 }
59 
60 }  // debug
61 }  // ash
62