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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 } | 258 } |
259 | 259 |
260 void SelectFaviconFrameIndices(const std::vector<gfx::Size>& frame_pixel_sizes, | 260 void SelectFaviconFrameIndices(const std::vector<gfx::Size>& frame_pixel_sizes, |
261 const std::vector<int>& desired_sizes, | 261 const std::vector<int>& desired_sizes, |
262 std::vector<size_t>* best_indices, | 262 std::vector<size_t>* best_indices, |
263 float* match_score) { | 263 float* match_score) { |
264 std::vector<SelectionResult> results; | 264 std::vector<SelectionResult> results; |
265 GetCandidateIndicesWithBestScores( | 265 GetCandidateIndicesWithBestScores( |
266 frame_pixel_sizes, desired_sizes, match_score, &results); | 266 frame_pixel_sizes, desired_sizes, match_score, &results); |
267 | 267 |
| 268 if (!best_indices) |
| 269 return; |
| 270 |
268 std::set<size_t> already_added; | 271 std::set<size_t> already_added; |
269 for (size_t i = 0; i < results.size(); ++i) { | 272 for (size_t i = 0; i < results.size(); ++i) { |
270 size_t index = results[i].index; | 273 size_t index = results[i].index; |
271 // GetCandidateIndicesWithBestScores() will return duplicate indices if the | 274 // GetCandidateIndicesWithBestScores() will return duplicate indices if the |
272 // bitmap data with |frame_pixel_sizes[index]| should be used for multiple | 275 // bitmap data with |frame_pixel_sizes[index]| should be used for multiple |
273 // scale factors. Remove duplicates here such that |best_indices| contains | 276 // scale factors. Remove duplicates here such that |best_indices| contains |
274 // no duplicates. | 277 // no duplicates. |
275 if (already_added.find(index) == already_added.end()) { | 278 if (already_added.find(index) == already_added.end()) { |
276 already_added.insert(index); | 279 already_added.insert(index); |
277 best_indices->push_back(index); | 280 best_indices->push_back(index); |
278 } | 281 } |
279 } | 282 } |
280 } | 283 } |
OLD | NEW |