diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-25 01:08:39 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-25 01:08:39 +0000 |
commit | e607e65e5b0502ff0dd86d15c7cd173aaddbe129 (patch) | |
tree | 21c8cf71e9ef8c59dd3ec3eb165f13f8c1f29ec8 /ash/desktop_background/desktop_background_controller.cc | |
parent | 332b4d309224fddf3abd89a7c8e2197bf950139f (diff) | |
download | chromium_src-e607e65e5b0502ff0dd86d15c7cd173aaddbe129.zip chromium_src-e607e65e5b0502ff0dd86d15c7cd173aaddbe129.tar.gz chromium_src-e607e65e5b0502ff0dd86d15c7cd173aaddbe129.tar.bz2 |
* Use correct bounds to pick and resize wallpaper image
* Use separate layer to draw wallpaper and scale it,
rather than scaling at drawing time, which uses more CPU and memory.
* Changed ctrl-alt-b behavior so that it uses fixed image with different layouts.
BUG=294479
TEST=manual + unittests.
R=derat@chromium.org
Review URL: https://codereview.chromium.org/24269015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225116 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/desktop_background/desktop_background_controller.cc')
-rw-r--r-- | ash/desktop_background/desktop_background_controller.cc | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/ash/desktop_background/desktop_background_controller.cc b/ash/desktop_background/desktop_background_controller.cc index d91f383..b8fef38 100644 --- a/ash/desktop_background/desktop_background_controller.cc +++ b/ash/desktop_background/desktop_background_controller.cc @@ -10,6 +10,8 @@ #include "ash/desktop_background/desktop_background_widget_controller.h" #include "ash/desktop_background/user_wallpaper_delegate.h" #include "ash/desktop_background/wallpaper_resizer.h" +#include "ash/display/display_info.h" +#include "ash/display/display_manager.h" #include "ash/root_window_controller.h" #include "ash/shell.h" #include "ash/shell_factory.h" @@ -45,22 +47,6 @@ internal::RootWindowLayoutManager* GetRootWindowLayoutManager( root_window->layout_manager()); } -// Returns the maximum width and height of all root windows. -gfx::Size GetRootWindowsSize() { - int width = 0; - int height = 0; - 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() > width) - width = root_window_size.width(); - if (root_window_size.height() > height) - height = root_window_size.height(); - } - return gfx::Size(width, height); -} - } // namespace const int kSmallWallpaperMaxWidth = 1366; @@ -139,10 +125,10 @@ class DesktopBackgroundController::WallpaperLoader if (file_bitmap_) { gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(*file_bitmap_); wallpaper_resizer_.reset(new WallpaperResizer( - image, GetRootWindowsSize(), file_layout_)); + image, GetMaxDisplaySizeInNative(), file_layout_)); } else { wallpaper_resizer_.reset(new WallpaperResizer( - resource_id_, GetRootWindowsSize(), resource_layout_)); + resource_id_, GetMaxDisplaySizeInNative(), resource_layout_)); } } @@ -275,7 +261,7 @@ void DesktopBackgroundController::SetCustomWallpaper( return; current_wallpaper_.reset(new WallpaperResizer( - image, GetRootWindowsSize(), layout)); + image, GetMaxDisplaySizeInNative(), layout)); current_wallpaper_->StartResize(); current_default_wallpaper_path_ = base::FilePath(); @@ -302,19 +288,10 @@ void DesktopBackgroundController::CreateEmptyWallpaper() { WallpaperResolution DesktopBackgroundController::GetAppropriateResolution() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); - for (Shell::RootWindowList::iterator iter = root_windows.begin(); - iter != root_windows.end(); ++iter) { - // Compare to host size as constants are defined in terms of - // physical pixel size. - // TODO(oshima): This may not be ideal for fractional scaling - // scenario. Revisit and fix if necessary. - gfx::Size host_window_size = (*iter)->GetHostSize(); - if (host_window_size.width() > kSmallWallpaperMaxWidth || - host_window_size.height() > kSmallWallpaperMaxHeight) - return WALLPAPER_RESOLUTION_LARGE; - } - return WALLPAPER_RESOLUTION_SMALL; + gfx::Size size = GetMaxDisplaySizeInNative(); + return (size.width() > kSmallWallpaperMaxWidth || + size.height() > kSmallWallpaperMaxHeight) ? + WALLPAPER_RESOLUTION_LARGE : WALLPAPER_RESOLUTION_SMALL; } bool DesktopBackgroundController::MoveDesktopToLockedContainer() { @@ -443,4 +420,27 @@ int DesktopBackgroundController::GetBackgroundContainerId(bool locked) { internal::kShellWindowId_DesktopBackgroundContainer; } +// static +gfx::Size DesktopBackgroundController::GetMaxDisplaySizeInNative() { + int width = 0; + int height = 0; + std::vector<gfx::Display> displays = Shell::GetScreen()->GetAllDisplays(); + internal::DisplayManager* display_manager = + Shell::GetInstance()->display_manager(); + + for (std::vector<gfx::Display>::iterator iter = displays.begin(); + iter != displays.end(); ++iter) { + // Don't use size_in_pixel because we want to use the native pixel size. + gfx::Size size_in_pixel = + display_manager->GetDisplayInfo(iter->id()).bounds_in_native().size(); + if (iter->rotation() == gfx::Display::ROTATE_90 || + iter->rotation() == gfx::Display::ROTATE_270) { + size_in_pixel = gfx::Size(size_in_pixel.height(), size_in_pixel.width()); + } + width = std::max(size_in_pixel.width(), width); + height = std::max(size_in_pixel.height(), height); + } + return gfx::Size(width, height); +} + } // namespace ash |