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.
5 #include "ash/accelerators/accelerator_commands.h"
7 #include "ash/desktop_background/desktop_background_controller.h"
8 #include "ash/desktop_background/user_wallpaper_delegate.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"
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
);
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());
37 bool CycleDesktopBackgroundMode() {
39 DesktopBackgroundController
* desktop_background_controller
=
40 Shell::GetInstance()->desktop_background_controller();
41 switch (++index
% 4) {
43 ash::Shell::GetInstance()->user_wallpaper_delegate()->
44 InitializeWallpaper();
47 desktop_background_controller
->SetCustomWallpaper(
48 CreateWallpaperImage(SK_ColorRED
, SK_ColorBLUE
),
49 WALLPAPER_LAYOUT_STRETCH
);
52 desktop_background_controller
->SetCustomWallpaper(
53 CreateWallpaperImage(SK_ColorBLUE
, SK_ColorGREEN
),
54 WALLPAPER_LAYOUT_CENTER
);
57 desktop_background_controller
->SetCustomWallpaper(
58 CreateWallpaperImage(SK_ColorGREEN
, SK_ColorRED
),
59 WALLPAPER_LAYOUT_CENTER_CROPPED
);