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

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

Issue 236013002: Apply default wallpaper from customization manifest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove wallpaper URL from ServicesCustomizationDocumentTest. 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
98 // static 96 // static
99 uint32_t WallpaperResizer::GetImageId(const gfx::ImageSkia& image) { 97 uint32_t WallpaperResizer::GetImageId(const gfx::ImageSkia& image) {
100 const gfx::ImageSkiaRep& image_rep = image.GetRepresentation(1.0f); 98 const gfx::ImageSkiaRep& image_rep = image.GetRepresentation(1.0f);
101 return image_rep.is_null() ? 0 : image_rep.sk_bitmap().getGenerationID(); 99 return image_rep.is_null() ? 0 : image_rep.sk_bitmap().getGenerationID();
102 } 100 }
103 101
104 WallpaperResizer::WallpaperResizer(int image_resource_id, 102 WallpaperResizer::WallpaperResizer(int image_resource_id,
105 const gfx::Size& target_size, 103 const gfx::Size& target_size,
106 WallpaperLayout layout) 104 WallpaperLayout layout)
107 : image_(*(ui::ResourceBundle::GetSharedInstance() 105 : image_(*(ui::ResourceBundle::GetSharedInstance()
108 .GetImageNamed(image_resource_id) 106 .GetImageNamed(image_resource_id)
109 .ToImageSkia())), 107 .ToImageSkia())),
110 original_image_id_(GetImageId(image_)), 108 original_image_id_(GetImageId(image_)),
111 resource_id_(image_resource_id), 109 resource_id_(image_resource_id),
112 target_size_(target_size), 110 target_size_(target_size),
113 layout_(layout), 111 layout_(layout),
114 weak_ptr_factory_(this) { 112 weak_ptr_factory_(this) {
115 image_.MakeThreadSafe(); 113 image_.MakeThreadSafe();
116 } 114 }
117 115
118 WallpaperResizer::WallpaperResizer(const gfx::ImageSkia& image, 116 WallpaperResizer::WallpaperResizer(const gfx::ImageSkia& image,
119 const gfx::Size& target_size, 117 const gfx::Size& target_size,
120 WallpaperLayout layout) 118 WallpaperLayout layout)
121 : image_(image), 119 : image_(image),
122 original_image_id_(GetImageId(image_)), 120 original_image_id_(GetImageId(image_)),
123 resource_id_(kInvalidResourceID), 121 resource_id_(DesktopBackgroundController::kInvalidResourceID),
124 target_size_(target_size), 122 target_size_(target_size),
125 layout_(layout), 123 layout_(layout),
126 weak_ptr_factory_(this) { 124 weak_ptr_factory_(this) {
127 image_.MakeThreadSafe(); 125 image_.MakeThreadSafe();
128 } 126 }
129 127
130 WallpaperResizer::~WallpaperResizer() { 128 WallpaperResizer::~WallpaperResizer() {
131 } 129 }
132 130
133 void WallpaperResizer::StartResize() { 131 void WallpaperResizer::StartResize() {
(...skipping 20 matching lines...) Expand all
154 } 152 }
155 153
156 void WallpaperResizer::OnResizeFinished(SkBitmap* resized_bitmap) { 154 void WallpaperResizer::OnResizeFinished(SkBitmap* resized_bitmap) {
157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 155 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
158 image_ = gfx::ImageSkia::CreateFrom1xBitmap(*resized_bitmap); 156 image_ = gfx::ImageSkia::CreateFrom1xBitmap(*resized_bitmap);
159 FOR_EACH_OBSERVER(WallpaperResizerObserver, observers_, 157 FOR_EACH_OBSERVER(WallpaperResizerObserver, observers_,
160 OnWallpaperResized()); 158 OnWallpaperResized());
161 } 159 }
162 160
163 } // namespace ash 161 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698