OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/history/select_favicon_frames.h" | 5 #include "chrome/browser/history/select_favicon_frames.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "skia/ext/image_operations.h" | 9 #include "skia/ext/image_operations.h" |
10 #include "third_party/skia/include/core/SkCanvas.h" | 10 #include "third_party/skia/include/core/SkCanvas.h" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 std::vector<SelectionResult> results; | 218 std::vector<SelectionResult> results; |
219 GetCandidateIndicesWithBestScores(candidate_sizes, scale_factors, | 219 GetCandidateIndicesWithBestScores(candidate_sizes, scale_factors, |
220 desired_size, match_score, &results); | 220 desired_size, match_score, &results); |
221 | 221 |
222 gfx::ImageSkia multi_image; | 222 gfx::ImageSkia multi_image; |
223 for (size_t i = 0; i < results.size(); ++i) { | 223 for (size_t i = 0; i < results.size(); ++i) { |
224 const SelectionResult& result = results[i]; | 224 const SelectionResult& result = results[i]; |
225 SkBitmap resized_bitmap = GetResizedBitmap(bitmaps[result.index], | 225 SkBitmap resized_bitmap = GetResizedBitmap(bitmaps[result.index], |
226 desired_size, result.scale_factor, result.resize_method); | 226 desired_size, result.scale_factor, result.resize_method); |
227 multi_image.AddRepresentation( | 227 multi_image.AddRepresentation( |
228 gfx::ImageSkiaRep(resized_bitmap, result.scale_factor)); | 228 gfx::ImageSkiaRep(resized_bitmap, |
| 229 ui::GetScaleFactorScale(result.scale_factor))); |
229 } | 230 } |
230 return multi_image; | 231 return multi_image; |
231 } | 232 } |
232 | 233 |
233 void SelectFaviconFrameIndices( | 234 void SelectFaviconFrameIndices( |
234 const std::vector<gfx::Size>& frame_pixel_sizes, | 235 const std::vector<gfx::Size>& frame_pixel_sizes, |
235 const std::vector<ui::ScaleFactor>& scale_factors, | 236 const std::vector<ui::ScaleFactor>& scale_factors, |
236 int desired_size, | 237 int desired_size, |
237 std::vector<size_t>* best_indices, | 238 std::vector<size_t>* best_indices, |
238 float* match_score) { | 239 float* match_score) { |
239 std::vector<SelectionResult> results; | 240 std::vector<SelectionResult> results; |
240 GetCandidateIndicesWithBestScores(frame_pixel_sizes, scale_factors, | 241 GetCandidateIndicesWithBestScores(frame_pixel_sizes, scale_factors, |
241 desired_size, match_score, &results); | 242 desired_size, match_score, &results); |
242 | 243 |
243 std::set<size_t> already_added; | 244 std::set<size_t> already_added; |
244 for (size_t i = 0; i < results.size(); ++i) { | 245 for (size_t i = 0; i < results.size(); ++i) { |
245 size_t index = results[i].index; | 246 size_t index = results[i].index; |
246 // GetCandidateIndicesWithBestScores() will return duplicate indices if the | 247 // GetCandidateIndicesWithBestScores() will return duplicate indices if the |
247 // bitmap data with |frame_pixel_sizes[index]| should be used for multiple | 248 // bitmap data with |frame_pixel_sizes[index]| should be used for multiple |
248 // scale factors. Remove duplicates here such that |best_indices| contains | 249 // scale factors. Remove duplicates here such that |best_indices| contains |
249 // no duplicates. | 250 // no duplicates. |
250 if (already_added.find(index) == already_added.end()) { | 251 if (already_added.find(index) == already_added.end()) { |
251 already_added.insert(index); | 252 already_added.insert(index); |
252 best_indices->push_back(index); | 253 best_indices->push_back(index); |
253 } | 254 } |
254 } | 255 } |
255 } | 256 } |
OLD | NEW |