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 @@
namespace ash {
namespace {
const int kSmallWallpaperMaximalWidth = 1366;
const int kSmallWallpaperMaximalHeight = 800;
internal::RootWindowLayoutManager* GetRootWindowLayoutManager(
aura::RootWindow* root_window) {
return static_cast<internal::RootWindowLayoutManager*>(
......@@ -36,11 +32,11 @@ internal::RootWindowLayoutManager* GetRootWindowLayoutManager(
// Stores the current wallpaper data.
struct DesktopBackgroundController::WallpaperData {
WallpaperData(int index, WallpaperResolution resolution)
explicit WallpaperData(int index)
: wallpaper_index(index),
wallpaper_layout(GetWallpaperViewInfo(index, resolution).layout),
wallpaper_layout(GetWallpaperInfo(index).layout),
wallpaper_image(*(ui::ResourceBundle::GetSharedInstance().GetImageNamed(
GetWallpaperViewInfo(index, resolution).id).ToImageSkia())) {
GetWallpaperInfo(index).id).ToImageSkia())) {
}
WallpaperData(WallpaperLayout layout, const gfx::ImageSkia& image)
: wallpaper_index(-1),
......@@ -58,9 +54,7 @@ class DesktopBackgroundController::WallpaperOperation
: public base::RefCountedThreadSafe<
DesktopBackgroundController::WallpaperOperation> {
public:
WallpaperOperation(int index, WallpaperResolution resolution)
: index_(index),
resolution_(resolution) {
explicit WallpaperOperation(int index) : index_(index) {
}
static void Run(scoped_refptr<WallpaperOperation> wo) {
......@@ -70,7 +64,7 @@ class DesktopBackgroundController::WallpaperOperation
void LoadingWallpaper() {
if (cancel_flag_.IsSet())
return;
wallpaper_data_.reset(new WallpaperData(index_, resolution_));
wallpaper_data_.reset(new WallpaperData(index_));
}
void Cancel() {
......@@ -91,9 +85,7 @@ class DesktopBackgroundController::WallpaperOperation
scoped_ptr<WallpaperData> wallpaper_data_;
const int index_;
const WallpaperResolution resolution_;
int index_;
DISALLOW_COPY_AND_ASSIGN(WallpaperOperation);
};
......@@ -131,17 +123,7 @@ void DesktopBackgroundController::OnRootWindowAdded(
switch (desktop_background_mode_) {
case BACKGROUND_IMAGE:
if (current_wallpaper_.get()) {
gfx::Size root_window_size = root_window->GetHostSize();
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);
SetDesktopBackgroundImage(root_window);
} else {
internal::CreateDesktopBackground(root_window);
}
......@@ -152,8 +134,7 @@ void DesktopBackgroundController::OnRootWindowAdded(
}
}
void DesktopBackgroundController::SetDefaultWallpaper(int index,
bool force_reload) {
void DesktopBackgroundController::SetDefaultWallpaper(int index) {
// We should not change background when index is invalid. For instance, at
// login screen or stub_user login.
if (index == ash::GetInvalidWallpaperIndex()) {
......@@ -164,23 +145,12 @@ void DesktopBackgroundController::SetDefaultWallpaper(int index,
return;
}
if (!force_reload && current_wallpaper_.get() &&
current_wallpaper_->wallpaper_index == index)
if (current_wallpaper_.get() && current_wallpaper_->wallpaper_index == index)
return;
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;
}
wallpaper_op_ = new WallpaperOperation(index, resolution);
wallpaper_op_ = new WallpaperOperation(index);
base::WorkerPool::PostTaskAndReply(
FROM_HERE,
base::Bind(&WallpaperOperation::Run, wallpaper_op_),
......
......@@ -71,10 +71,8 @@ class ASH_EXPORT DesktopBackgroundController {
void OnRootWindowAdded(aura::RootWindow* root_window);
// 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
// must be true when a different resolution of current wallpaper is needed.
void SetDefaultWallpaper(int index, bool force_reload);
// wallpaper after loaded.
void SetDefaultWallpaper(int index);
// Sets the user selected custom wallpaper. Called when user selected a file
// from file system or changed the layout of wallpaper.
......
......@@ -19,21 +19,10 @@ enum WallpaperLayout {
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 {
WallpaperViewInfo large;
WallpaperViewInfo small;
int id;
int thumb_id;
WallpaperLayout layout;
// TODO(bshe): author member should be encoded to UTF16. We need to use i18n
// string for this member after M19.
const char* author;
......@@ -50,8 +39,6 @@ ASH_EXPORT int GetNextWallpaperIndex(int index);
ASH_EXPORT int GetSolidColorIndex();
ASH_EXPORT int GetWallpaperCount();
ASH_EXPORT const WallpaperInfo& GetWallpaperInfo(int index);
ASH_EXPORT const WallpaperViewInfo& GetWallpaperViewInfo(int index,
WallpaperResolution resolution);
} // namespace ash
......
......@@ -206,7 +206,7 @@ void WallpaperManager::InitializeWallpaper() {
// TODO(nkostylev): Add switch to disable wallpaper transition on OOBE.
// Should be used on test images so that they are not slowed down.
ash::Shell::GetInstance()->desktop_background_controller()->
SetDefaultWallpaper(kDefaultOOBEWallpaperIndex, false);
SetDefaultWallpaper(kDefaultOOBEWallpaperIndex);
} else {
bool show_users = true;
bool result = CrosSettings::Get()->GetBoolean(
......@@ -215,7 +215,7 @@ void WallpaperManager::InitializeWallpaper() {
<< kAccountsPrefShowUserNamesOnSignIn;
if (!show_users) {
ash::Shell::GetInstance()->desktop_background_controller()->
SetDefaultWallpaper(ash::GetSolidColorIndex(), false);
SetDefaultWallpaper(ash::GetSolidColorIndex());
}
}
}
......@@ -307,7 +307,7 @@ void WallpaperManager::SetInitialUserWallpaper(const std::string& username) {
// crash and speed up the tests by avoid loading wallpaper.
if (ash::Shell::HasInstance()) {
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) {
return;
}
ash::Shell::GetInstance()->desktop_background_controller()->
SetDefaultWallpaper(index, false);
SetDefaultWallpaper(index);
SetLastSelectedUser(email);
}
......@@ -381,7 +381,7 @@ void WallpaperManager::OnUserDeselected() {
if (!UserManager::Get()->IsUserLoggedIn()) {
// This will set default login wallpaper (#fefefe).
ash::Shell::GetInstance()->desktop_background_controller()->
SetDefaultWallpaper(ash::GetSolidColorIndex(), false);
SetDefaultWallpaper(ash::GetSolidColorIndex());
}
}
......
......@@ -248,7 +248,7 @@ void SetWallpaperOptionsHandler::HandleDailyWallpaper(const ListValue* args) {
index = ash::GetNextWallpaperIndex(index);
UserManager::Get()->SaveLoggedInUserWallpaperProperties(User::DAILY, index);
ash::Shell::GetInstance()->desktop_background_controller()->
SetDefaultWallpaper(index, false);
SetDefaultWallpaper(index);
base::StringValue image_url(GetDefaultWallpaperThumbnailURL(index));
base::FundamentalValue is_daily(true);
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