Revert 149915 - Use low resolution wallpapers for small screens

Broke Win Aura compile

BUG=140336
TBR=jhawkins

Review URL: https://chromiumcodereview.appspot.com/10837089

TBR=bshe@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10829178

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149940 0039d316-1c4b-4281-b951-d872f2087c98
parent 0b74c338
...@@ -23,10 +23,6 @@ ...@@ -23,10 +23,6 @@
namespace ash { namespace ash {
namespace { namespace {
const int kSmallWallpaperMaximalWidth = 1366;
const int kSmallWallpaperMaximalHeight = 800;
internal::RootWindowLayoutManager* GetRootWindowLayoutManager( internal::RootWindowLayoutManager* GetRootWindowLayoutManager(
aura::RootWindow* root_window) { aura::RootWindow* root_window) {
return static_cast<internal::RootWindowLayoutManager*>( return static_cast<internal::RootWindowLayoutManager*>(
...@@ -36,11 +32,11 @@ internal::RootWindowLayoutManager* GetRootWindowLayoutManager( ...@@ -36,11 +32,11 @@ internal::RootWindowLayoutManager* GetRootWindowLayoutManager(
// Stores the current wallpaper data. // Stores the current wallpaper data.
struct DesktopBackgroundController::WallpaperData { struct DesktopBackgroundController::WallpaperData {
WallpaperData(int index, WallpaperResolution resolution) explicit WallpaperData(int index)
: wallpaper_index(index), : wallpaper_index(index),
wallpaper_layout(GetWallpaperViewInfo(index, resolution).layout), wallpaper_layout(GetWallpaperInfo(index).layout),
wallpaper_image(*(ui::ResourceBundle::GetSharedInstance().GetImageNamed( wallpaper_image(*(ui::ResourceBundle::GetSharedInstance().GetImageNamed(
GetWallpaperViewInfo(index, resolution).id).ToImageSkia())) { GetWallpaperInfo(index).id).ToImageSkia())) {
} }
WallpaperData(WallpaperLayout layout, const gfx::ImageSkia& image) WallpaperData(WallpaperLayout layout, const gfx::ImageSkia& image)
: wallpaper_index(-1), : wallpaper_index(-1),
...@@ -58,9 +54,7 @@ class DesktopBackgroundController::WallpaperOperation ...@@ -58,9 +54,7 @@ class DesktopBackgroundController::WallpaperOperation
: public base::RefCountedThreadSafe< : public base::RefCountedThreadSafe<
DesktopBackgroundController::WallpaperOperation> { DesktopBackgroundController::WallpaperOperation> {
public: public:
WallpaperOperation(int index, WallpaperResolution resolution) explicit WallpaperOperation(int index) : index_(index) {
: index_(index),
resolution_(resolution) {
} }
static void Run(scoped_refptr<WallpaperOperation> wo) { static void Run(scoped_refptr<WallpaperOperation> wo) {
...@@ -70,7 +64,7 @@ class DesktopBackgroundController::WallpaperOperation ...@@ -70,7 +64,7 @@ class DesktopBackgroundController::WallpaperOperation
void LoadingWallpaper() { void LoadingWallpaper() {
if (cancel_flag_.IsSet()) if (cancel_flag_.IsSet())
return; return;
wallpaper_data_.reset(new WallpaperData(index_, resolution_)); wallpaper_data_.reset(new WallpaperData(index_));
} }
void Cancel() { void Cancel() {
...@@ -91,9 +85,7 @@ class DesktopBackgroundController::WallpaperOperation ...@@ -91,9 +85,7 @@ class DesktopBackgroundController::WallpaperOperation
scoped_ptr<WallpaperData> wallpaper_data_; scoped_ptr<WallpaperData> wallpaper_data_;
const int index_; int index_;
const WallpaperResolution resolution_;
DISALLOW_COPY_AND_ASSIGN(WallpaperOperation); DISALLOW_COPY_AND_ASSIGN(WallpaperOperation);
}; };
...@@ -131,17 +123,7 @@ void DesktopBackgroundController::OnRootWindowAdded( ...@@ -131,17 +123,7 @@ void DesktopBackgroundController::OnRootWindowAdded(
switch (desktop_background_mode_) { switch (desktop_background_mode_) {
case BACKGROUND_IMAGE: case BACKGROUND_IMAGE:
if (current_wallpaper_.get()) { if (current_wallpaper_.get()) {
gfx::Size root_window_size = root_window->GetHostSize(); SetDesktopBackgroundImage(root_window);
int wallpaper_width = current_wallpaper_->wallpaper_image.width();
int wallpaper_height = current_wallpaper_->wallpaper_image.height();
// Loads a higher resolution wallpaper if needed.
if ((wallpaper_width < root_window_size.width() ||
wallpaper_height < root_window_size.height()) &&
current_wallpaper_->wallpaper_index != -1 &&
current_wallpaper_->wallpaper_layout != TILE)
SetDefaultWallpaper(current_wallpaper_->wallpaper_index, true);
else
SetDesktopBackgroundImage(root_window);
} else { } else {
internal::CreateDesktopBackground(root_window); internal::CreateDesktopBackground(root_window);
} }
...@@ -152,8 +134,7 @@ void DesktopBackgroundController::OnRootWindowAdded( ...@@ -152,8 +134,7 @@ 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 // We should not change background when index is invalid. For instance, at
// login screen or stub_user login. // login screen or stub_user login.
if (index == ash::GetInvalidWallpaperIndex()) { if (index == ash::GetInvalidWallpaperIndex()) {
...@@ -164,23 +145,12 @@ void DesktopBackgroundController::SetDefaultWallpaper(int index, ...@@ -164,23 +145,12 @@ void DesktopBackgroundController::SetDefaultWallpaper(int index,
return; return;
} }
if (!force_reload && current_wallpaper_.get() && if (current_wallpaper_.get() && current_wallpaper_->wallpaper_index == index)
current_wallpaper_->wallpaper_index == index)
return; return;
CancelPendingWallpaperOperation(); CancelPendingWallpaperOperation();
WallpaperResolution resolution = SMALL; wallpaper_op_ = new WallpaperOperation(index);
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( base::WorkerPool::PostTaskAndReply(
FROM_HERE, FROM_HERE,
base::Bind(&WallpaperOperation::Run, wallpaper_op_), base::Bind(&WallpaperOperation::Run, wallpaper_op_),
......
...@@ -71,10 +71,8 @@ class ASH_EXPORT DesktopBackgroundController { ...@@ -71,10 +71,8 @@ class ASH_EXPORT DesktopBackgroundController {
void OnRootWindowAdded(aura::RootWindow* root_window); void OnRootWindowAdded(aura::RootWindow* root_window);
// Loads default wallpaper at |index| asynchronously and sets to current // Loads default wallpaper at |index| asynchronously and sets to current
// wallpaper after loaded. When |force_reload| is true, reload wallpaper // wallpaper after loaded.
// for all root windows even if |index| is the same as current wallpaper. It void SetDefaultWallpaper(int index);
// must be true when a different resolution of current wallpaper is needed.
void SetDefaultWallpaper(int index, bool force_reload);
// Sets the user selected custom wallpaper. Called when user selected a file // Sets the user selected custom wallpaper. Called when user selected a file
// from file system or changed the layout of wallpaper. // from file system or changed the layout of wallpaper.
......
...@@ -19,21 +19,10 @@ enum WallpaperLayout { ...@@ -19,21 +19,10 @@ enum WallpaperLayout {
TILE, TILE,
}; };
enum WallpaperResolution {
LARGE,
SMALL
};
// Encapsulates wallpaper infomation needed by desktop background view.
struct ASH_EXPORT WallpaperViewInfo {
int id;
WallpaperLayout layout;
};
struct ASH_EXPORT WallpaperInfo { struct ASH_EXPORT WallpaperInfo {
WallpaperViewInfo large; int id;
WallpaperViewInfo small;
int thumb_id; int thumb_id;
WallpaperLayout layout;
// TODO(bshe): author member should be encoded to UTF16. We need to use i18n // TODO(bshe): author member should be encoded to UTF16. We need to use i18n
// string for this member after M19. // string for this member after M19.
const char* author; const char* author;
...@@ -50,8 +39,6 @@ ASH_EXPORT int GetNextWallpaperIndex(int index); ...@@ -50,8 +39,6 @@ ASH_EXPORT int GetNextWallpaperIndex(int index);
ASH_EXPORT int GetSolidColorIndex(); ASH_EXPORT int GetSolidColorIndex();
ASH_EXPORT int GetWallpaperCount(); ASH_EXPORT int GetWallpaperCount();
ASH_EXPORT const WallpaperInfo& GetWallpaperInfo(int index); ASH_EXPORT const WallpaperInfo& GetWallpaperInfo(int index);
ASH_EXPORT const WallpaperViewInfo& GetWallpaperViewInfo(int index,
WallpaperResolution resolution);
} // namespace ash } // namespace ash
......
...@@ -206,7 +206,7 @@ void WallpaperManager::InitializeWallpaper() { ...@@ -206,7 +206,7 @@ void WallpaperManager::InitializeWallpaper() {
// TODO(nkostylev): Add switch to disable wallpaper transition on OOBE. // TODO(nkostylev): Add switch to disable wallpaper transition on OOBE.
// Should be used on test images so that they are not slowed down. // Should be used on test images so that they are not slowed down.
ash::Shell::GetInstance()->desktop_background_controller()-> ash::Shell::GetInstance()->desktop_background_controller()->
SetDefaultWallpaper(kDefaultOOBEWallpaperIndex, false); SetDefaultWallpaper(kDefaultOOBEWallpaperIndex);
} else { } else {
bool show_users = true; bool show_users = true;
bool result = CrosSettings::Get()->GetBoolean( bool result = CrosSettings::Get()->GetBoolean(
...@@ -215,7 +215,7 @@ void WallpaperManager::InitializeWallpaper() { ...@@ -215,7 +215,7 @@ void WallpaperManager::InitializeWallpaper() {
<< kAccountsPrefShowUserNamesOnSignIn; << kAccountsPrefShowUserNamesOnSignIn;
if (!show_users) { if (!show_users) {
ash::Shell::GetInstance()->desktop_background_controller()-> ash::Shell::GetInstance()->desktop_background_controller()->
SetDefaultWallpaper(ash::GetSolidColorIndex(), false); SetDefaultWallpaper(ash::GetSolidColorIndex());
} }
} }
} }
...@@ -307,7 +307,7 @@ void WallpaperManager::SetInitialUserWallpaper(const std::string& username) { ...@@ -307,7 +307,7 @@ void WallpaperManager::SetInitialUserWallpaper(const std::string& username) {
// crash and speed up the tests by avoid loading wallpaper. // crash and speed up the tests by avoid loading wallpaper.
if (ash::Shell::HasInstance()) { if (ash::Shell::HasInstance()) {
ash::Shell::GetInstance()->desktop_background_controller()-> ash::Shell::GetInstance()->desktop_background_controller()->
SetDefaultWallpaper(current_user_wallpaper_index_, false); SetDefaultWallpaper(current_user_wallpaper_index_);
} }
} }
...@@ -366,7 +366,7 @@ void WallpaperManager::SetUserWallpaper(const std::string& email) { ...@@ -366,7 +366,7 @@ void WallpaperManager::SetUserWallpaper(const std::string& email) {
return; return;
} }
ash::Shell::GetInstance()->desktop_background_controller()-> ash::Shell::GetInstance()->desktop_background_controller()->
SetDefaultWallpaper(index, false); SetDefaultWallpaper(index);
SetLastSelectedUser(email); SetLastSelectedUser(email);
} }
...@@ -381,7 +381,7 @@ void WallpaperManager::OnUserDeselected() { ...@@ -381,7 +381,7 @@ void WallpaperManager::OnUserDeselected() {
if (!UserManager::Get()->IsUserLoggedIn()) { if (!UserManager::Get()->IsUserLoggedIn()) {
// This will set default login wallpaper (#fefefe). // This will set default login wallpaper (#fefefe).
ash::Shell::GetInstance()->desktop_background_controller()-> ash::Shell::GetInstance()->desktop_background_controller()->
SetDefaultWallpaper(ash::GetSolidColorIndex(), false); SetDefaultWallpaper(ash::GetSolidColorIndex());
} }
} }
......
...@@ -248,7 +248,7 @@ void SetWallpaperOptionsHandler::HandleDailyWallpaper(const ListValue* args) { ...@@ -248,7 +248,7 @@ void SetWallpaperOptionsHandler::HandleDailyWallpaper(const ListValue* args) {
index = ash::GetNextWallpaperIndex(index); index = ash::GetNextWallpaperIndex(index);
UserManager::Get()->SaveLoggedInUserWallpaperProperties(User::DAILY, index); UserManager::Get()->SaveLoggedInUserWallpaperProperties(User::DAILY, index);
ash::Shell::GetInstance()->desktop_background_controller()-> ash::Shell::GetInstance()->desktop_background_controller()->
SetDefaultWallpaper(index, false); SetDefaultWallpaper(index);
base::StringValue image_url(GetDefaultWallpaperThumbnailURL(index)); base::StringValue image_url(GetDefaultWallpaperThumbnailURL(index));
base::FundamentalValue is_daily(true); base::FundamentalValue is_daily(true);
web_ui()->CallJavascriptFunction("SetWallpaperOptions.setSelectedImage", web_ui()->CallJavascriptFunction("SetWallpaperOptions.setSelectedImage",
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment