Index: ash/desktop_background/desktop_background_controller.cc |
diff --git a/ash/desktop_background/desktop_background_controller.cc b/ash/desktop_background/desktop_background_controller.cc |
index 022ca0ba0c796d47753b6536e39bc8dac85d94e0..1c6327832adcb653b4bbe8dc03494ea165e7ba50 100644 |
--- a/ash/desktop_background/desktop_background_controller.cc |
+++ b/ash/desktop_background/desktop_background_controller.cc |
@@ -23,6 +23,10 @@ |
namespace ash { |
namespace { |
+ |
+const int kSmallWallpaperMaximalWidth = 1366; |
+const int kSmallWallpaperMaximalHeight = 800; |
+ |
internal::RootWindowLayoutManager* GetRootWindowLayoutManager( |
aura::RootWindow* root_window) { |
return static_cast<internal::RootWindowLayoutManager*>( |
@@ -32,11 +36,11 @@ internal::RootWindowLayoutManager* GetRootWindowLayoutManager( |
// Stores the current wallpaper data. |
struct DesktopBackgroundController::WallpaperData { |
- explicit WallpaperData(int index) |
+ explicit WallpaperData(int index, WallpaperResolution resolution) |
: wallpaper_index(index), |
- wallpaper_layout(GetWallpaperInfo(index).layout), |
+ wallpaper_layout(GetWallpaperViewInfo(index, resolution).layout), |
wallpaper_image(*(ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
- GetWallpaperInfo(index).id).ToImageSkia())) { |
+ GetWallpaperViewInfo(index, resolution).id).ToImageSkia())) { |
} |
WallpaperData(WallpaperLayout layout, const gfx::ImageSkia& image) |
: wallpaper_index(-1), |
@@ -54,7 +58,9 @@ class DesktopBackgroundController::WallpaperOperation |
: public base::RefCountedThreadSafe< |
DesktopBackgroundController::WallpaperOperation> { |
public: |
- explicit WallpaperOperation(int index) : index_(index) { |
+ WallpaperOperation(int index, WallpaperResolution resolution) |
+ : index_(index), |
+ resolution_(resolution) { |
} |
static void Run(scoped_refptr<WallpaperOperation> wo) { |
@@ -64,7 +70,7 @@ class DesktopBackgroundController::WallpaperOperation |
void LoadingWallpaper() { |
if (cancel_flag_.IsSet()) |
return; |
- wallpaper_data_.reset(new WallpaperData(index_)); |
+ wallpaper_data_.reset(new WallpaperData(index_, resolution_)); |
} |
void Cancel() { |
@@ -87,6 +93,8 @@ class DesktopBackgroundController::WallpaperOperation |
int index_; |
+ WallpaperResolution resolution_; |
+ |
DISALLOW_COPY_AND_ASSIGN(WallpaperOperation); |
}; |
@@ -123,7 +131,14 @@ void DesktopBackgroundController::OnRootWindowAdded( |
switch (desktop_background_mode_) { |
case BACKGROUND_IMAGE: |
if (current_wallpaper_.get()) { |
- SetDesktopBackgroundImage(root_window); |
+ gfx::Size root_window_size = root_window->GetHostSize(); |
+ int wallpaper_width = current_wallpaper_->wallpaper_image.width(); |
+ int wallpaper_height = current_wallpaper_->wallpaper_image.height(); |
+ if (wallpaper_width < root_window_size.width() || |
+ wallpaper_height < root_window_size.height()) |
Emmanuel Saint-loubert-Bié
2012/08/03 14:28:26
Does this test works for smaller images that are t
bshe
2012/08/03 15:01:33
Ahha. I overlooked that case. Also custom wallpape
|
+ SetDefaultWallpaper(current_wallpaper_->wallpaper_index, true); |
+ else |
+ SetDesktopBackgroundImage(root_window); |
} else { |
internal::CreateDesktopBackground(root_window); |
} |
@@ -134,7 +149,8 @@ void DesktopBackgroundController::OnRootWindowAdded( |
} |
} |
-void DesktopBackgroundController::SetDefaultWallpaper(int index) { |
+void DesktopBackgroundController::SetDefaultWallpaper(int index, |
+ bool force_reload) { |
// We should not change background when index is invalid. For instance, at |
// login screen or stub_user login. |
if (index == ash::GetInvalidWallpaperIndex()) { |
@@ -145,12 +161,23 @@ void DesktopBackgroundController::SetDefaultWallpaper(int index) { |
return; |
} |
- if (current_wallpaper_.get() && current_wallpaper_->wallpaper_index == index) |
+ if (!force_reload && current_wallpaper_.get() && |
+ current_wallpaper_->wallpaper_index == index) |
return; |
CancelPendingWallpaperOperation(); |
- wallpaper_op_ = new WallpaperOperation(index); |
+ 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; |
+ } |
+ |
+ wallpaper_op_ = new WallpaperOperation(index, resolution); |
base::WorkerPool::PostTaskAndReply( |
FROM_HERE, |
base::Bind(&WallpaperOperation::Run, wallpaper_op_), |