OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ash/common/accelerators/debug_commands.h" | 5 #include "ash/common/accelerators/debug_commands.h" |
6 | 6 |
7 #include "ash/common/accelerators/accelerator_commands.h" | 7 #include "ash/common/accelerators/accelerator_commands.h" |
8 #include "ash/common/ash_switches.h" | 8 #include "ash/common/ash_switches.h" |
9 #include "ash/common/shell_delegate.h" | 9 #include "ash/common/shell_delegate.h" |
10 #include "ash/common/system/toast/toast_data.h" | 10 #include "ash/common/system/toast/toast_data.h" |
11 #include "ash/common/system/toast/toast_manager.h" | 11 #include "ash/common/system/toast/toast_manager.h" |
| 12 #include "ash/common/wallpaper/wallpaper_controller.h" |
| 13 #include "ash/common/wallpaper/wallpaper_delegate.h" |
12 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 14 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
13 #include "ash/common/wm_root_window_controller.h" | 15 #include "ash/common/wm_root_window_controller.h" |
14 #include "ash/common/wm_shell.h" | 16 #include "ash/common/wm_shell.h" |
15 #include "ash/common/wm_window.h" | 17 #include "ash/common/wm_window.h" |
16 #include "base/command_line.h" | 18 #include "base/command_line.h" |
17 #include "base/metrics/user_metrics.h" | 19 #include "base/metrics/user_metrics.h" |
18 #include "base/metrics/user_metrics_action.h" | 20 #include "base/metrics/user_metrics_action.h" |
19 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
20 #include "ui/compositor/debug_utils.h" | 22 #include "ui/compositor/debug_utils.h" |
| 23 #include "ui/gfx/canvas.h" |
| 24 #include "ui/gfx/image/image_skia.h" |
21 #include "ui/views/debug_utils.h" | 25 #include "ui/views/debug_utils.h" |
22 #include "ui/views/widget/widget.h" | 26 #include "ui/views/widget/widget.h" |
23 | 27 |
24 namespace ash { | 28 namespace ash { |
25 namespace debug { | 29 namespace debug { |
26 namespace { | 30 namespace { |
27 | 31 |
28 void HandlePrintLayerHierarchy() { | 32 void HandlePrintLayerHierarchy() { |
29 for (WmWindow* root : WmShell::Get()->GetAllRootWindows()) { | 33 for (WmWindow* root : WmShell::Get()->GetAllRootWindows()) { |
30 ui::Layer* layer = root->GetLayer(); | 34 ui::Layer* layer = root->GetLayer(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 WmWindow::Windows roots = WmShell::Get()->GetAllRootWindows(); | 71 WmWindow::Windows roots = WmShell::Get()->GetAllRootWindows(); |
68 for (size_t i = 0; i < roots.size(); ++i) { | 72 for (size_t i = 0; i < roots.size(); ++i) { |
69 std::ostringstream out; | 73 std::ostringstream out; |
70 out << "RootWindow " << i << ":\n"; | 74 out << "RootWindow " << i << ":\n"; |
71 PrintWindowHierarchy(active_window, roots[i], 0, &out); | 75 PrintWindowHierarchy(active_window, roots[i], 0, &out); |
72 // Error so logs can be collected from end-users. | 76 // Error so logs can be collected from end-users. |
73 LOG(ERROR) << out.str(); | 77 LOG(ERROR) << out.str(); |
74 } | 78 } |
75 } | 79 } |
76 | 80 |
| 81 gfx::ImageSkia CreateWallpaperImage(SkColor fill, SkColor rect) { |
| 82 // TODO(oshima): Consider adding a command line option to control wallpaper |
| 83 // images for testing. The size is randomly picked. |
| 84 gfx::Size image_size(1366, 768); |
| 85 gfx::Canvas canvas(image_size, 1.0f, true); |
| 86 canvas.DrawColor(fill); |
| 87 SkPaint paint; |
| 88 paint.setColor(rect); |
| 89 paint.setStrokeWidth(10); |
| 90 paint.setStyle(SkPaint::kStroke_Style); |
| 91 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); |
| 92 canvas.DrawRoundRect(gfx::Rect(image_size), 100, paint); |
| 93 return gfx::ImageSkia(canvas.ExtractImageRep()); |
| 94 } |
| 95 |
| 96 void HandleToggleWallpaperMode() { |
| 97 static int index = 0; |
| 98 WallpaperController* wallpaper_controller = |
| 99 WmShell::Get()->wallpaper_controller(); |
| 100 switch (++index % 4) { |
| 101 case 0: |
| 102 ash::WmShell::Get()->wallpaper_delegate()->InitializeWallpaper(); |
| 103 break; |
| 104 case 1: |
| 105 wallpaper_controller->SetWallpaperImage( |
| 106 CreateWallpaperImage(SK_ColorRED, SK_ColorBLUE), |
| 107 wallpaper::WALLPAPER_LAYOUT_STRETCH); |
| 108 break; |
| 109 case 2: |
| 110 wallpaper_controller->SetWallpaperImage( |
| 111 CreateWallpaperImage(SK_ColorBLUE, SK_ColorGREEN), |
| 112 wallpaper::WALLPAPER_LAYOUT_CENTER); |
| 113 break; |
| 114 case 3: |
| 115 wallpaper_controller->SetWallpaperImage( |
| 116 CreateWallpaperImage(SK_ColorGREEN, SK_ColorRED), |
| 117 wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED); |
| 118 break; |
| 119 } |
| 120 } |
| 121 |
77 #if defined(OS_CHROMEOS) | 122 #if defined(OS_CHROMEOS) |
78 | 123 |
79 void HandleToggleTouchpad() { | 124 void HandleToggleTouchpad() { |
80 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Touchpad")); | 125 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Touchpad")); |
81 ash::WmShell::Get()->delegate()->ToggleTouchpad(); | 126 ash::WmShell::Get()->delegate()->ToggleTouchpad(); |
82 } | 127 } |
83 | 128 |
84 void HandleToggleTouchscreen() { | 129 void HandleToggleTouchscreen() { |
85 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Touchscreen")); | 130 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Touchscreen")); |
86 ash::WmShell::Get()->delegate()->ToggleTouchscreen(); | 131 ash::WmShell::Get()->delegate()->ToggleTouchscreen(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 case DEBUG_TOGGLE_TOUCH_PAD: | 170 case DEBUG_TOGGLE_TOUCH_PAD: |
126 HandleToggleTouchpad(); | 171 HandleToggleTouchpad(); |
127 break; | 172 break; |
128 case DEBUG_TOGGLE_TOUCH_SCREEN: | 173 case DEBUG_TOGGLE_TOUCH_SCREEN: |
129 HandleToggleTouchscreen(); | 174 HandleToggleTouchscreen(); |
130 break; | 175 break; |
131 case DEBUG_TOGGLE_TOUCH_VIEW: | 176 case DEBUG_TOGGLE_TOUCH_VIEW: |
132 HandleToggleToggleTouchView(); | 177 HandleToggleToggleTouchView(); |
133 break; | 178 break; |
134 #endif | 179 #endif |
| 180 case DEBUG_TOGGLE_WALLPAPER_MODE: |
| 181 HandleToggleWallpaperMode(); |
| 182 break; |
135 case DEBUG_PRINT_LAYER_HIERARCHY: | 183 case DEBUG_PRINT_LAYER_HIERARCHY: |
136 HandlePrintLayerHierarchy(); | 184 HandlePrintLayerHierarchy(); |
137 break; | 185 break; |
138 case DEBUG_PRINT_VIEW_HIERARCHY: | 186 case DEBUG_PRINT_VIEW_HIERARCHY: |
139 HandlePrintViewHierarchy(); | 187 HandlePrintViewHierarchy(); |
140 break; | 188 break; |
141 case DEBUG_PRINT_WINDOW_HIERARCHY: | 189 case DEBUG_PRINT_WINDOW_HIERARCHY: |
142 HandlePrintWindowHierarchy(); | 190 HandlePrintWindowHierarchy(); |
143 break; | 191 break; |
144 default: | 192 default: |
145 break; | 193 break; |
146 } | 194 } |
147 } | 195 } |
148 | 196 |
149 } // namespace debug | 197 } // namespace debug |
150 } // namespace ash | 198 } // namespace ash |
OLD | NEW |