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/favicon_base/select_favicon_frames.h" | 5 #include "components/favicon_base/select_favicon_frames.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 #include <map> | 10 #include <map> |
(...skipping 17 matching lines...) Expand all Loading... |
28 if (area > max_area) { | 28 if (area > max_area) { |
29 max_area = area; | 29 max_area = area; |
30 max_index = i; | 30 max_index = i; |
31 } | 31 } |
32 } | 32 } |
33 return max_index; | 33 return max_index; |
34 } | 34 } |
35 | 35 |
36 SkBitmap SampleNearestNeighbor(const SkBitmap& contents, int desired_size) { | 36 SkBitmap SampleNearestNeighbor(const SkBitmap& contents, int desired_size) { |
37 SkBitmap bitmap; | 37 SkBitmap bitmap; |
38 bitmap.setConfig(SkBitmap::kARGB_8888_Config, desired_size, desired_size); | 38 bitmap.allocN32Pixels(desired_size, desired_size); |
39 bitmap.allocPixels(); | |
40 if (!contents.isOpaque()) | 39 if (!contents.isOpaque()) |
41 bitmap.eraseARGB(0, 0, 0, 0); | 40 bitmap.eraseARGB(0, 0, 0, 0); |
42 | 41 |
43 { | 42 { |
44 SkCanvas canvas(bitmap); | 43 SkCanvas canvas(bitmap); |
45 SkRect dest(SkRect::MakeWH(desired_size, desired_size)); | 44 SkRect dest(SkRect::MakeWH(desired_size, desired_size)); |
46 canvas.drawBitmapRect(contents, NULL, dest); | 45 canvas.drawBitmapRect(contents, NULL, dest); |
47 } | 46 } |
48 | 47 |
49 return bitmap; | 48 return bitmap; |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 // GetCandidateIndicesWithBestScores() will return duplicate indices if the | 269 // GetCandidateIndicesWithBestScores() will return duplicate indices if the |
271 // bitmap data with |frame_pixel_sizes[index]| should be used for multiple | 270 // bitmap data with |frame_pixel_sizes[index]| should be used for multiple |
272 // scale factors. Remove duplicates here such that |best_indices| contains | 271 // scale factors. Remove duplicates here such that |best_indices| contains |
273 // no duplicates. | 272 // no duplicates. |
274 if (already_added.find(index) == already_added.end()) { | 273 if (already_added.find(index) == already_added.end()) { |
275 already_added.insert(index); | 274 already_added.insert(index); |
276 best_indices->push_back(index); | 275 best_indices->push_back(index); |
277 } | 276 } |
278 } | 277 } |
279 } | 278 } |
OLD | NEW |