OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_ | 5 #ifndef ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_ |
6 #define ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_ | 6 #define ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "ash/display/display_controller.h" | 9 #include "ash/display/display_controller.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
16 #include "base/timer/timer.h" | 16 #include "base/timer/timer.h" |
17 #include "ui/compositor/layer.h" | 17 #include "ui/compositor/layer.h" |
18 #include "ui/gfx/image/image_skia.h" | 18 #include "ui/gfx/image/image_skia.h" |
19 | 19 |
20 typedef unsigned int SkColor; | 20 typedef unsigned int SkColor; |
21 | 21 |
22 namespace aura { | 22 namespace aura { |
23 class Window; | 23 class Window; |
24 } | 24 } |
25 | 25 |
26 namespace ash { | 26 namespace ash { |
27 | 27 |
28 // -1 | |
Daniel Erat
2014/04/14 15:26:15
either turn this comment into a sentence or delete
Alexander Alekseev
2014/04/15 01:57:16
Done.
| |
29 extern const int ASH_EXPORT kInvalidResourceID; | |
Daniel Erat
2014/04/14 15:26:15
this name is too generic to be at the top level of
Alexander Alekseev
2014/04/15 01:57:16
Done.
| |
30 | |
28 enum WallpaperLayout { | 31 enum WallpaperLayout { |
29 // Center the wallpaper on the desktop without scaling it. The wallpaper | 32 // Center the wallpaper on the desktop without scaling it. The wallpaper |
30 // may be cropped. | 33 // may be cropped. |
31 WALLPAPER_LAYOUT_CENTER, | 34 WALLPAPER_LAYOUT_CENTER, |
32 // Scale the wallpaper (while preserving its aspect ratio) to cover the | 35 // Scale the wallpaper (while preserving its aspect ratio) to cover the |
33 // desktop; the wallpaper may be cropped. | 36 // desktop; the wallpaper may be cropped. |
34 WALLPAPER_LAYOUT_CENTER_CROPPED, | 37 WALLPAPER_LAYOUT_CENTER_CROPPED, |
35 // Scale the wallpaper (without preserving its aspect ratio) to match the | 38 // Scale the wallpaper (without preserving its aspect ratio) to match the |
36 // desktop's size. | 39 // desktop's size. |
37 WALLPAPER_LAYOUT_STRETCH, | 40 WALLPAPER_LAYOUT_STRETCH, |
38 // Tile the wallpaper over the background without scaling it. | 41 // Tile the wallpaper over the background without scaling it. |
39 WALLPAPER_LAYOUT_TILE, | 42 WALLPAPER_LAYOUT_TILE, |
43 // This is a special value for WallpaperIsAlreadyLoaded() | |
44 // meaning "do not compare layouts". | |
45 WALLPAPER_LAYOUT_UNKNOWN, | |
Daniel Erat
2014/04/14 15:26:15
please don't add a special-purpose value like this
Alexander Alekseev
2014/04/15 01:57:16
Done.
| |
40 }; | 46 }; |
41 | 47 |
42 const SkColor kLoginWallpaperColor = 0xFEFEFE; | 48 const SkColor kLoginWallpaperColor = 0xFEFEFE; |
43 | 49 |
44 class DesktopBackgroundControllerObserver; | 50 class DesktopBackgroundControllerObserver; |
45 class WallpaperResizer; | 51 class WallpaperResizer; |
46 | 52 |
47 // Updates background layer if necessary. | 53 // Updates background layer if necessary. |
48 class ASH_EXPORT DesktopBackgroundController | 54 class ASH_EXPORT DesktopBackgroundController |
49 : public DisplayController::Observer { | 55 : public DisplayController::Observer { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
101 | 107 |
102 // Overrides DisplayController::Observer: | 108 // Overrides DisplayController::Observer: |
103 virtual void OnDisplayConfigurationChanged() OVERRIDE; | 109 virtual void OnDisplayConfigurationChanged() OVERRIDE; |
104 | 110 |
105 // Returns the maximum size of all displays combined in native | 111 // Returns the maximum size of all displays combined in native |
106 // resolutions. Note that this isn't the bounds of the display who | 112 // resolutions. Note that this isn't the bounds of the display who |
107 // has maximum resolutions. Instead, this returns the size of the | 113 // has maximum resolutions. Instead, this returns the size of the |
108 // maximum width of all displays, and the maximum height of all displays. | 114 // maximum width of all displays, and the maximum height of all displays. |
109 static gfx::Size GetMaxDisplaySizeInNative(); | 115 static gfx::Size GetMaxDisplaySizeInNative(); |
110 | 116 |
117 // Returns true if the specified wallpaper is already stored | |
118 // in |current_wallpaper_|. | |
119 // If |image| is NULL, resource_id is compared. | |
120 // If |layout| == WALLPAPER_LAYOUT_UNKNOWN, layout is ignored. | |
121 bool WallpaperIsAlreadyLoaded(const gfx::ImageSkia* image, | |
122 int resource_id, | |
123 WallpaperLayout layout) const; | |
124 | |
111 private: | 125 private: |
112 friend class DesktopBackgroundControllerTest; | 126 friend class DesktopBackgroundControllerTest; |
113 // friend class chromeos::WallpaperManagerBrowserTestDefaultWallpaper; | 127 // friend class chromeos::WallpaperManagerBrowserTestDefaultWallpaper; |
114 FRIEND_TEST_ALL_PREFIXES(DesktopBackgroundControllerTest, GetMaxDisplaySize); | 128 FRIEND_TEST_ALL_PREFIXES(DesktopBackgroundControllerTest, GetMaxDisplaySize); |
115 | 129 |
116 // Returns true if the specified wallpaper is already stored | |
117 // in |current_wallpaper_|. | |
118 // If |image| is NULL, resource_id is compared. | |
119 bool WallpaperIsAlreadyLoaded(const gfx::ImageSkia* image, | |
120 int resource_id, | |
121 WallpaperLayout layout) const; | |
122 | |
123 // Creates view for all root windows, or notifies them to repaint if they | 130 // Creates view for all root windows, or notifies them to repaint if they |
124 // already exist. | 131 // already exist. |
125 void SetDesktopBackgroundImageMode(); | 132 void SetDesktopBackgroundImageMode(); |
126 | 133 |
127 // Creates and adds component for current mode (either Widget or Layer) to | 134 // Creates and adds component for current mode (either Widget or Layer) to |
128 // |root_window|. | 135 // |root_window|. |
129 void InstallDesktopController(aura::Window* root_window); | 136 void InstallDesktopController(aura::Window* root_window); |
130 | 137 |
131 // Creates and adds component for current mode (either Widget or Layer) to | 138 // Creates and adds component for current mode (either Widget or Layer) to |
132 // all root windows. | 139 // all root windows. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 base::OneShotTimer<DesktopBackgroundController> timer_; | 173 base::OneShotTimer<DesktopBackgroundController> timer_; |
167 | 174 |
168 int wallpaper_reload_delay_; | 175 int wallpaper_reload_delay_; |
169 | 176 |
170 DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundController); | 177 DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundController); |
171 }; | 178 }; |
172 | 179 |
173 } // namespace ash | 180 } // namespace ash |
174 | 181 |
175 #endif // ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_ | 182 #endif // ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_ |
OLD | NEW |