diff options
author | bshe@chromium.org <bshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-20 17:17:38 +0000 |
---|---|---|
committer | bshe@chromium.org <bshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-20 17:17:38 +0000 |
commit | 0c3461ab36efb7744df197f7029d66c3170a61f3 (patch) | |
tree | 5c11004cd470a1f028548e9139738d9cd7c528fb /ash/desktop_background | |
parent | 2dca2dc97fd303df0c6a1fb11828472ef1c00428 (diff) | |
download | chromium_src-0c3461ab36efb7744df197f7029d66c3170a61f3.zip chromium_src-0c3461ab36efb7744df197f7029d66c3170a61f3.tar.gz chromium_src-0c3461ab36efb7744df197f7029d66c3170a61f3.tar.bz2 |
Remove use of index in wallpaper picker code and some refactor
BUG=141431
Review URL: https://codereview.chromium.org/11415015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168818 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/desktop_background')
6 files changed, 114 insertions, 291 deletions
diff --git a/ash/desktop_background/desktop_background_controller.cc b/ash/desktop_background/desktop_background_controller.cc index 8575c1e..9639196 100644 --- a/ash/desktop_background/desktop_background_controller.cc +++ b/ash/desktop_background/desktop_background_controller.cc @@ -18,6 +18,7 @@ #include "base/synchronization/cancellation_flag.h" #include "base/threading/worker_pool.h" #include "content/public/browser/browser_thread.h" +#include "grit/ash_wallpaper_resources.h" #include "ui/aura/root_window.h" #include "ui/aura/window.h" #include "ui/base/resource/resource_bundle.h" @@ -43,6 +44,24 @@ internal::RootWindowLayoutManager* GetRootWindowLayoutManager( } } // namespace +#if defined(GOOGLE_CHROME_BUILD) +const WallpaperInfo kDefaultLargeWallpaper = + { IDR_AURA_WALLPAPERS_2_LANDSCAPE8_LARGE, WALLPAPER_LAYOUT_CENTER_CROPPED }; +const WallpaperInfo kDefaultSmallWallpaper = + { IDR_AURA_WALLPAPERS_2_LANDSCAPE8_SMALL, WALLPAPER_LAYOUT_CENTER }; +const WallpaperInfo kGuestLargeWallpaper = + { IDR_AURA_WALLPAPERS_2_LANDSCAPE7_LARGE, WALLPAPER_LAYOUT_CENTER_CROPPED }; +const WallpaperInfo kGuestSmallWallpaper = + { IDR_AURA_WALLPAPERS_2_LANDSCAPE7_SMALL, WALLPAPER_LAYOUT_CENTER }; +#else +const WallpaperInfo kDefaultLargeWallpaper = + { IDR_AURA_WALLPAPERS_5_GRADIENT5_LARGE, WALLPAPER_LAYOUT_TILE }; +const WallpaperInfo kDefaultSmallWallpaper = + { IDR_AURA_WALLPAPERS_5_GRADIENT5_SMALL, WALLPAPER_LAYOUT_TILE }; +const WallpaperInfo kGuestLargeWallpaper = kDefaultLargeWallpaper; +const WallpaperInfo kGuestSmallWallpaper = kDefaultSmallWallpaper; +#endif + const int kSmallWallpaperMaxWidth = 1366; const int kSmallWallpaperMaxHeight = 800; const int kLargeWallpaperMaxWidth = 2560; @@ -50,52 +69,40 @@ const int kLargeWallpaperMaxHeight = 1700; // Stores the current wallpaper data. struct DesktopBackgroundController::WallpaperData { - WallpaperData(int index, WallpaperResolution resolution) - : is_default_wallpaper(true), - wallpaper_index(index), - wallpaper_layout(GetWallpaperViewInfo(index, resolution).layout), + explicit WallpaperData(const WallpaperInfo& info) + : wallpaper_info(info), wallpaper_image(*(ui::ResourceBundle::GetSharedInstance().GetImageNamed( - GetWallpaperViewInfo(index, resolution).id).ToImageSkia())) { + info.idr).ToImageSkia())) { } - WallpaperData(WallpaperLayout layout, const gfx::ImageSkia& image) - : is_default_wallpaper(false), - wallpaper_index(-1), - wallpaper_layout(layout), + WallpaperData(const WallpaperInfo& info, const gfx::ImageSkia& image) + : wallpaper_info(info), wallpaper_image(image) { } - const bool is_default_wallpaper; - const int wallpaper_index; - const WallpaperLayout wallpaper_layout; + const WallpaperInfo wallpaper_info; const gfx::ImageSkia wallpaper_image; }; -// DesktopBackgroundController::WallpaperOperation wraps background wallpaper +// DesktopBackgroundController::WallpaperLoader wraps background wallpaper // loading. -class DesktopBackgroundController::WallpaperOperation +class DesktopBackgroundController::WallpaperLoader : public base::RefCountedThreadSafe< - DesktopBackgroundController::WallpaperOperation> { + DesktopBackgroundController::WallpaperLoader> { public: - WallpaperOperation(int index, WallpaperResolution resolution) - : index_(index), - resolution_(resolution) { - } - - static void Run(scoped_refptr<WallpaperOperation> wo) { - wo->LoadingWallpaper(); + explicit WallpaperLoader(const WallpaperInfo& info) + : info_(info) { } - void LoadingWallpaper() { - if (cancel_flag_.IsSet()) - return; - wallpaper_data_.reset(new WallpaperData(index_, resolution_)); + static void LoadOnWorkerPoolThread(scoped_refptr<WallpaperLoader> wl) { + DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); + wl->LoadingWallpaper(); } void Cancel() { cancel_flag_.Set(); } - int index() const { - return index_; + int idr() const { + return info_.idr; } WallpaperData* ReleaseWallpaperData() { @@ -104,19 +111,23 @@ class DesktopBackgroundController::WallpaperOperation private: friend class base::RefCountedThreadSafe< - DesktopBackgroundController::WallpaperOperation>; + DesktopBackgroundController::WallpaperLoader>; - ~WallpaperOperation() {} + void LoadingWallpaper() { + if (cancel_flag_.IsSet()) + return; + wallpaper_data_.reset(new WallpaperData(info_)); + } + + ~WallpaperLoader() {} base::CancellationFlag cancel_flag_; scoped_ptr<WallpaperData> wallpaper_data_; - const int index_; - - const WallpaperResolution resolution_; + const WallpaperInfo info_; - DISALLOW_COPY_AND_ASSIGN(WallpaperOperation); + DISALLOW_COPY_AND_ASSIGN(WallpaperLoader); }; DesktopBackgroundController::DesktopBackgroundController() @@ -148,8 +159,8 @@ void DesktopBackgroundController::RemoveObserver( WallpaperLayout DesktopBackgroundController::GetWallpaperLayout() const { if (current_wallpaper_.get()) - return current_wallpaper_->wallpaper_layout; - return CENTER_CROPPED; + return current_wallpaper_->wallpaper_info.layout; + return WALLPAPER_LAYOUT_CENTER_CROPPED; } gfx::ImageSkia DesktopBackgroundController::GetCurrentWallpaperImage() { @@ -158,6 +169,15 @@ gfx::ImageSkia DesktopBackgroundController::GetCurrentWallpaperImage() { return GetWallpaper(); } +int DesktopBackgroundController::GetWallpaperIDR() const { + if (wallpaper_loader_.get()) + return wallpaper_loader_->idr(); + else if (current_wallpaper_.get()) + return current_wallpaper_->wallpaper_info.idr; + else + return -1; +} + void DesktopBackgroundController::OnRootWindowAdded( aura::RootWindow* root_window) { // Handle resolution change for "built-in" images." @@ -168,69 +188,30 @@ void DesktopBackgroundController::OnRootWindowAdded( // small screen. if (kSmallWallpaperMaxWidth < root_window_size.width() || kSmallWallpaperMaxHeight < root_window_size.height()) { - if (current_wallpaper_->is_default_wallpaper) { - ReloadDefaultWallpaper(); - } else { - ash::Shell::GetInstance()->user_wallpaper_delegate()-> - UpdateWallpaper(); - } + current_wallpaper_.reset(NULL); + ash::Shell::GetInstance()->user_wallpaper_delegate()-> + UpdateWallpaper(); } } InstallDesktopController(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) { - // We should not change background when index is invalid. For instance, at - // login screen or stub_user login. - if (index == GetInvalidWallpaperIndex()) { - CreateEmptyWallpaper(); - return; - } else if (index == GetSolidColorIndex()) { - SetDesktopBackgroundSolidColorMode(kLoginWallpaperColor); - return; - } - - // Prevents loading of the same wallpaper as the currently loading/loaded - // one. - if ((wallpaper_op_.get() && wallpaper_op_->index() == index) || - (current_wallpaper_.get() && - current_wallpaper_->wallpaper_index == index)) { - return; - } +void DesktopBackgroundController::SetDefaultWallpaper( + const WallpaperInfo& info) { + DCHECK_NE(GetWallpaperIDR(), info.idr); CancelPendingWallpaperOperation(); - - WallpaperResolution resolution = GetAppropriateResolution(); - - wallpaper_op_ = new WallpaperOperation(index, resolution); + wallpaper_loader_ = new WallpaperLoader(info); base::WorkerPool::PostTaskAndReply( FROM_HERE, - base::Bind(&WallpaperOperation::Run, wallpaper_op_), + base::Bind(&WallpaperLoader::LoadOnWorkerPoolThread, wallpaper_loader_), base::Bind(&DesktopBackgroundController::OnWallpaperLoadCompleted, weak_ptr_factory_.GetWeakPtr(), - wallpaper_op_), + wallpaper_loader_), true /* task_is_slow */); } -void DesktopBackgroundController::ReloadDefaultWallpaper() { - int index = current_wallpaper_->wallpaper_index; - current_wallpaper_.reset(NULL); - SetDefaultWallpaper(index); -} - void DesktopBackgroundController::SetCustomWallpaper( const gfx::ImageSkia& wallpaper, WallpaperLayout layout) { @@ -240,7 +221,8 @@ void DesktopBackgroundController::SetCustomWallpaper( return; } - current_wallpaper_.reset(new WallpaperData(layout, wallpaper)); + WallpaperInfo info = { -1, layout }; + current_wallpaper_.reset(new WallpaperData(info, wallpaper)); FOR_EACH_OBSERVER(DesktopBackgroundControllerObserver, observers_, OnWallpaperDataChanged()); SetDesktopBackgroundImageMode(); @@ -248,8 +230,8 @@ void DesktopBackgroundController::SetCustomWallpaper( void DesktopBackgroundController::CancelPendingWallpaperOperation() { // Set canceled flag of previous request to skip unneeded loading. - if (wallpaper_op_.get()) - wallpaper_op_->Cancel(); + if (wallpaper_loader_.get()) + wallpaper_loader_->Cancel(); // Cancel reply callback for previous request. weak_ptr_factory_.InvalidateWeakPtrs(); @@ -270,14 +252,14 @@ void DesktopBackgroundController::CreateEmptyWallpaper() { WallpaperResolution DesktopBackgroundController::GetAppropriateResolution() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - WallpaperResolution resolution = SMALL; + WallpaperResolution resolution = WALLPAPER_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() > kSmallWallpaperMaxWidth || root_window_size.height() > kSmallWallpaperMaxHeight) { - resolution = LARGE; + resolution = WALLPAPER_RESOLUTION_LARGE; } } return resolution; @@ -312,15 +294,15 @@ void DesktopBackgroundController::SetDesktopBackgroundImageMode() { } void DesktopBackgroundController::OnWallpaperLoadCompleted( - scoped_refptr<WallpaperOperation> wo) { - current_wallpaper_.reset(wo->ReleaseWallpaperData()); + scoped_refptr<WallpaperLoader> wl) { + current_wallpaper_.reset(wl->ReleaseWallpaperData()); FOR_EACH_OBSERVER(DesktopBackgroundControllerObserver, observers_, OnWallpaperDataChanged()); SetDesktopBackgroundImageMode(); - DCHECK(wo.get() == wallpaper_op_.get()); - wallpaper_op_ = NULL; + DCHECK(wl.get() == wallpaper_loader_.get()); + wallpaper_loader_ = NULL; } void DesktopBackgroundController::NotifyAnimationFinished() { diff --git a/ash/desktop_background/desktop_background_controller.h b/ash/desktop_background/desktop_background_controller.h index 23302c8..a93de63 100644 --- a/ash/desktop_background/desktop_background_controller.h +++ b/ash/desktop_background/desktop_background_controller.h @@ -6,7 +6,6 @@ #define ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_ #include "ash/ash_export.h" -#include "ash/desktop_background/desktop_background_resources.h" #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" @@ -24,6 +23,31 @@ class RootWindow; namespace ash { +enum WallpaperLayout { + WALLPAPER_LAYOUT_CENTER, + WALLPAPER_LAYOUT_CENTER_CROPPED, + WALLPAPER_LAYOUT_STRETCH, + WALLPAPER_LAYOUT_TILE, +}; + +enum WallpaperResolution { + WALLPAPER_RESOLUTION_LARGE, + WALLPAPER_RESOLUTION_SMALL +}; + +const SkColor kLoginWallpaperColor = 0xFEFEFE; + +// Encapsulates wallpaper infomation needed by desktop background controller. +struct ASH_EXPORT WallpaperInfo { + int idr; + WallpaperLayout layout; +}; + +ASH_EXPORT extern const WallpaperInfo kDefaultLargeWallpaper; +ASH_EXPORT extern const WallpaperInfo kDefaultSmallWallpaper; +ASH_EXPORT extern const WallpaperInfo kGuestLargeWallpaper; +ASH_EXPORT extern const WallpaperInfo kGuestSmallWallpaper; + // The width and height of small/large resolution wallpaper. When screen size is // smaller than |kSmallWallpaperMaxWidth| and |kSmallWallpaperMaxHeight|, the // small resolution wallpaper should be used. Otherwise, uses the large @@ -64,21 +88,16 @@ class ASH_EXPORT DesktopBackgroundController : public aura::WindowObserver { // is no image, e.g. background is solid color. gfx::ImageSkia GetCurrentWallpaperImage(); + // Gets the IDR of current wallpaper. Returns -1 if current wallpaper is not + // a builtin wallpaper. + int GetWallpaperIDR() const; + // 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. - void SetDefaultWallpaper(int index); - - // Forces to reload the current default wallpaper. A different resolution - // wallpaper maybe loaded. - void ReloadDefaultWallpaper(); + // Loads builtin wallpaper asynchronously and sets to current wallpaper after + // loaded. + void SetDefaultWallpaper(const WallpaperInfo& info); // Sets the user selected custom wallpaper. Called when user selected a file // from file system or changed the layout of wallpaper. @@ -116,7 +135,7 @@ class ASH_EXPORT DesktopBackgroundController : public aura::WindowObserver { private: // An operation to asynchronously loads wallpaper. - class WallpaperOperation; + class WallpaperLoader; struct WallpaperData; @@ -126,7 +145,7 @@ class ASH_EXPORT DesktopBackgroundController : public aura::WindowObserver { // Creates a new background widget and sets the background mode to image mode. // Called after wallpaper loaded successfully. - void OnWallpaperLoadCompleted(scoped_refptr<WallpaperOperation> wo); + void OnWallpaperLoadCompleted(scoped_refptr<WallpaperLoader> wl); // Adds layer with solid |color| to container |container_id| in |root_window|. ui::Layer* SetColorLayerForContainer(SkColor color, @@ -163,7 +182,7 @@ class ASH_EXPORT DesktopBackgroundController : public aura::WindowObserver { // The current wallpaper. scoped_ptr<WallpaperData> current_wallpaper_; - scoped_refptr<WallpaperOperation> wallpaper_op_; + scoped_refptr<WallpaperLoader> wallpaper_loader_; base::WeakPtrFactory<DesktopBackgroundController> weak_ptr_factory_; diff --git a/ash/desktop_background/desktop_background_resources.cc b/ash/desktop_background/desktop_background_resources.cc deleted file mode 100644 index 5d9cf28..0000000 --- a/ash/desktop_background/desktop_background_resources.cc +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ash/desktop_background/desktop_background_resources.h" - -#include "base/logging.h" -#include "base/rand_util.h" -#include "grit/ash_wallpaper_resources.h" -#include "ui/base/resource/resource_bundle.h" -#include "ui/gfx/image/image.h" - -namespace { - -// Keeps in sync (same order) with WallpaperLayout enum in header file. -const char* kWallpaperLayoutArrays[] = { - "CENTER", - "CENTER_CROPPED", - "STRETCH", - "TILE" -}; - -const ash::WallpaperInfo kDefaultWallpapers[] = { -#if defined(GOOGLE_CHROME_BUILD) - { - { - IDR_AURA_WALLPAPERS_2_LANDSCAPE7_LARGE, - ash::CENTER_CROPPED - }, - { - IDR_AURA_WALLPAPERS_2_LANDSCAPE7_SMALL, - ash::CENTER - } - }, - { - { - IDR_AURA_WALLPAPERS_2_LANDSCAPE8_LARGE, - ash::CENTER_CROPPED - }, - { - IDR_AURA_WALLPAPERS_2_LANDSCAPE8_SMALL, - ash::CENTER - } - }, -#endif - { - { - IDR_AURA_WALLPAPERS_5_GRADIENT5_LARGE, - ash::TILE - }, - { - IDR_AURA_WALLPAPERS_5_GRADIENT5_SMALL, - ash::TILE - } - } -}; - -const int kWallpaperLayoutCount = arraysize(kWallpaperLayoutArrays); -const int kDefaultWallpaperCount = arraysize(kDefaultWallpapers); -const int kInvalidWallpaperIndex = -1; -const int kSolidColorIndex = -2; - -// TODO(saintlou): These hardcoded indexes, although checked against the size -// of the array are really hacky. -#if defined(GOOGLE_CHROME_BUILD) -const int kDefaultWallpaperIndex = 1; // IDR_AURA_WALLPAPERS_2_LANDSCAPE8 -const int kGuestWallpaperIndex = 0; // IDR_AURA_WALLPAPERS_2_LANDSCAPE7 -#else -// Set default wallpaper to the grey background for faster wallpaper loading -// time in browser tests. Otherwise, some of the tests will finish before -// wallpaper loaded and cause crashes. -const int kDefaultWallpaperIndex = 0; // IDR_AURA_WALLPAPERS_5_GRADIENT5 -const int kGuestWallpaperIndex = kDefaultWallpaperIndex; -#endif - -} // namespace - -namespace ash { - -int GetDefaultWallpaperIndex() { - DCHECK(kDefaultWallpaperIndex < kDefaultWallpaperCount); - return std::min(kDefaultWallpaperIndex, kDefaultWallpaperCount - 1); -} - -int GetGuestWallpaperIndex() { - DCHECK(kGuestWallpaperIndex < kDefaultWallpaperCount); - return std::min(kGuestWallpaperIndex, kDefaultWallpaperCount - 1); -} - -int GetInvalidWallpaperIndex() { - return kInvalidWallpaperIndex; -} - -WallpaperLayout GetLayoutEnum(const std::string& layout) { - for (int i = 0; i < kWallpaperLayoutCount; i++) { - if (layout.compare(kWallpaperLayoutArrays[i]) == 0) - return static_cast<WallpaperLayout>(i); - } - // Default to use CENTER layout. - return CENTER; -} - -int GetSolidColorIndex() { - return kSolidColorIndex; -} - -int GetWallpaperCount() { - return kDefaultWallpaperCount; -} - -const WallpaperInfo& GetWallpaperInfo(int index) { - DCHECK(index >= 0 && index < kDefaultWallpaperCount); - return kDefaultWallpapers[index]; -} - -const WallpaperViewInfo& GetWallpaperViewInfo(int index, - WallpaperResolution resolution) { - DCHECK(index >= 0 && index < kDefaultWallpaperCount); - if (resolution == SMALL) - return kDefaultWallpapers[index].small_wallpaper; - else - return kDefaultWallpapers[index].large_wallpaper; -} - -} // namespace ash diff --git a/ash/desktop_background/desktop_background_resources.h b/ash/desktop_background/desktop_background_resources.h deleted file mode 100644 index fe9805f..0000000 --- a/ash/desktop_background/desktop_background_resources.h +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_RESOURCES_H_ -#define ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_RESOURCES_H_ - -#include <string> - -#include "ash/ash_export.h" -#include "third_party/skia/include/core/SkColor.h" - -namespace ash { - -enum WallpaperLayout { - CENTER, - CENTER_CROPPED, - STRETCH, - 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_wallpaper; - WallpaperViewInfo small_wallpaper; -}; - -const SkColor kLoginWallpaperColor = 0xFEFEFE; - -ASH_EXPORT int GetDefaultWallpaperIndex(); -ASH_EXPORT int GetGuestWallpaperIndex(); -ASH_EXPORT int GetInvalidWallpaperIndex(); -ASH_EXPORT WallpaperLayout GetLayoutEnum(const std::string& layout); -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 - -#endif // ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_RESOURCES_H_ diff --git a/ash/desktop_background/desktop_background_view.cc b/ash/desktop_background/desktop_background_view.cc index 99b22dd..86175a4 100644 --- a/ash/desktop_background/desktop_background_view.cc +++ b/ash/desktop_background/desktop_background_view.cc @@ -128,8 +128,8 @@ void DesktopBackgroundView::OnPaint(gfx::Canvas* canvas) { WallpaperLayout wallpaper_layout = controller->GetWallpaperLayout(); gfx::Rect wallpaper_rect(0, 0, wallpaper.width(), wallpaper.height()); - if (wallpaper_layout == ash::CENTER_CROPPED && wallpaper.width() > width() - && wallpaper.height() > height()) { + if (wallpaper_layout == WALLPAPER_LAYOUT_CENTER_CROPPED && + wallpaper.width() > width() && wallpaper.height() > height()) { // The dimension with the smallest ratio must be cropped, the other one // is preserved. Both are set in gfx::Size cropped_size. double horizontal_ratio = static_cast<double>(width()) / @@ -154,9 +154,9 @@ void DesktopBackgroundView::OnPaint(gfx::Canvas* canvas) { wallpaper_cropped_rect.width(), wallpaper_cropped_rect.height(), 0, 0, width(), height(), true); - } else if (wallpaper_layout == ash::TILE) { + } else if (wallpaper_layout == WALLPAPER_LAYOUT_TILE) { canvas->TileImageInt(wallpaper, 0, 0, width(), height()); - } else if (wallpaper_layout == ash::STRETCH) { + } else if (wallpaper_layout == WALLPAPER_LAYOUT_STRETCH) { // This is generally not recommended as it may show artifacts. canvas->DrawImageInt(wallpaper, 0, 0, wallpaper.width(), wallpaper.height(), 0, 0, width(), height(), true); diff --git a/ash/desktop_background/desktop_background_view.h b/ash/desktop_background/desktop_background_view.h index 3793496..06d4dc4 100644 --- a/ash/desktop_background/desktop_background_view.h +++ b/ash/desktop_background/desktop_background_view.h @@ -5,7 +5,6 @@ #ifndef ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_VIEW_H_ #define ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_VIEW_H_ -#include "ash/desktop_background/desktop_background_resources.h" #include "ui/gfx/image/image_skia.h" #include "ui/views/context_menu_controller.h" #include "ui/views/view.h" |