| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/wallpaper/wallpaper_manager_base.h" | 5 #include "components/wallpaper/wallpaper_manager_base.h" |
| 6 | 6 |
| 7 #include <numeric> | 7 #include <numeric> |
| 8 #include <vector> | 8 #include <vector> |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 return; | 907 return; |
| 908 } | 908 } |
| 909 | 909 |
| 910 wallpaper.image().EnsureRepsForSupportedScales(); | 910 wallpaper.image().EnsureRepsForSupportedScales(); |
| 911 scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper.image().DeepCopy()); | 911 scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper.image().DeepCopy()); |
| 912 | 912 |
| 913 scoped_ptr<bool> success(new bool(false)); | 913 scoped_ptr<bool> success(new bool(false)); |
| 914 scoped_ptr<gfx::ImageSkia> small_wallpaper_image(new gfx::ImageSkia); | 914 scoped_ptr<gfx::ImageSkia> small_wallpaper_image(new gfx::ImageSkia); |
| 915 scoped_ptr<gfx::ImageSkia> large_wallpaper_image(new gfx::ImageSkia); | 915 scoped_ptr<gfx::ImageSkia> large_wallpaper_image(new gfx::ImageSkia); |
| 916 | 916 |
| 917 // TODO(bshe): This may break if RawImage becomes RefCountedMemory. | 917 // TODO(bshe): This may break if Bytes becomes RefCountedMemory. |
| 918 base::Closure resize_closure = base::Bind( | 918 base::Closure resize_closure = base::Bind( |
| 919 &WallpaperManagerBase::ResizeCustomizedDefaultWallpaper, | 919 &WallpaperManagerBase::ResizeCustomizedDefaultWallpaper, |
| 920 base::Passed(&deep_copy), wallpaper.raw_image(), | 920 base::Passed(&deep_copy), wallpaper.image_bytes(), |
| 921 base::Unretained(rescaled_files.get()), base::Unretained(success.get()), | 921 base::Unretained(rescaled_files.get()), base::Unretained(success.get()), |
| 922 base::Unretained(small_wallpaper_image.get()), | 922 base::Unretained(small_wallpaper_image.get()), |
| 923 base::Unretained(large_wallpaper_image.get())); | 923 base::Unretained(large_wallpaper_image.get())); |
| 924 base::Closure on_resized_closure = base::Bind( | 924 base::Closure on_resized_closure = base::Bind( |
| 925 &WallpaperManagerBase::OnCustomizedDefaultWallpaperResized, | 925 &WallpaperManagerBase::OnCustomizedDefaultWallpaperResized, |
| 926 weak_factory_.GetWeakPtr(), wallpaper_url, | 926 weak_factory_.GetWeakPtr(), wallpaper_url, |
| 927 base::Passed(std::move(rescaled_files)), base::Passed(std::move(success)), | 927 base::Passed(std::move(rescaled_files)), base::Passed(std::move(success)), |
| 928 base::Passed(std::move(small_wallpaper_image)), | 928 base::Passed(std::move(small_wallpaper_image)), |
| 929 base::Passed(std::move(large_wallpaper_image))); | 929 base::Passed(std::move(large_wallpaper_image))); |
| 930 | 930 |
| 931 if (!task_runner_->PostTaskAndReply(FROM_HERE, resize_closure, | 931 if (!task_runner_->PostTaskAndReply(FROM_HERE, resize_closure, |
| 932 on_resized_closure)) { | 932 on_resized_closure)) { |
| 933 LOG(WARNING) << "Failed to start Customized Wallpaper resize."; | 933 LOG(WARNING) << "Failed to start Customized Wallpaper resize."; |
| 934 } | 934 } |
| 935 } | 935 } |
| 936 | 936 |
| 937 void WallpaperManagerBase::ResizeCustomizedDefaultWallpaper( | 937 void WallpaperManagerBase::ResizeCustomizedDefaultWallpaper( |
| 938 scoped_ptr<gfx::ImageSkia> image, | 938 scoped_ptr<gfx::ImageSkia> image, |
| 939 const user_manager::UserImage::RawImage& raw_image, | 939 const user_manager::UserImage::Bytes& image_bytes, |
| 940 const CustomizedWallpaperRescaledFiles* rescaled_files, | 940 const CustomizedWallpaperRescaledFiles* rescaled_files, |
| 941 bool* success, | 941 bool* success, |
| 942 gfx::ImageSkia* small_wallpaper_image, | 942 gfx::ImageSkia* small_wallpaper_image, |
| 943 gfx::ImageSkia* large_wallpaper_image) { | 943 gfx::ImageSkia* large_wallpaper_image) { |
| 944 *success = true; | 944 *success = true; |
| 945 | 945 |
| 946 *success &= ResizeAndSaveWallpaper( | 946 *success &= ResizeAndSaveWallpaper( |
| 947 *image, rescaled_files->path_rescaled_small(), WALLPAPER_LAYOUT_STRETCH, | 947 *image, rescaled_files->path_rescaled_small(), WALLPAPER_LAYOUT_STRETCH, |
| 948 kSmallWallpaperMaxWidth, kSmallWallpaperMaxHeight, small_wallpaper_image); | 948 kSmallWallpaperMaxWidth, kSmallWallpaperMaxHeight, small_wallpaper_image); |
| 949 | 949 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 void WallpaperManagerBase::CreateSolidDefaultWallpaper() { | 994 void WallpaperManagerBase::CreateSolidDefaultWallpaper() { |
| 995 loaded_wallpapers_for_test_++; | 995 loaded_wallpapers_for_test_++; |
| 996 SkBitmap bitmap; | 996 SkBitmap bitmap; |
| 997 bitmap.allocN32Pixels(1, 1); | 997 bitmap.allocN32Pixels(1, 1); |
| 998 bitmap.eraseColor(kDefaultWallpaperColor); | 998 bitmap.eraseColor(kDefaultWallpaperColor); |
| 999 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); | 999 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); |
| 1000 default_wallpaper_image_.reset(new user_manager::UserImage(image)); | 1000 default_wallpaper_image_.reset(new user_manager::UserImage(image)); |
| 1001 } | 1001 } |
| 1002 | 1002 |
| 1003 } // namespace wallpaper | 1003 } // namespace wallpaper |
| OLD | NEW |