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 3 // found in the LICENSE file. 4 5 #include "ash/accelerators/accelerator_commands.h" 6 7 #include "ash/desktop_background/desktop_background_controller.h" 8 #include "ash/desktop_background/user_wallpaper_delegate.h" 9 #include "ash/shell.h" 10 #include "third_party/skia/include/core/SkColor.h" 11 #include "third_party/skia/include/core/SkPaint.h" 12 #include "ui/gfx/canvas.h" 13 #include "ui/gfx/image/image_skia.h" 14 15 namespace ash { 16 namespace debug { 17 namespace { 18 19 gfx::ImageSkia CreateWallpaperImage(SkColor fill, SkColor rect) { 20 // TODO(oshima): Consider adding a command line option to control 21 // wallpaper images for testing. 22 // The size is randomly picked. 23 gfx::Size image_size(1366, 768); 24 gfx::Canvas canvas(image_size, 1.0f, true); 25 canvas.DrawColor(fill); 26 SkPaint paint; 27 paint.setColor(rect); 28 paint.setStrokeWidth(10); 29 paint.setStyle(SkPaint::kStroke_Style); 30 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); 31 canvas.DrawRoundRect(gfx::Rect(image_size), 100, paint); 32 return gfx::ImageSkia(canvas.ExtractImageRep()); 33 } 34 35 } // namespace 36 37 bool CycleDesktopBackgroundMode() { 38 static int index = 0; 39 DesktopBackgroundController* desktop_background_controller = 40 Shell::GetInstance()->desktop_background_controller(); 41 switch (++index % 4) { 42 case 0: 43 ash::Shell::GetInstance()->user_wallpaper_delegate()-> 44 InitializeWallpaper(); 45 break; 46 case 1: 47 desktop_background_controller->SetCustomWallpaper( 48 CreateWallpaperImage(SK_ColorRED, SK_ColorBLUE), 49 WALLPAPER_LAYOUT_STRETCH); 50 break; 51 case 2: 52 desktop_background_controller->SetCustomWallpaper( 53 CreateWallpaperImage(SK_ColorBLUE, SK_ColorGREEN), 54 WALLPAPER_LAYOUT_CENTER); 55 break; 56 case 3: 57 desktop_background_controller->SetCustomWallpaper( 58 CreateWallpaperImage(SK_ColorGREEN, SK_ColorRED), 59 WALLPAPER_LAYOUT_CENTER_CROPPED); 60 break; 61 } 62 return true; 63 } 64 65 } // namespace debug 66 } // namespace ash 67