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

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: After-review. 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 static_cast<double>(new_height) / horizontal_ratio)); 77 static_cast<double>(new_height) / horizontal_ratio));
78 } 78 }
79 wallpaper_rect.ClampToCenteredSize(cropped_size); 79 wallpaper_rect.ClampToCenteredSize(cropped_size);
80 SkBitmap sub_image; 80 SkBitmap sub_image;
81 orig_bitmap.extractSubset(&sub_image, 81 orig_bitmap.extractSubset(&sub_image,
82 gfx::RectToSkIRect(wallpaper_rect)); 82 gfx::RectToSkIRect(wallpaper_rect));
83 new_bitmap = skia::ImageOperations::Resize( 83 new_bitmap = skia::ImageOperations::Resize(
84 sub_image, skia::ImageOperations::RESIZE_LANCZOS3, 84 sub_image, skia::ImageOperations::RESIZE_LANCZOS3,
85 new_width, new_height); 85 new_width, new_height);
86 } 86 }
87 break;
88 case WALLPAPER_LAYOUT_UNKNOWN:
89 NOTREACHED();
87 } 90 }
88 } 91 }
89 92
90 *resized_bitmap_out = new_bitmap; 93 *resized_bitmap_out = new_bitmap;
91 resized_bitmap_out->setImmutable(); 94 resized_bitmap_out->setImmutable();
92 } 95 }
93 96
94 } // namespace 97 } // namespace
95 98
96 const int kInvalidResourceID = -1;
97
98 // static 99 // static
99 uint32_t WallpaperResizer::GetImageId(const gfx::ImageSkia& image) { 100 uint32_t WallpaperResizer::GetImageId(const gfx::ImageSkia& image) {
100 const gfx::ImageSkiaRep& image_rep = image.GetRepresentation(1.0f); 101 const gfx::ImageSkiaRep& image_rep = image.GetRepresentation(1.0f);
101 return image_rep.is_null() ? 0 : image_rep.sk_bitmap().getGenerationID(); 102 return image_rep.is_null() ? 0 : image_rep.sk_bitmap().getGenerationID();
102 } 103 }
103 104
104 WallpaperResizer::WallpaperResizer(int image_resource_id, 105 WallpaperResizer::WallpaperResizer(int image_resource_id,
105 const gfx::Size& target_size, 106 const gfx::Size& target_size,
106 WallpaperLayout layout) 107 WallpaperLayout layout)
107 : image_(*(ui::ResourceBundle::GetSharedInstance() 108 : image_(*(ui::ResourceBundle::GetSharedInstance()
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 155 }
155 156
156 void WallpaperResizer::OnResizeFinished(SkBitmap* resized_bitmap) { 157 void WallpaperResizer::OnResizeFinished(SkBitmap* resized_bitmap) {
157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 158 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
158 image_ = gfx::ImageSkia::CreateFrom1xBitmap(*resized_bitmap); 159 image_ = gfx::ImageSkia::CreateFrom1xBitmap(*resized_bitmap);
159 FOR_EACH_OBSERVER(WallpaperResizerObserver, observers_, 160 FOR_EACH_OBSERVER(WallpaperResizerObserver, observers_,
160 OnWallpaperResized()); 161 OnWallpaperResized());
161 } 162 }
162 163
163 } // namespace ash 164 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698