| 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" | 12 #include "ash/common/wallpaper/wallpaper_controller.h" |
| 13 #include "ash/common/wallpaper/wallpaper_delegate.h" | 13 #include "ash/common/wallpaper/wallpaper_delegate.h" |
| 14 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 14 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| 15 #include "ash/common/wm_shell.h" | 15 #include "ash/common/wm_shell.h" |
| 16 #include "ash/common/wm_window.h" | 16 #include "ash/common/wm_window.h" |
| 17 #include "ash/root_window_controller.h" | 17 #include "ash/root_window_controller.h" |
| 18 #include "ash/shell.h" | 18 #include "ash/shell.h" |
| 19 #include "ash/wm/window_properties.h" | 19 #include "ash/wm/window_properties.h" |
| 20 #include "base/command_line.h" | 20 #include "base/command_line.h" |
| 21 #include "base/metrics/user_metrics.h" | 21 #include "base/metrics/user_metrics.h" |
| 22 #include "base/metrics/user_metrics_action.h" | 22 #include "base/metrics/user_metrics_action.h" |
| 23 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
| 24 #include "ui/compositor/debug_utils.h" | 24 #include "ui/compositor/debug_utils.h" |
| 25 #include "ui/compositor/layer.h" | 25 #include "ui/compositor/layer.h" |
| 26 #include "ui/gfx/canvas.h" | 26 #include "ui/gfx/canvas.h" |
| 27 #include "ui/gfx/image/image_skia.h" | 27 #include "ui/gfx/image/image_skia.h" |
| 28 #include "ui/gfx/image/image_skia_rep.h" |
| 28 #include "ui/views/debug_utils.h" | 29 #include "ui/views/debug_utils.h" |
| 29 #include "ui/views/widget/widget.h" | 30 #include "ui/views/widget/widget.h" |
| 30 | 31 |
| 31 namespace ash { | 32 namespace ash { |
| 32 namespace debug { | 33 namespace debug { |
| 33 namespace { | 34 namespace { |
| 34 | 35 |
| 35 void HandlePrintLayerHierarchy() { | 36 void HandlePrintLayerHierarchy() { |
| 36 for (WmWindow* root : WmShell::Get()->GetAllRootWindows()) { | 37 for (WmWindow* root : WmShell::Get()->GetAllRootWindows()) { |
| 37 ui::Layer* layer = root->GetLayer(); | 38 ui::Layer* layer = root->GetLayer(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 PrintWindowHierarchy(active_window, roots[i], 0, &out); | 84 PrintWindowHierarchy(active_window, roots[i], 0, &out); |
| 84 // Error so logs can be collected from end-users. | 85 // Error so logs can be collected from end-users. |
| 85 LOG(ERROR) << out.str(); | 86 LOG(ERROR) << out.str(); |
| 86 } | 87 } |
| 87 } | 88 } |
| 88 | 89 |
| 89 gfx::ImageSkia CreateWallpaperImage(SkColor fill, SkColor rect) { | 90 gfx::ImageSkia CreateWallpaperImage(SkColor fill, SkColor rect) { |
| 90 // TODO(oshima): Consider adding a command line option to control wallpaper | 91 // TODO(oshima): Consider adding a command line option to control wallpaper |
| 91 // images for testing. The size is randomly picked. | 92 // images for testing. The size is randomly picked. |
| 92 gfx::Size image_size(1366, 768); | 93 gfx::Size image_size(1366, 768); |
| 93 gfx::Canvas canvas(image_size, 1.0f, true); | 94 SkBitmap bitmap; |
| 94 canvas.DrawColor(fill); | 95 bitmap.allocN32Pixels(image_size.width(), image_size.height(), true); |
| 95 cc::PaintFlags flags; | 96 sk_sp<SkSurface> surface = SkSurface::MakeRasterDirect( |
| 96 flags.setColor(rect); | 97 bitmap.info(), bitmap.getPixels(), bitmap.rowBytes()); |
| 97 flags.setStrokeWidth(10); | 98 surface->getCanvas()->drawColor(fill); |
| 98 flags.setStyle(cc::PaintFlags::kStroke_Style); | 99 SkPaint paint; |
| 99 flags.setBlendMode(SkBlendMode::kSrcOver); | 100 paint.setColor(rect); |
| 100 canvas.DrawRoundRect(gfx::Rect(image_size), 100, flags); | 101 paint.setStrokeWidth(10); |
| 101 return gfx::ImageSkia(canvas.ExtractImageRep()); | 102 paint.setStyle(SkPaint::kStroke_Style); |
| 103 paint.setBlendMode(SkBlendMode::kSrcOver); |
| 104 surface->getCanvas()->drawRoundRect(gfx::RectToSkRect(gfx::Rect(image_size)), |
| 105 100.f, 100.f, paint); |
| 106 return gfx::ImageSkia(gfx::ImageSkiaRep(std::move(bitmap), 1.f)); |
| 102 } | 107 } |
| 103 | 108 |
| 104 void HandleToggleWallpaperMode() { | 109 void HandleToggleWallpaperMode() { |
| 105 static int index = 0; | 110 static int index = 0; |
| 106 WallpaperController* wallpaper_controller = | 111 WallpaperController* wallpaper_controller = |
| 107 Shell::GetInstance()->wallpaper_controller(); | 112 Shell::GetInstance()->wallpaper_controller(); |
| 108 switch (++index % 4) { | 113 switch (++index % 4) { |
| 109 case 0: | 114 case 0: |
| 110 Shell::Get()->wallpaper_delegate()->InitializeWallpaper(); | 115 Shell::Get()->wallpaper_delegate()->InitializeWallpaper(); |
| 111 break; | 116 break; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 case DEBUG_TRIGGER_CRASH: | 212 case DEBUG_TRIGGER_CRASH: |
| 208 HandleTriggerCrash(); | 213 HandleTriggerCrash(); |
| 209 break; | 214 break; |
| 210 default: | 215 default: |
| 211 break; | 216 break; |
| 212 } | 217 } |
| 213 } | 218 } |
| 214 | 219 |
| 215 } // namespace debug | 220 } // namespace debug |
| 216 } // namespace ash | 221 } // namespace ash |
| OLD | NEW |