OLD | NEW |
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" |
(...skipping 22 matching lines...) Expand all Loading... |
33 WallpaperResizer(const gfx::ImageSkia& image, | 33 WallpaperResizer(const gfx::ImageSkia& image, |
34 const gfx::Size& target_size, | 34 const gfx::Size& target_size, |
35 WallpaperLayout layout); | 35 WallpaperLayout layout); |
36 | 36 |
37 ~WallpaperResizer(); | 37 ~WallpaperResizer(); |
38 | 38 |
39 const gfx::ImageSkia& image() const { return image_; } | 39 const gfx::ImageSkia& image() const { return image_; } |
40 uint32_t original_image_id() const { return original_image_id_; } | 40 uint32_t original_image_id() const { return original_image_id_; } |
41 WallpaperLayout layout() const { return layout_; } | 41 WallpaperLayout layout() const { return layout_; } |
42 | 42 |
| 43 int resource_id() const { return resource_id_; } |
| 44 |
43 // Called on the UI thread to run Resize() on the worker pool and post an | 45 // Called on the UI thread to run Resize() on the worker pool and post an |
44 // OnResizeFinished() task back to the UI thread on completion. | 46 // OnResizeFinished() task back to the UI thread on completion. |
45 void StartResize(); | 47 void StartResize(); |
46 | 48 |
47 // Add/Remove observers. | 49 // Add/Remove observers. |
48 void AddObserver(WallpaperResizerObserver* observer); | 50 void AddObserver(WallpaperResizerObserver* observer); |
49 void RemoveObserver(WallpaperResizerObserver* observer); | 51 void RemoveObserver(WallpaperResizerObserver* observer); |
50 | 52 |
51 private: | 53 private: |
52 // Copies |resized_bitmap| to |image_| and notifies observers after Resize() | 54 // Copies |resized_bitmap| to |image_| and notifies observers after Resize() |
53 // has finished running. | 55 // has finished running. |
54 void OnResizeFinished(SkBitmap* resized_bitmap); | 56 void OnResizeFinished(SkBitmap* resized_bitmap); |
55 | 57 |
56 ObserverList<WallpaperResizerObserver> observers_; | 58 ObserverList<WallpaperResizerObserver> observers_; |
57 | 59 |
58 // Image that should currently be used for wallpaper. It initially | 60 // Image that should currently be used for wallpaper. It initially |
59 // contains the original image and is updated to contain the resized | 61 // contains the original image and is updated to contain the resized |
60 // image by OnResizeFinished(). | 62 // image by OnResizeFinished(). |
61 gfx::ImageSkia image_; | 63 gfx::ImageSkia image_; |
62 | 64 |
63 // Unique identifier corresponding to the original (i.e. pre-resize) |image_|. | 65 // Unique identifier corresponding to the original (i.e. pre-resize) |image_|. |
64 uint32_t original_image_id_; | 66 uint32_t original_image_id_; |
65 | 67 |
| 68 // -1 if image was not obtained from resources. |
| 69 const int resource_id_; |
| 70 |
66 gfx::Size target_size_; | 71 gfx::Size target_size_; |
67 | 72 |
68 WallpaperLayout layout_; | 73 WallpaperLayout layout_; |
69 | 74 |
70 base::WeakPtrFactory<WallpaperResizer> weak_ptr_factory_; | 75 base::WeakPtrFactory<WallpaperResizer> weak_ptr_factory_; |
71 | 76 |
72 DISALLOW_COPY_AND_ASSIGN(WallpaperResizer); | 77 DISALLOW_COPY_AND_ASSIGN(WallpaperResizer); |
73 }; | 78 }; |
74 | 79 |
75 } // namespace ash | 80 } // namespace ash |
76 | 81 |
77 | 82 |
78 #endif // ASH_DESKTOP_BACKGROUND_DESKTOP_WALLPAPER_RESIZER_H_ | 83 #endif // ASH_DESKTOP_BACKGROUND_DESKTOP_WALLPAPER_RESIZER_H_ |
OLD | NEW |