diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-20 23:20:53 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-20 23:20:53 +0000 |
commit | abe29e2ae1ad6d9bd8a7bfa23b3316a203d39ef2 (patch) | |
tree | a86028978d5e3258dfbf7040de93a4e1fb4be54b /components/favicon_base/select_favicon_frames.cc | |
parent | 87ab8a7db8754aa193cc3b5aa4f7a77b439f2141 (diff) | |
download | chromium_src-abe29e2ae1ad6d9bd8a7bfa23b3316a203d39ef2.zip chromium_src-abe29e2ae1ad6d9bd8a7bfa23b3316a203d39ef2.tar.gz chromium_src-abe29e2ae1ad6d9bd8a7bfa23b3316a203d39ef2.tar.bz2 |
Convert ui::ScaleFactor -> float in favicon/history code
First stop to fix favicon for fractional scale factor.
I'll convert the rest of ui::ScaleFactor in 38
BUG=376367,381601
R=pkotwicz@chromium.org, sky@chromium.org
Review URL: https://codereview.chromium.org/335233003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278853 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/favicon_base/select_favicon_frames.cc')
-rw-r--r-- | components/favicon_base/select_favicon_frames.cc | 47 |
1 files changed, 20 insertions, 27 deletions
diff --git a/components/favicon_base/select_favicon_frames.cc b/components/favicon_base/select_favicon_frames.cc index 2f67aaa..0315408 100644 --- a/components/favicon_base/select_favicon_frames.cc +++ b/components/favicon_base/select_favicon_frames.cc @@ -88,9 +88,7 @@ size_t GetCandidateIndexWithBestScore( candidate_sizes[i].height() >= desired_size) { score = desired_size / average_edge * 0.01f + 0.15f; } else { - score = std::min(1.0f, average_edge / desired_size) * - 0.01f + - 0.1f; + score = std::min(1.0f, average_edge / desired_size) * 0.01f + 0.1f; } if (candidate_index == std::numeric_limits<size_t>::max() || @@ -140,8 +138,8 @@ void GetCandidateIndicesWithBestScores( return; } - std::vector<int>::const_iterator zero_size_it = std::find( - desired_sizes.begin(), desired_sizes.end(), 0); + std::vector<int>::const_iterator zero_size_it = + std::find(desired_sizes.begin(), desired_sizes.end(), 0); if (zero_size_it != desired_sizes.end()) { // Just return the biggest image available. SelectionResult result; @@ -159,10 +157,8 @@ void GetCandidateIndicesWithBestScores( float score; SelectionResult result; result.desired_size = desired_sizes[i]; - result.index = GetCandidateIndexWithBestScore(candidate_sizes, - result.desired_size, - &score, - &result.resize_method); + result.index = GetCandidateIndexWithBestScore( + candidate_sizes, result.desired_size, &score, &result.resize_method); results->push_back(result); total_score += score; } @@ -194,20 +190,19 @@ SkBitmap GetResizedBitmap(const SkBitmap& source_bitmap, const float kSelectFaviconFramesInvalidScore = -1.0f; -gfx::ImageSkia SelectFaviconFrames( - const std::vector<SkBitmap>& bitmaps, - const std::vector<gfx::Size>& original_sizes, - const std::vector<ui::ScaleFactor>& scale_factors, - int desired_size_in_dip, - float* match_score) { +gfx::ImageSkia SelectFaviconFrames(const std::vector<SkBitmap>& bitmaps, + const std::vector<gfx::Size>& original_sizes, + const std::vector<float>& favicon_scales, + int desired_size_in_dip, + float* match_score) { std::vector<int> desired_sizes; std::map<int, float> scale_map; if (desired_size_in_dip == 0) { desired_sizes.push_back(0); scale_map[0] = 1.0f; } else { - for (size_t i = 0; i < scale_factors.size(); ++i) { - float scale = ui::GetScaleForScaleFactor(scale_factors[i]); + for (size_t i = 0; i < favicon_scales.size(); ++i) { + float scale = favicon_scales[i]; int desired_size = ceil(desired_size_in_dip * scale); desired_sizes.push_back(desired_size); scale_map[desired_size] = scale; @@ -221,12 +216,11 @@ gfx::ImageSkia SelectFaviconFrames( gfx::ImageSkia multi_image; for (size_t i = 0; i < results.size(); ++i) { const SelectionResult& result = results[i]; - SkBitmap resized_bitmap = GetResizedBitmap(bitmaps[result.index], - result.desired_size, - result.resize_method); + SkBitmap resized_bitmap = GetResizedBitmap( + bitmaps[result.index], result.desired_size, result.resize_method); - std::map<int, float>::const_iterator it = scale_map.find( - result.desired_size); + std::map<int, float>::const_iterator it = + scale_map.find(result.desired_size); DCHECK(it != scale_map.end()); float scale = it->second; multi_image.AddRepresentation(gfx::ImageSkiaRep(resized_bitmap, scale)); @@ -234,11 +228,10 @@ gfx::ImageSkia SelectFaviconFrames( return multi_image; } -void SelectFaviconFrameIndices( - const std::vector<gfx::Size>& frame_pixel_sizes, - const std::vector<int>& desired_sizes, - std::vector<size_t>* best_indices, - float* match_score) { +void SelectFaviconFrameIndices(const std::vector<gfx::Size>& frame_pixel_sizes, + const std::vector<int>& desired_sizes, + std::vector<size_t>* best_indices, + float* match_score) { std::vector<SelectionResult> results; GetCandidateIndicesWithBestScores( frame_pixel_sizes, desired_sizes, match_score, &results); |