| 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 "components/wallpaper/wallpaper_resizer.h" | 5 #include "components/wallpaper/wallpaper_resizer.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 // Resizes |image| to |target_size| using |layout| and stores the | 27 // Resizes |image| to |target_size| using |layout| and stores the |
| 28 // resulting bitmap at |resized_bitmap_out|. | 28 // resulting bitmap at |resized_bitmap_out|. |
| 29 // | 29 // |
| 30 // NOTE: |image| is intentionally a copy to ensure it exists for the duration of | 30 // NOTE: |image| is intentionally a copy to ensure it exists for the duration of |
| 31 // the function. | 31 // the function. |
| 32 void Resize(const gfx::ImageSkia image, | 32 void Resize(const gfx::ImageSkia image, |
| 33 const gfx::Size& target_size, | 33 const gfx::Size& target_size, |
| 34 WallpaperLayout layout, | 34 WallpaperLayout layout, |
| 35 SkBitmap* resized_bitmap_out, | 35 SkBitmap* resized_bitmap_out, |
| 36 base::TaskRunner* task_runner) { | 36 base::TaskRunner* task_runner) { |
| 37 DCHECK(task_runner->RunsTasksOnCurrentThread()); | 37 DCHECK(task_runner->RunsTasksInCurrentSequence()); |
| 38 | 38 |
| 39 SkBitmap orig_bitmap = *image.bitmap(); | 39 SkBitmap orig_bitmap = *image.bitmap(); |
| 40 SkBitmap new_bitmap = orig_bitmap; | 40 SkBitmap new_bitmap = orig_bitmap; |
| 41 | 41 |
| 42 const int orig_width = orig_bitmap.width(); | 42 const int orig_width = orig_bitmap.width(); |
| 43 const int orig_height = orig_bitmap.height(); | 43 const int orig_height = orig_bitmap.height(); |
| 44 const int new_width = target_size.width(); | 44 const int new_width = target_size.width(); |
| 45 const int new_height = target_size.height(); | 45 const int new_height = target_size.height(); |
| 46 | 46 |
| 47 if (orig_width > new_width || orig_height > new_height) { | 47 if (orig_width > new_width || orig_height > new_height) { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 void WallpaperResizer::OnResizeFinished(SkBitmap* resized_bitmap) { | 153 void WallpaperResizer::OnResizeFinished(SkBitmap* resized_bitmap) { |
| 154 image_ = gfx::ImageSkia::CreateFrom1xBitmap(*resized_bitmap); | 154 image_ = gfx::ImageSkia::CreateFrom1xBitmap(*resized_bitmap); |
| 155 UMA_HISTOGRAM_TIMES("Ash.Wallpaper.TimeSpentResizing", | 155 UMA_HISTOGRAM_TIMES("Ash.Wallpaper.TimeSpentResizing", |
| 156 base::TimeTicks::Now() - start_calculation_time_); | 156 base::TimeTicks::Now() - start_calculation_time_); |
| 157 | 157 |
| 158 for (auto& observer : observers_) | 158 for (auto& observer : observers_) |
| 159 observer.OnWallpaperResized(); | 159 observer.OnWallpaperResized(); |
| 160 } | 160 } |
| 161 | 161 |
| 162 } // namespace wallpaper | 162 } // namespace wallpaper |
| OLD | NEW |