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

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

Issue 215293003: Move all wallpaper file loading and decoding from DesktopBackgroundController to WallpaperManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Call WM::SetDefaultWallpaper() from ShellBrowserMainParts::PreMainMessageLoopRun(). Created 6 years, 8 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
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 #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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } 86 }
87 } 87 }
88 } 88 }
89 89
90 *resized_bitmap_out = new_bitmap; 90 *resized_bitmap_out = new_bitmap;
91 resized_bitmap_out->setImmutable(); 91 resized_bitmap_out->setImmutable();
92 } 92 }
93 93
94 } // namespace 94 } // namespace
95 95
96 const int kInvalidResourceID = -1;
97
96 // static 98 // static
97 uint32_t WallpaperResizer::GetImageId(const gfx::ImageSkia& image) { 99 uint32_t WallpaperResizer::GetImageId(const gfx::ImageSkia& image) {
98 const gfx::ImageSkiaRep& image_rep = image.GetRepresentation(1.0f); 100 const gfx::ImageSkiaRep& image_rep = image.GetRepresentation(1.0f);
99 return image_rep.is_null() ? 0 : image_rep.sk_bitmap().getGenerationID(); 101 return image_rep.is_null() ? 0 : image_rep.sk_bitmap().getGenerationID();
100 } 102 }
101 103
102 WallpaperResizer::WallpaperResizer(int image_resource_id, 104 WallpaperResizer::WallpaperResizer(int image_resource_id,
103 const gfx::Size& target_size, 105 const gfx::Size& target_size,
104 WallpaperLayout layout) 106 WallpaperLayout layout)
105 : image_(*(ui::ResourceBundle::GetSharedInstance(). 107 : image_(*(ui::ResourceBundle::GetSharedInstance()
106 GetImageNamed(image_resource_id).ToImageSkia())), 108 .GetImageNamed(image_resource_id)
109 .ToImageSkia())),
107 original_image_id_(GetImageId(image_)), 110 original_image_id_(GetImageId(image_)),
111 resource_id_(image_resource_id),
108 target_size_(target_size), 112 target_size_(target_size),
109 layout_(layout), 113 layout_(layout),
110 weak_ptr_factory_(this) { 114 weak_ptr_factory_(this) {
111 image_.MakeThreadSafe(); 115 image_.MakeThreadSafe();
112 } 116 }
113 117
114 WallpaperResizer::WallpaperResizer(const gfx::ImageSkia& image, 118 WallpaperResizer::WallpaperResizer(const gfx::ImageSkia& image,
115 const gfx::Size& target_size, 119 const gfx::Size& target_size,
116 WallpaperLayout layout) 120 WallpaperLayout layout)
117 : image_(image), 121 : image_(image),
118 original_image_id_(GetImageId(image_)), 122 original_image_id_(GetImageId(image_)),
123 resource_id_(kInvalidResourceID),
119 target_size_(target_size), 124 target_size_(target_size),
120 layout_(layout), 125 layout_(layout),
121 weak_ptr_factory_(this) { 126 weak_ptr_factory_(this) {
122 image_.MakeThreadSafe(); 127 image_.MakeThreadSafe();
123 } 128 }
124 129
125 WallpaperResizer::~WallpaperResizer() { 130 WallpaperResizer::~WallpaperResizer() {
126 } 131 }
127 132
128 void WallpaperResizer::StartResize() { 133 void WallpaperResizer::StartResize() {
(...skipping 20 matching lines...) Expand all
149 } 154 }
150 155
151 void WallpaperResizer::OnResizeFinished(SkBitmap* resized_bitmap) { 156 void WallpaperResizer::OnResizeFinished(SkBitmap* resized_bitmap) {
152 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
153 image_ = gfx::ImageSkia::CreateFrom1xBitmap(*resized_bitmap); 158 image_ = gfx::ImageSkia::CreateFrom1xBitmap(*resized_bitmap);
154 FOR_EACH_OBSERVER(WallpaperResizerObserver, observers_, 159 FOR_EACH_OBSERVER(WallpaperResizerObserver, observers_,
155 OnWallpaperResized()); 160 OnWallpaperResized());
156 } 161 }
157 162
158 } // namespace ash 163 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698