1 // Copyright (c) 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/desktop_background/user_wallpaper_delegate.h"
7 #include "ash/desktop_background/desktop_background_controller.h"
9 #include "ash/wm/window_animations.h"
10 #include "base/basictypes.h"
11 #include "ui/gfx/image/image_skia.h"
15 const char kBackgroundRed
= 70;
16 const char kBackgroundGreen
= 70;
17 const char kBackgroundBlue
= 78;
19 class UserWallpaperDelegate
: public ash::UserWallpaperDelegate
{
21 UserWallpaperDelegate() {
24 virtual ~UserWallpaperDelegate() {
27 virtual int GetAnimationType() OVERRIDE
{
28 return ShouldShowInitialAnimation() ?
29 ash::WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE
:
30 static_cast<int>(views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE
);
33 virtual bool ShouldShowInitialAnimation() OVERRIDE
{
37 virtual void UpdateWallpaper() OVERRIDE
{
39 bitmap
.setConfig(SkBitmap::kARGB_8888_Config
, 16, 16);
41 bitmap
.eraseARGB(255, kBackgroundRed
, kBackgroundGreen
, kBackgroundBlue
);
43 // In debug builds we generate a simple pattern that allows visually
44 // notice if transparency is broken.
46 SkAutoLockPixels
alp(bitmap
);
47 *bitmap
.getAddr32(0,0) = SkColorSetRGB(0, 0, 0);
50 gfx::ImageSkia wallpaper
= gfx::ImageSkia::CreateFrom1xBitmap(bitmap
);
51 ash::Shell::GetInstance()->desktop_background_controller()->
52 SetCustomWallpaper(wallpaper
, ash::WALLPAPER_LAYOUT_TILE
);
55 virtual void InitializeWallpaper() OVERRIDE
{
59 virtual void OpenSetWallpaperPage() OVERRIDE
{
62 virtual bool CanOpenSetWallpaperPage() OVERRIDE
{
66 virtual void OnWallpaperAnimationFinished() OVERRIDE
{
69 virtual void OnWallpaperBootAnimationFinished() OVERRIDE
{
73 DISALLOW_COPY_AND_ASSIGN(UserWallpaperDelegate
);
78 ash::UserWallpaperDelegate
* CreateUserWallpaperDelegate() {
79 return new UserWallpaperDelegate();