Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2351)

Unified Diff: ash/common/accelerators/debug_commands.cc

Issue 2318223003: mash: Migrate wallpaper controllers to ash/common. (Closed)
Patch Set: Fix nit. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/common/accelerators/accelerator_controller.cc ('k') | ash/common/wallpaper/DEPS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/accelerators/debug_commands.cc
diff --git a/ash/common/accelerators/debug_commands.cc b/ash/common/accelerators/debug_commands.cc
index e9872e567200883999fa5349d118e79c88ff5215..c7746650f398ab9c913be9051bb96afc2d47fa9d 100644
--- a/ash/common/accelerators/debug_commands.cc
+++ b/ash/common/accelerators/debug_commands.cc
@@ -9,6 +9,8 @@
#include "ash/common/shell_delegate.h"
#include "ash/common/system/toast/toast_data.h"
#include "ash/common/system/toast/toast_manager.h"
+#include "ash/common/wallpaper/wallpaper_controller.h"
+#include "ash/common/wallpaper/wallpaper_delegate.h"
#include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
#include "ash/common/wm_root_window_controller.h"
#include "ash/common/wm_shell.h"
@@ -18,6 +20,8 @@
#include "base/metrics/user_metrics_action.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/compositor/debug_utils.h"
+#include "ui/gfx/canvas.h"
+#include "ui/gfx/image/image_skia.h"
#include "ui/views/debug_utils.h"
#include "ui/views/widget/widget.h"
@@ -74,6 +78,47 @@ void HandlePrintWindowHierarchy() {
}
}
+gfx::ImageSkia CreateWallpaperImage(SkColor fill, SkColor rect) {
+ // TODO(oshima): Consider adding a command line option to control wallpaper
+ // images for testing. The size is randomly picked.
+ gfx::Size image_size(1366, 768);
+ gfx::Canvas canvas(image_size, 1.0f, true);
+ canvas.DrawColor(fill);
+ SkPaint paint;
+ paint.setColor(rect);
+ paint.setStrokeWidth(10);
+ paint.setStyle(SkPaint::kStroke_Style);
+ paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
+ canvas.DrawRoundRect(gfx::Rect(image_size), 100, paint);
+ return gfx::ImageSkia(canvas.ExtractImageRep());
+}
+
+void HandleToggleWallpaperMode() {
+ static int index = 0;
+ WallpaperController* wallpaper_controller =
+ WmShell::Get()->wallpaper_controller();
+ switch (++index % 4) {
+ case 0:
+ ash::WmShell::Get()->wallpaper_delegate()->InitializeWallpaper();
+ break;
+ case 1:
+ wallpaper_controller->SetWallpaperImage(
+ CreateWallpaperImage(SK_ColorRED, SK_ColorBLUE),
+ wallpaper::WALLPAPER_LAYOUT_STRETCH);
+ break;
+ case 2:
+ wallpaper_controller->SetWallpaperImage(
+ CreateWallpaperImage(SK_ColorBLUE, SK_ColorGREEN),
+ wallpaper::WALLPAPER_LAYOUT_CENTER);
+ break;
+ case 3:
+ wallpaper_controller->SetWallpaperImage(
+ CreateWallpaperImage(SK_ColorGREEN, SK_ColorRED),
+ wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED);
+ break;
+ }
+}
+
#if defined(OS_CHROMEOS)
void HandleToggleTouchpad() {
@@ -132,6 +177,9 @@ void PerformDebugActionIfEnabled(AcceleratorAction action) {
HandleToggleToggleTouchView();
break;
#endif
+ case DEBUG_TOGGLE_WALLPAPER_MODE:
+ HandleToggleWallpaperMode();
+ break;
case DEBUG_PRINT_LAYER_HIERARCHY:
HandlePrintLayerHierarchy();
break;
« no previous file with comments | « ash/common/accelerators/accelerator_controller.cc ('k') | ash/common/wallpaper/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698