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 #include "ash/desktop_background/wallpaper_resizer.h" | 5 #include "ash/desktop_background/wallpaper_resizer.h" |
6 | 6 |
7 #include "ash/desktop_background/wallpaper_resizer_observer.h" | 7 #include "ash/desktop_background/wallpaper_resizer_observer.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/threading/sequenced_worker_pool.h" | 10 #include "base/threading/sequenced_worker_pool.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 | 95 |
96 // static | 96 // static |
97 uint32_t WallpaperResizer::GetImageId(const gfx::ImageSkia& image) { | 97 uint32_t WallpaperResizer::GetImageId(const gfx::ImageSkia& image) { |
98 const gfx::ImageSkiaRep& image_rep = image.GetRepresentation(1.0f); | 98 const gfx::ImageSkiaRep& image_rep = image.GetRepresentation(1.0f); |
99 return image_rep.is_null() ? 0 : image_rep.sk_bitmap().getGenerationID(); | 99 return image_rep.is_null() ? 0 : image_rep.sk_bitmap().getGenerationID(); |
100 } | 100 } |
101 | 101 |
102 WallpaperResizer::WallpaperResizer(int image_resource_id, | 102 WallpaperResizer::WallpaperResizer(int image_resource_id, |
103 const gfx::Size& target_size, | 103 const gfx::Size& target_size, |
104 WallpaperLayout layout) | 104 WallpaperLayout layout) |
105 : image_(*(ui::ResourceBundle::GetSharedInstance(). | 105 : image_(*(ui::ResourceBundle::GetSharedInstance() |
106 GetImageNamed(image_resource_id).ToImageSkia())), | 106 .GetImageNamed(image_resource_id) |
107 .ToImageSkia())), | |
107 original_image_id_(GetImageId(image_)), | 108 original_image_id_(GetImageId(image_)), |
109 resource_id_(image_resource_id), | |
108 target_size_(target_size), | 110 target_size_(target_size), |
109 layout_(layout), | 111 layout_(layout), |
110 weak_ptr_factory_(this) { | 112 weak_ptr_factory_(this) { |
111 image_.MakeThreadSafe(); | 113 image_.MakeThreadSafe(); |
112 } | 114 } |
113 | 115 |
114 WallpaperResizer::WallpaperResizer(const gfx::ImageSkia& image, | 116 WallpaperResizer::WallpaperResizer(const gfx::ImageSkia& image, |
115 const gfx::Size& target_size, | 117 const gfx::Size& target_size, |
116 WallpaperLayout layout) | 118 WallpaperLayout layout) |
117 : image_(image), | 119 : image_(image), |
118 original_image_id_(GetImageId(image_)), | 120 original_image_id_(GetImageId(image_)), |
121 resource_id_(-1), | |
bshe
2014/04/07 15:49:16
nit: could you replace -1 with something like:
con
Alexander Alekseev
2014/04/08 13:18:49
Done.
| |
119 target_size_(target_size), | 122 target_size_(target_size), |
120 layout_(layout), | 123 layout_(layout), |
121 weak_ptr_factory_(this) { | 124 weak_ptr_factory_(this) { |
122 image_.MakeThreadSafe(); | 125 image_.MakeThreadSafe(); |
123 } | 126 } |
124 | 127 |
125 WallpaperResizer::~WallpaperResizer() { | 128 WallpaperResizer::~WallpaperResizer() { |
126 } | 129 } |
127 | 130 |
128 void WallpaperResizer::StartResize() { | 131 void WallpaperResizer::StartResize() { |
(...skipping 20 matching lines...) Expand all Loading... | |
149 } | 152 } |
150 | 153 |
151 void WallpaperResizer::OnResizeFinished(SkBitmap* resized_bitmap) { | 154 void WallpaperResizer::OnResizeFinished(SkBitmap* resized_bitmap) { |
152 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 155 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
153 image_ = gfx::ImageSkia::CreateFrom1xBitmap(*resized_bitmap); | 156 image_ = gfx::ImageSkia::CreateFrom1xBitmap(*resized_bitmap); |
154 FOR_EACH_OBSERVER(WallpaperResizerObserver, observers_, | 157 FOR_EACH_OBSERVER(WallpaperResizerObserver, observers_, |
155 OnWallpaperResized()); | 158 OnWallpaperResized()); |
156 } | 159 } |
157 | 160 |
158 } // namespace ash | 161 } // namespace ash |
OLD | NEW |