| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/desktop_background/desktop_background_controller.h" | 5 #include "ash/desktop_background/desktop_background_controller.h" |
| 6 | 6 |
| 7 #include "ash/desktop_background/desktop_background_view.h" | 7 #include "ash/desktop_background/desktop_background_view.h" |
| 8 #include "ash/desktop_background/desktop_background_widget_controller.h" | 8 #include "ash/desktop_background/desktop_background_widget_controller.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_factory.h" | 10 #include "ash/shell_factory.h" |
| 11 #include "ash/shell_window_ids.h" | 11 #include "ash/shell_window_ids.h" |
| 12 #include "ash/wm/root_window_layout_manager.h" | 12 #include "ash/wm/root_window_layout_manager.h" |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/synchronization/cancellation_flag.h" | 15 #include "base/synchronization/cancellation_flag.h" |
| 16 #include "base/threading/worker_pool.h" | 16 #include "base/threading/worker_pool.h" |
| 17 #include "grit/ui_resources.h" | 17 #include "grit/ui_resources.h" |
| 18 #include "ui/aura/root_window.h" | 18 #include "ui/aura/root_window.h" |
| 19 #include "ui/aura/window.h" | 19 #include "ui/aura/window.h" |
| 20 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
| 21 #include "ui/compositor/layer.h" | 21 #include "ui/compositor/layer.h" |
| 22 #include "ui/gfx/rect.h" | 22 #include "ui/gfx/rect.h" |
| 23 #include "ui/gfx/image/image.h" | 23 #include "ui/gfx/image/image.h" |
| 24 #include "ui/views/widget/widget.h" | 24 #include "ui/views/widget/widget.h" |
| 25 | 25 |
| 26 namespace ash { | 26 namespace ash { |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 const int kSmallWallpaperMaximalWidth = 1366; | |
| 30 const int kSmallWallpaperMaximalHeight = 800; | |
| 31 const SkColor kTransparentColor = SkColorSetARGB(0x00, 0x00, 0x00, 0x00); | 29 const SkColor kTransparentColor = SkColorSetARGB(0x00, 0x00, 0x00, 0x00); |
| 32 | 30 |
| 33 internal::RootWindowLayoutManager* GetRootWindowLayoutManager( | 31 internal::RootWindowLayoutManager* GetRootWindowLayoutManager( |
| 34 aura::RootWindow* root_window) { | 32 aura::RootWindow* root_window) { |
| 35 return static_cast<internal::RootWindowLayoutManager*>( | 33 return static_cast<internal::RootWindowLayoutManager*>( |
| 36 root_window->layout_manager()); | 34 root_window->layout_manager()); |
| 37 } | 35 } |
| 38 } // namespace | 36 } // namespace |
| 39 | 37 |
| 38 const int kSmallWallpaperMaxWidth = 1366; |
| 39 const int kSmallWallpaperMaxHeight = 800; |
| 40 const int kLargeWallpaperMaxWidth = 2560; |
| 41 const int kLargeWallpaperMaxHeight = 1700; |
| 42 |
| 40 // Stores the current wallpaper data. | 43 // Stores the current wallpaper data. |
| 41 struct DesktopBackgroundController::WallpaperData { | 44 struct DesktopBackgroundController::WallpaperData { |
| 42 WallpaperData(int index, WallpaperResolution resolution) | 45 WallpaperData(int index, WallpaperResolution resolution) |
| 43 : wallpaper_index(index), | 46 : wallpaper_index(index), |
| 44 wallpaper_layout(GetWallpaperViewInfo(index, resolution).layout), | 47 wallpaper_layout(GetWallpaperViewInfo(index, resolution).layout), |
| 45 wallpaper_image(*(ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 48 wallpaper_image(*(ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| 46 GetWallpaperViewInfo(index, resolution).id).ToImageSkia())) { | 49 GetWallpaperViewInfo(index, resolution).id).ToImageSkia())) { |
| 47 } | 50 } |
| 48 WallpaperData(WallpaperLayout layout, const gfx::ImageSkia& image) | 51 WallpaperData(WallpaperLayout layout, const gfx::ImageSkia& image) |
| 49 : wallpaper_index(-1), | 52 : wallpaper_index(-1), |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 current_wallpaper_.reset(NULL); | 224 current_wallpaper_.reset(NULL); |
| 222 SetDesktopBackgroundImageMode(); | 225 SetDesktopBackgroundImageMode(); |
| 223 } | 226 } |
| 224 | 227 |
| 225 WallpaperResolution DesktopBackgroundController::GetAppropriateResolution() { | 228 WallpaperResolution DesktopBackgroundController::GetAppropriateResolution() { |
| 226 WallpaperResolution resolution = SMALL; | 229 WallpaperResolution resolution = SMALL; |
| 227 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 230 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 228 for (Shell::RootWindowList::iterator iter = root_windows.begin(); | 231 for (Shell::RootWindowList::iterator iter = root_windows.begin(); |
| 229 iter != root_windows.end(); ++iter) { | 232 iter != root_windows.end(); ++iter) { |
| 230 gfx::Size root_window_size = (*iter)->GetHostSize(); | 233 gfx::Size root_window_size = (*iter)->GetHostSize(); |
| 231 if (root_window_size.width() > kSmallWallpaperMaximalWidth || | 234 if (root_window_size.width() > kSmallWallpaperMaxWidth || |
| 232 root_window_size.height() > kSmallWallpaperMaximalHeight) | 235 root_window_size.height() > kSmallWallpaperMaxHeight) |
| 233 resolution = LARGE; | 236 resolution = LARGE; |
| 234 } | 237 } |
| 235 return resolution; | 238 return resolution; |
| 236 } | 239 } |
| 237 | 240 |
| 238 void DesktopBackgroundController::MoveDesktopToLockedContainer() { | 241 void DesktopBackgroundController::MoveDesktopToLockedContainer() { |
| 239 if (locked_) | 242 if (locked_) |
| 240 return; | 243 return; |
| 241 locked_ = true; | 244 locked_ = true; |
| 242 ReparentBackgroundWidgets(GetBackgroundContainerId(false), | 245 ReparentBackgroundWidgets(GetBackgroundContainerId(false), |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 } | 359 } |
| 357 } | 360 } |
| 358 } | 361 } |
| 359 | 362 |
| 360 int DesktopBackgroundController::GetBackgroundContainerId(bool locked) { | 363 int DesktopBackgroundController::GetBackgroundContainerId(bool locked) { |
| 361 return locked ? internal::kShellWindowId_LockScreenBackgroundContainer : | 364 return locked ? internal::kShellWindowId_LockScreenBackgroundContainer : |
| 362 internal::kShellWindowId_DesktopBackgroundContainer; | 365 internal::kShellWindowId_DesktopBackgroundContainer; |
| 363 } | 366 } |
| 364 | 367 |
| 365 } // namespace ash | 368 } // namespace ash |
| OLD | NEW |