summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-23 18:38:08 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-23 18:38:08 +0000
commit8b257c9762e9051c1d4e794900d1084fd81913cd (patch)
tree36a68a41347aed8661b800c524d336a921bf7972 /ash
parent65a3cd78252f3a1edae4ae595820e0cb2cd0ba9d (diff)
downloadchromium_src-8b257c9762e9051c1d4e794900d1084fd81913cd.zip
chromium_src-8b257c9762e9051c1d4e794900d1084fd81913cd.tar.gz
chromium_src-8b257c9762e9051c1d4e794900d1084fd81913cd.tar.bz2
Add debug shortcuts that toggles options to shows paint rects, debug borders and fps counters.
Cleanup: Separate desktop shortcuts which are useful only on linux desktop, and debug shortcuts. BUG=227375 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=195733 Review URL: https://chromiumcodereview.appspot.com/14050009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195854 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/DEPS1
-rw-r--r--ash/accelerators/accelerator_controller.cc16
-rw-r--r--ash/accelerators/accelerator_table.cc105
-rw-r--r--ash/accelerators/accelerator_table.h25
-rw-r--r--ash/ash.gyp2
-rw-r--r--ash/debug.cc61
-rw-r--r--ash/debug.h22
7 files changed, 174 insertions, 58 deletions
diff --git a/ash/DEPS b/ash/DEPS
index 7aa545b..29f9c96 100644
--- a/ash/DEPS
+++ b/ash/DEPS
@@ -1,4 +1,5 @@
include_rules = [
+ "+cc/debug",
"+chromeos",
"+content/public",
"+grit/ash_resources.h",
diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc
index 07b92f2..6c6b940 100644
--- a/ash/accelerators/accelerator_controller.cc
+++ b/ash/accelerators/accelerator_controller.cc
@@ -12,6 +12,7 @@
#include "ash/accelerators/accelerator_table.h"
#include "ash/ash_switches.h"
#include "ash/caps_lock_delegate.h"
+#include "ash/debug.h"
#include "ash/desktop_background/desktop_background_controller.h"
#include "ash/desktop_background/user_wallpaper_delegate.h"
#include "ash/display/display_controller.h"
@@ -374,6 +375,10 @@ void AcceleratorController::Init() {
RegisterAccelerators(kAcceleratorData, kAcceleratorDataLength);
+#if !defined(NDEBUG)
+ RegisterAccelerators(kDesktopAcceleratorData, kDesktopAcceleratorDataLength);
+#endif
+
if (DebugShortcutsEnabled())
RegisterAccelerators(kDebugAcceleratorData, kDebugAcceleratorDataLength);
@@ -814,9 +819,18 @@ bool AcceleratorController::PerformAction(int action,
return HandleToggleDesktopBackgroundMode();
case TOGGLE_ROOT_WINDOW_FULL_SCREEN:
return HandleToggleRootWindowFullScreen();
- case DISPLAY_TOGGLE_SCALE:
+ case DEBUG_TOGGLE_DEVICE_SCALE_FACTOR:
internal::DisplayManager::ToggleDisplayScaleFactor();
return true;
+ case DEBUG_TOGGLE_SHOW_DEBUG_BORDERS:
+ ash::debug::ToggleShowDebugBorders();
+ return true;
+ case DEBUG_TOGGLE_SHOW_FPS_COUNTER:
+ ash::debug::ToggleShowFpsCounter();
+ return true;
+ case DEBUG_TOGGLE_SHOW_PAINT_RECTS:
+ ash::debug::ToggleShowPaintRects();
+ return true;
case MAGNIFY_SCREEN_ZOOM_IN:
return HandleMagnifyScreen(1);
case MAGNIFY_SCREEN_ZOOM_OUT:
diff --git a/ash/accelerators/accelerator_table.cc b/ash/accelerators/accelerator_table.cc
index 9daa8b1..06a75d0 100644
--- a/ash/accelerators/accelerator_table.cc
+++ b/ash/accelerators/accelerator_table.cc
@@ -64,23 +64,6 @@ const AcceleratorData kAcceleratorData[] = {
{ false, ui::VKEY_F13, ui::EF_NONE, LOCK_RELEASED },
{ true, ui::VKEY_POWER, ui::EF_NONE, POWER_PRESSED },
{ false, ui::VKEY_POWER, ui::EF_NONE, POWER_RELEASED },
-#if !defined(NDEBUG)
- // Extra shortcut for debug build to control magnifier on linux desktop.
- { true, ui::VKEY_BRIGHTNESS_DOWN, ui::EF_CONTROL_DOWN,
- MAGNIFY_SCREEN_ZOOM_OUT},
- { true, ui::VKEY_BRIGHTNESS_UP, ui::EF_CONTROL_DOWN, MAGNIFY_SCREEN_ZOOM_IN},
- // Extra shortcut for debug build to activate lock screen on linux desktop.
- { true, ui::VKEY_L, ui::EF_ALT_DOWN, LOCK_SCREEN },
- // Extra shortcut for display swaping as alt-f4 is taken on linux desktop.
- { true, ui::VKEY_F4, ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN,
- SWAP_PRIMARY_DISPLAY },
- // Extra shortcut to lock the screen on linux desktop.
- { true, ui::VKEY_POWER, ui::EF_SHIFT_DOWN, LOCK_PRESSED },
- { false, ui::VKEY_POWER, ui::EF_SHIFT_DOWN, LOCK_RELEASED },
- // Extra shortcut to rotate/scale up/down the screen on linux desktop.
- { true, ui::VKEY_R,
- ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN, ROTATE_SCREEN },
-#endif // !defined(NDEBUG)
{ true, ui::VKEY_O, ui::EF_CONTROL_DOWN, OPEN_FILE_DIALOG },
{ true, ui::VKEY_M, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN,
OPEN_FILE_MANAGER },
@@ -181,25 +164,53 @@ const AcceleratorData kAcceleratorData[] = {
const size_t kAcceleratorDataLength = arraysize(kAcceleratorData);
-const AcceleratorData kDebugAcceleratorData[] = {
- { true, ui::VKEY_B, ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN,
- TOGGLE_DESKTOP_BACKGROUND_MODE },
- { true, ui::VKEY_F11, ui::EF_CONTROL_DOWN, TOGGLE_ROOT_WINDOW_FULL_SCREEN },
- { true, ui::VKEY_W, ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN, TOGGLE_WIFI },
+#if !defined(NDEBUG)
+const AcceleratorData kDesktopAcceleratorData[] = {
+#if defined(OS_CHROMEOS)
+ // Extra shortcut for debug build to control magnifier on linux desktop.
+ { true, ui::VKEY_BRIGHTNESS_DOWN, ui::EF_CONTROL_DOWN,
+ MAGNIFY_SCREEN_ZOOM_OUT},
+ { true, ui::VKEY_BRIGHTNESS_UP, ui::EF_CONTROL_DOWN, MAGNIFY_SCREEN_ZOOM_IN},
+ // Extra shortcuts to lock the screen on linux desktop.
+ { true, ui::VKEY_L, ui::EF_ALT_DOWN, LOCK_SCREEN },
+ { true, ui::VKEY_POWER, ui::EF_SHIFT_DOWN, LOCK_PRESSED },
+ { false, ui::VKEY_POWER, ui::EF_SHIFT_DOWN, LOCK_RELEASED },
+#endif
+ // Extra shortcut for display swaping as alt-f4 is taken on linux desktop.
+ { true, ui::VKEY_S, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN,
+ SWAP_PRIMARY_DISPLAY },
+ // Extra shortcut to rotate/scale up/down the screen on linux desktop.
+ { true, ui::VKEY_R,
+ ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN, ROTATE_SCREEN },
// For testing on systems where Alt-Tab is already mapped.
{ true, ui::VKEY_W, ui::EF_ALT_DOWN, CYCLE_FORWARD_MRU },
+
+ { true, ui::VKEY_F11, ui::EF_CONTROL_DOWN, TOGGLE_ROOT_WINDOW_FULL_SCREEN },
+ { true, ui::VKEY_W, ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN, TOGGLE_WIFI },
{ true, ui::VKEY_W, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN,
CYCLE_BACKWARD_MRU },
- { true, ui::VKEY_HOME, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN,
- DISPLAY_TOGGLE_SCALE },
-#if !defined(NDEBUG)
+ { true, ui::VKEY_B, ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN,
+ TOGGLE_DESKTOP_BACKGROUND_MODE },
+};
+
+const size_t kDesktopAcceleratorDataLength = arraysize(kDesktopAcceleratorData);
+#endif
+
+const AcceleratorData kDebugAcceleratorData[] = {
{ true, ui::VKEY_L, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN,
PRINT_LAYER_HIERARCHY },
{ true, ui::VKEY_V, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN,
PRINT_VIEW_HIERARCHY },
{ true, ui::VKEY_W, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN,
PRINT_WINDOW_HIERARCHY },
-#endif
+ { true, ui::VKEY_S, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN,
+ DEBUG_TOGGLE_DEVICE_SCALE_FACTOR },
+ { true, ui::VKEY_B, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN,
+ DEBUG_TOGGLE_SHOW_DEBUG_BORDERS },
+ { true, ui::VKEY_F, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN,
+ DEBUG_TOGGLE_SHOW_FPS_COUNTER },
+ { true, ui::VKEY_P, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN,
+ DEBUG_TOGGLE_SHOW_PAINT_RECTS },
};
const size_t kDebugAcceleratorDataLength = arraysize(kDebugAcceleratorData);
@@ -219,10 +230,6 @@ const size_t kReservedActionsLength = arraysize(kReservedActions);
const AcceleratorAction kActionsAllowedAtLoginOrLockScreen[] = {
BRIGHTNESS_DOWN,
BRIGHTNESS_UP,
-#if defined(OS_CHROMEOS)
- CYCLE_DISPLAY_MODE,
- DISABLE_GPU_WATCHDOG,
-#endif // defined(OS_CHROMEOS)
DISABLE_CAPS_LOCK,
KEYBOARD_BRIGHTNESS_DOWN,
KEYBOARD_BRIGHTNESS_UP,
@@ -230,10 +237,14 @@ const AcceleratorAction kActionsAllowedAtLoginOrLockScreen[] = {
MAGNIFY_SCREEN_ZOOM_OUT, // Control+F6
NEXT_IME,
PREVIOUS_IME,
+ PRINT_LAYER_HIERARCHY,
PRINT_UI_HIERARCHIES,
+ PRINT_VIEW_HIERARCHY,
+ PRINT_WINDOW_HIERARCHY,
+ ROTATE_WINDOW,
SWITCH_IME, // Switch to another IME depending on the accelerator.
- TAKE_SCREENSHOT,
TAKE_PARTIAL_SCREENSHOT,
+ TAKE_SCREENSHOT,
TOGGLE_CAPS_LOCK,
TOGGLE_SPOKEN_FEEDBACK,
TOGGLE_WIFI,
@@ -241,16 +252,14 @@ const AcceleratorAction kActionsAllowedAtLoginOrLockScreen[] = {
VOLUME_DOWN,
VOLUME_MUTE,
VOLUME_UP,
- ROTATE_WINDOW,
-#if !defined(NDEBUG)
- PRINT_LAYER_HIERARCHY,
- PRINT_VIEW_HIERARCHY,
- PRINT_WINDOW_HIERARCHY,
+#if defined(OS_CHROMEOS)
+ CYCLE_DISPLAY_MODE,
+ DISABLE_GPU_WATCHDOG,
#endif
#if defined(OS_CHROMEOS) && !defined(NDEBUG)
POWER_PRESSED,
POWER_RELEASED,
-#endif
+#endif // defined(OS_CHROMEOS)
};
const size_t kActionsAllowedAtLoginOrLockScreenLength =
@@ -284,8 +293,8 @@ const AcceleratorAction kActionsAllowedAtModalWindow[] = {
SHOW_KEYBOARD_OVERLAY,
SWAP_PRIMARY_DISPLAY,
SWITCH_IME,
- TAKE_SCREENSHOT,
TAKE_PARTIAL_SCREENSHOT,
+ TAKE_SCREENSHOT,
TOGGLE_CAPS_LOCK,
TOGGLE_SPOKEN_FEEDBACK,
TOGGLE_WIFI,
@@ -310,9 +319,9 @@ const AcceleratorAction kNonrepeatableActions[] = {
PRINT_UI_HIERARCHIES, // Don't fill the logs if the key is held down.
ROTATE_SCREEN,
ROTATE_WINDOW,
- SCALE_UI_UP,
SCALE_UI_DOWN,
SCALE_UI_RESET,
+ SCALE_UI_UP,
TOGGLE_MAXIMIZED,
WINDOW_MINIMIZE,
};
@@ -323,10 +332,6 @@ const size_t kNonrepeatableActionsLength =
const AcceleratorAction kActionsAllowedInAppMode[] = {
BRIGHTNESS_DOWN,
BRIGHTNESS_UP,
-#if defined(OS_CHROMEOS)
- CYCLE_DISPLAY_MODE,
- DISABLE_GPU_WATCHDOG,
-#endif // defined(OS_CHROMEOS)
DISABLE_CAPS_LOCK,
KEYBOARD_BRIGHTNESS_DOWN,
KEYBOARD_BRIGHTNESS_UP,
@@ -339,11 +344,14 @@ const AcceleratorAction kActionsAllowedInAppMode[] = {
POWER_PRESSED,
POWER_RELEASED,
PREVIOUS_IME,
+ PRINT_LAYER_HIERARCHY,
PRINT_UI_HIERARCHIES,
+ PRINT_VIEW_HIERARCHY,
+ PRINT_WINDOW_HIERARCHY,
ROTATE_SCREEN,
- SCALE_UI_UP,
SCALE_UI_DOWN,
SCALE_UI_RESET,
+ SCALE_UI_UP,
SWAP_PRIMARY_DISPLAY,
SWITCH_IME, // Switch to another IME depending on the accelerator.
TOGGLE_CAPS_LOCK,
@@ -353,11 +361,10 @@ const AcceleratorAction kActionsAllowedInAppMode[] = {
VOLUME_DOWN,
VOLUME_MUTE,
VOLUME_UP,
-#if !defined(NDEBUG)
- PRINT_LAYER_HIERARCHY,
- PRINT_VIEW_HIERARCHY,
- PRINT_WINDOW_HIERARCHY,
-#endif
+#if defined(OS_CHROMEOS)
+ CYCLE_DISPLAY_MODE,
+ DISABLE_GPU_WATCHDOG,
+#endif // defined(OS_CHROMEOS)
};
const size_t kActionsAllowedInAppModeLength =
diff --git a/ash/accelerators/accelerator_table.h b/ash/accelerators/accelerator_table.h
index b28e4e9..0666861 100644
--- a/ash/accelerators/accelerator_table.h
+++ b/ash/accelerators/accelerator_table.h
@@ -21,8 +21,11 @@ enum AcceleratorAction {
CYCLE_BACKWARD_MRU,
CYCLE_FORWARD_LINEAR,
CYCLE_FORWARD_MRU,
+ DEBUG_TOGGLE_DEVICE_SCALE_FACTOR,
+ DEBUG_TOGGLE_SHOW_DEBUG_BORDERS,
+ DEBUG_TOGGLE_SHOW_FPS_COUNTER,
+ DEBUG_TOGGLE_SHOW_PAINT_RECTS,
DISABLE_CAPS_LOCK,
- DISPLAY_TOGGLE_SCALE,
EXIT,
FOCUS_LAUNCHER,
FOCUS_NEXT_PANE,
@@ -41,10 +44,13 @@ enum AcceleratorAction {
NEW_WINDOW,
NEXT_IME,
OPEN_FEEDBACK_PAGE,
- PREVIOUS_IME,
POWER_PRESSED,
POWER_RELEASED,
+ PREVIOUS_IME,
+ PRINT_LAYER_HIERARCHY,
PRINT_UI_HIERARCHIES,
+ PRINT_VIEW_HIERARCHY,
+ PRINT_WINDOW_HIERARCHY,
RESTORE_TAB,
ROTATE_SCREEN,
ROTATE_WINDOW,
@@ -88,16 +94,11 @@ enum AcceleratorAction {
WINDOW_SNAP_RIGHT,
#if defined(OS_CHROMEOS)
CYCLE_DISPLAY_MODE,
+ DISABLE_GPU_WATCHDOG,
LOCK_SCREEN,
OPEN_CROSH,
OPEN_FILE_DIALOG, // Open 'Open file' dialog.
OPEN_FILE_MANAGER,
- DISABLE_GPU_WATCHDOG,
-#endif
-#if !defined(NDEBUG)
- PRINT_LAYER_HIERARCHY,
- PRINT_VIEW_HIERARCHY,
- PRINT_WINDOW_HIERARCHY,
#endif
};
@@ -114,6 +115,14 @@ ASH_EXPORT extern const AcceleratorData kAcceleratorData[];
// The number of elements in kAcceleratorData.
ASH_EXPORT extern const size_t kAcceleratorDataLength;
+#if !defined(NDEBUG)
+// Accelerators useful when running on desktop. Debug build only.
+ASH_EXPORT extern const AcceleratorData kDesktopAcceleratorData[];
+
+// The number of elements in kDesktopAcceleratorData.
+ASH_EXPORT extern const size_t kDesktopAcceleratorDataLength;
+#endif
+
// Debug accelerators enabled only when "Debugging keyboard shortcuts" flag
// (--ash-debug-shortcuts) is enabled.
ASH_EXPORT extern const AcceleratorData kDebugAcceleratorData[];
diff --git a/ash/ash.gyp b/ash/ash.gyp
index d53debc..25b6116 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -70,6 +70,8 @@
'caps_lock_delegate.h',
'caps_lock_delegate_stub.cc',
'caps_lock_delegate_stub.h',
+ 'debug.cc',
+ 'debug.h',
'desktop_background/desktop_background_controller.cc',
'desktop_background/desktop_background_controller.h',
'desktop_background/desktop_background_controller_observer.h',
diff --git a/ash/debug.cc b/ash/debug.cc
new file mode 100644
index 0000000..060627c
--- /dev/null
+++ b/ash/debug.cc
@@ -0,0 +1,61 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/debug.h"
+
+#include "ash/shell.h"
+#include "cc/debug/layer_tree_debug_state.h"
+#include "ui/aura/root_window.h"
+#include "ui/compositor/compositor.h"
+
+namespace ash {
+namespace debug {
+
+void ToggleShowDebugBorders() {
+ Shell::RootWindowList root_windows =
+ Shell::GetInstance()->GetAllRootWindows();
+ scoped_ptr<bool> value;
+ for (Shell::RootWindowList::iterator it = root_windows.begin();
+ it != root_windows.end(); ++it) {
+ ui::Compositor* compositor = (*it)->compositor();
+ cc::LayerTreeDebugState state = compositor->GetLayerTreeDebugState();
+ if (!value.get())
+ value.reset(new bool(!state.show_debug_borders));
+ state.show_debug_borders = *value.get();
+ compositor->SetLayerTreeDebugState(state);
+ }
+}
+
+void ToggleShowFpsCounter() {
+ Shell::RootWindowList root_windows =
+ Shell::GetInstance()->GetAllRootWindows();
+ scoped_ptr<bool> value;
+ for (Shell::RootWindowList::iterator it = root_windows.begin();
+ it != root_windows.end(); ++it) {
+ ui::Compositor* compositor = (*it)->compositor();
+ cc::LayerTreeDebugState state = compositor->GetLayerTreeDebugState();
+ if (!value.get())
+ value.reset(new bool(!state.show_fps_counter));
+ state.show_fps_counter = *value.get();
+ compositor->SetLayerTreeDebugState(state);
+ }
+}
+
+void ToggleShowPaintRects() {
+ Shell::RootWindowList root_windows =
+ Shell::GetInstance()->GetAllRootWindows();
+ scoped_ptr<bool> value;
+ for (Shell::RootWindowList::iterator it = root_windows.begin();
+ it != root_windows.end(); ++it) {
+ ui::Compositor* compositor = (*it)->compositor();
+ cc::LayerTreeDebugState state = compositor->GetLayerTreeDebugState();
+ if (!value.get())
+ value.reset(new bool(!state.show_paint_rects));
+ state.show_paint_rects = *value.get();
+ compositor->SetLayerTreeDebugState(state);
+ }
+}
+
+} // debug
+} // ash
diff --git a/ash/debug.h b/ash/debug.h
new file mode 100644
index 0000000..1b2561e
--- /dev/null
+++ b/ash/debug.h
@@ -0,0 +1,22 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ASH_DEBUG_H_
+#define ASH_DEBUG_H_
+
+#include "ash/ash_export.h"
+
+namespace ash {
+namespace debug {
+
+// Toggles debugging features controlled by
+// cc::LayerTreeDebugState.
+ASH_EXPORT void ToggleShowPaintRects();
+ASH_EXPORT void ToggleShowDebugBorders();
+ASH_EXPORT void ToggleShowFpsCounter();
+
+} // debug
+} // ash
+
+#endif // ASH_DEBUG_H_