summaryrefslogtreecommitdiffstats
path: root/ash/desktop_background
diff options
context:
space:
mode:
authorbshe@chromium.org <bshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-09 20:34:36 +0000
committerbshe@chromium.org <bshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-09 20:34:36 +0000
commitf66b2bfe80a49c9941c11a646c6558aa9ad77b2b (patch)
treeacc62c92919ce4bebfd3ac14f2717c7d190beda4 /ash/desktop_background
parent62a379a9ecd3d803d43303f9cf8f6c850c21d7de (diff)
downloadchromium_src-f66b2bfe80a49c9941c11a646c6558aa9ad77b2b.zip
chromium_src-f66b2bfe80a49c9941c11a646c6558aa9ad77b2b.tar.gz
chromium_src-f66b2bfe80a49c9941c11a646c6558aa9ad77b2b.tar.bz2
Reland " Preload default wallpaper."
Original CL http://codereview.chromium.org/10827154/ was failed on linux_chromeos. This CL fixed the test. Preload default wallpaper. BUG=139929 TBR=nkostylev, sky Review URL: https://chromiumcodereview.appspot.com/10827247 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150885 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/desktop_background')
-rw-r--r--ash/desktop_background/desktop_background_controller.cc35
-rw-r--r--ash/desktop_background/desktop_background_controller.h8
2 files changed, 34 insertions, 9 deletions
diff --git a/ash/desktop_background/desktop_background_controller.cc b/ash/desktop_background/desktop_background_controller.cc
index 51c2d29..2d49b4d 100644
--- a/ash/desktop_background/desktop_background_controller.cc
+++ b/ash/desktop_background/desktop_background_controller.cc
@@ -151,6 +151,18 @@ void DesktopBackgroundController::OnRootWindowAdded(
InstallComponent(root_window);
}
+void DesktopBackgroundController::CacheDefaultWallpaper(int index) {
+ DCHECK(index >= 0);
+
+ WallpaperResolution resolution = GetAppropriateResolution();
+ scoped_refptr<WallpaperOperation> wallpaper_op =
+ new WallpaperOperation(index, resolution);
+ base::WorkerPool::PostTask(
+ FROM_HERE,
+ base::Bind(&WallpaperOperation::Run, wallpaper_op),
+ true);
+}
+
void DesktopBackgroundController::SetDefaultWallpaper(int index,
bool force_reload) {
// We should not change background when index is invalid. For instance, at
@@ -169,15 +181,7 @@ void DesktopBackgroundController::SetDefaultWallpaper(int index,
CancelPendingWallpaperOperation();
- WallpaperResolution resolution = SMALL;
- Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
- for (Shell::RootWindowList::iterator iter = root_windows.begin();
- iter != root_windows.end(); ++iter) {
- gfx::Size root_window_size = (*iter)->GetHostSize();
- if (root_window_size.width() > kSmallWallpaperMaximalWidth ||
- root_window_size.height() > kSmallWallpaperMaximalHeight)
- resolution = LARGE;
- }
+ WallpaperResolution resolution = GetAppropriateResolution();
wallpaper_op_ = new WallpaperOperation(index, resolution);
base::WorkerPool::PostTaskAndReply(
@@ -355,4 +359,17 @@ int DesktopBackgroundController::GetBackgroundContainerId(bool locked) {
internal::kShellWindowId_DesktopBackgroundContainer;
}
+WallpaperResolution DesktopBackgroundController::GetAppropriateResolution() {
+ WallpaperResolution resolution = SMALL;
+ Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
+ for (Shell::RootWindowList::iterator iter = root_windows.begin();
+ iter != root_windows.end(); ++iter) {
+ gfx::Size root_window_size = (*iter)->GetHostSize();
+ if (root_window_size.width() > kSmallWallpaperMaximalWidth ||
+ root_window_size.height() > kSmallWallpaperMaximalHeight)
+ resolution = LARGE;
+ }
+ return resolution;
+}
+
} // namespace ash
diff --git a/ash/desktop_background/desktop_background_controller.h b/ash/desktop_background/desktop_background_controller.h
index ec9fcab..edcd803 100644
--- a/ash/desktop_background/desktop_background_controller.h
+++ b/ash/desktop_background/desktop_background_controller.h
@@ -76,6 +76,11 @@ class ASH_EXPORT DesktopBackgroundController : public aura::WindowObserver {
// Initialize root window's background.
void OnRootWindowAdded(aura::RootWindow* root_window);
+ // Loads default wallpaper at |index| asynchronously but does not set the
+ // loaded image to current wallpaper. Resource bundle will cache the loaded
+ // image.
+ void CacheDefaultWallpaper(int index);
+
// Loads default wallpaper at |index| asynchronously and sets to current
// wallpaper after loaded. When |force_reload| is true, reload wallpaper
// for all root windows even if |index| is the same as current wallpaper. It
@@ -145,6 +150,9 @@ class ASH_EXPORT DesktopBackgroundController : public aura::WindowObserver {
// Returns id for background container for unlocked and locked states.
int GetBackgroundContainerId(bool locked);
+ // Returns the appropriate wallpaper resolution for all root windows.
+ WallpaperResolution GetAppropriateResolution();
+
// Can change at runtime.
bool locked_;