| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #include "ash/desktop_background/user_wallpaper_delegate.h" | |
| 6 | |
| 7 #include "ash/desktop_background/desktop_background_controller.h" | |
| 8 #include "ash/shell.h" | |
| 9 #include "ash/wm/window_animations.h" | |
| 10 #include "base/basictypes.h" | |
| 11 #include "ui/gfx/image/image_skia.h" | |
| 12 | |
| 13 namespace { | |
| 14 | |
| 15 const char kBackgroundRed = 70; | |
| 16 const char kBackgroundGreen = 70; | |
| 17 const char kBackgroundBlue = 78; | |
| 18 | |
| 19 class UserWallpaperDelegate : public ash::UserWallpaperDelegate { | |
| 20 public: | |
| 21 UserWallpaperDelegate() { | |
| 22 } | |
| 23 | |
| 24 virtual ~UserWallpaperDelegate() { | |
| 25 } | |
| 26 | |
| 27 virtual int GetAnimationType() OVERRIDE { | |
| 28 return ShouldShowInitialAnimation() ? | |
| 29 ash::WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE : | |
| 30 static_cast<int>(wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); | |
| 31 } | |
| 32 | |
| 33 virtual bool ShouldShowInitialAnimation() OVERRIDE { | |
| 34 return true; | |
| 35 } | |
| 36 | |
| 37 virtual int GetAnimationDurationOverride() OVERRIDE { | |
| 38 // Return 0 to select the default. | |
| 39 return 0; | |
| 40 } | |
| 41 | |
| 42 virtual void SetAnimationDurationOverride( | |
| 43 int animation_duration_in_ms) OVERRIDE { | |
| 44 NOTIMPLEMENTED(); | |
| 45 } | |
| 46 | |
| 47 virtual void UpdateWallpaper(bool clear_cache) OVERRIDE { | |
| 48 SkBitmap bitmap; | |
| 49 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 16, 16); | |
| 50 bitmap.allocPixels(); | |
| 51 bitmap.eraseARGB(255, kBackgroundRed, kBackgroundGreen, kBackgroundBlue); | |
| 52 #if !defined(NDEBUG) | |
| 53 // In debug builds we generate a simple pattern that allows visually | |
| 54 // notice if transparency is broken. | |
| 55 { | |
| 56 SkAutoLockPixels alp(bitmap); | |
| 57 *bitmap.getAddr32(0,0) = SkColorSetRGB(0, 0, 0); | |
| 58 } | |
| 59 #endif | |
| 60 gfx::ImageSkia wallpaper = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); | |
| 61 ash::Shell::GetInstance() | |
| 62 ->desktop_background_controller() | |
| 63 ->SetWallpaperImage(wallpaper, ash::WALLPAPER_LAYOUT_TILE); | |
| 64 } | |
| 65 | |
| 66 virtual void InitializeWallpaper() OVERRIDE { | |
| 67 UpdateWallpaper(false); | |
| 68 } | |
| 69 | |
| 70 virtual void OpenSetWallpaperPage() OVERRIDE { | |
| 71 } | |
| 72 | |
| 73 virtual bool CanOpenSetWallpaperPage() OVERRIDE { | |
| 74 return false; | |
| 75 } | |
| 76 | |
| 77 virtual void OnWallpaperAnimationFinished() OVERRIDE { | |
| 78 } | |
| 79 | |
| 80 virtual void OnWallpaperBootAnimationFinished() OVERRIDE { | |
| 81 } | |
| 82 | |
| 83 private: | |
| 84 DISALLOW_COPY_AND_ASSIGN(UserWallpaperDelegate); | |
| 85 }; | |
| 86 | |
| 87 } // namespace | |
| 88 | |
| 89 ash::UserWallpaperDelegate* CreateUserWallpaperDelegate() { | |
| 90 return new UserWallpaperDelegate(); | |
| 91 } | |
| OLD | NEW |