summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorbshe@chromium.org <bshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-09 04:08:37 +0000
committerbshe@chromium.org <bshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-09 04:08:37 +0000
commit67c5f0e96b3d716a833025fdcd4be466e0f3410f (patch)
treeada1d412af09efb967d7a9e8ba7cd74315686099 /ash
parent873a79c5783b392e78277aaec4dbfb71bc65918a (diff)
downloadchromium_src-67c5f0e96b3d716a833025fdcd4be466e0f3410f.zip
chromium_src-67c5f0e96b3d716a833025fdcd4be466e0f3410f.tar.gz
chromium_src-67c5f0e96b3d716a833025fdcd4be466e0f3410f.tar.bz2
Preload default wallpaper.
BUG=139929 Review URL: https://chromiumcodereview.appspot.com/10827154 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150726 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-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_;