Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: ash/desktop_background/wallpaper_resizer.h

Issue 17502005: Revert r207560 and r207566 to reland r207511. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add more SupportsMultipleDisplays checks Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_WALLPAPER_RESIZER_H_ 5 #ifndef ASH_DESKTOP_BACKGROUND_DESKTOP_WALLPAPER_RESIZER_H_
6 #define ASH_DESKTOP_BACKGROUND_DESKTOP_WALLPAPER_RESIZER_H_ 6 #define ASH_DESKTOP_BACKGROUND_DESKTOP_WALLPAPER_RESIZER_H_
7 7
8 #include "ash/ash_export.h" 8 #include "ash/ash_export.h"
9 #include "ash/desktop_background/desktop_background_controller.h" 9 #include "ash/desktop_background/desktop_background_controller.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/observer_list.h" 11 #include "base/observer_list.h"
12 #include "skia/ext/image_operations.h" 12 #include "skia/ext/image_operations.h"
13 #include "third_party/skia/include/core/SkBitmap.h"
13 #include "ui/gfx/image/image_skia.h" 14 #include "ui/gfx/image/image_skia.h"
14 #include "ui/gfx/size.h" 15 #include "ui/gfx/size.h"
15 16
16 namespace ash { 17 namespace ash {
17 18
18 class WallpaperResizerObserver; 19 class WallpaperResizerObserver;
19 20
20 // Stores the current wallpaper data and resize it to |target_size| if needed. 21 // Stores the current wallpaper data and resize it to |target_size| if needed.
21 class ASH_EXPORT WallpaperResizer { 22 class ASH_EXPORT WallpaperResizer {
22 public: 23 public:
23 WallpaperResizer(const WallpaperInfo& info, const gfx::Size& target_size); 24 WallpaperResizer(int image_resource_id,
25 const gfx::Size& target_size,
26 WallpaperLayout layout);
24 27
25 WallpaperResizer(const WallpaperInfo& info, const gfx::Size& target_size, 28 WallpaperResizer(const gfx::ImageSkia& image,
26 const gfx::ImageSkia& image); 29 const gfx::Size& target_size,
30 WallpaperLayout layout);
27 31
28 virtual ~WallpaperResizer(); 32 ~WallpaperResizer();
29
30 const WallpaperInfo& wallpaper_info() const { return wallpaper_info_; }
31 33
32 const gfx::ImageSkia& wallpaper_image() const { return wallpaper_image_; } 34 const gfx::ImageSkia& wallpaper_image() const { return wallpaper_image_; }
35 const WallpaperLayout layout() const { return layout_; }
33 36
34 // Starts resize task on UI thread. It posts task to worker pool. 37 // Called on the UI thread to run Resize() on the worker pool and post an
38 // OnResizeFinished() task back to the UI thread on completion.
35 void StartResize(); 39 void StartResize();
36 40
37 // Add/Remove observers. 41 // Add/Remove observers.
38 void AddObserver(WallpaperResizerObserver* observer); 42 void AddObserver(WallpaperResizerObserver* observer);
39 void RemoveObserver(WallpaperResizerObserver* observer); 43 void RemoveObserver(WallpaperResizerObserver* observer);
40 44
41 private: 45 private:
42 // Replaces the orginal uncompressed wallpaper to |resized_wallpaper|. 46 // Copies |resized_bitmap| to |wallpaper_image_| and notifies observers
43 void OnResizeFinished(const SkBitmap& resized_wallpaper); 47 // after Resize() has finished running.
48 void OnResizeFinished(SkBitmap* resized_bitmap);
44 49
45 ObserverList<WallpaperResizerObserver> observers_; 50 ObserverList<WallpaperResizerObserver> observers_;
46 51
47 const WallpaperInfo wallpaper_info_; 52 // Image that should currently be used for wallpaper. It initially
53 // contains the original image and is updated to contain the resized
54 // image by OnResizeFinished().
55 gfx::ImageSkia wallpaper_image_;
48 56
49 gfx::Size target_size_; 57 gfx::Size target_size_;
50 58
51 gfx::ImageSkia wallpaper_image_; 59 WallpaperLayout layout_;
52 60
53 base::WeakPtrFactory<WallpaperResizer> weak_ptr_factory_; 61 base::WeakPtrFactory<WallpaperResizer> weak_ptr_factory_;
54 62
55 DISALLOW_COPY_AND_ASSIGN(WallpaperResizer); 63 DISALLOW_COPY_AND_ASSIGN(WallpaperResizer);
56 }; 64 };
57 65
58 } // namespace ash 66 } // namespace ash
59 67
60 68
61 #endif // ASH_DESKTOP_BACKGROUND_DESKTOP_WALLPAPER_RESIZER_H_ 69 #endif // ASH_DESKTOP_BACKGROUND_DESKTOP_WALLPAPER_RESIZER_H_
OLDNEW
« no previous file with comments | « ash/desktop_background/desktop_background_controller_unittest.cc ('k') | ash/desktop_background/wallpaper_resizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698