Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Unified Diff: components/favicon_base/select_favicon_frames.cc

Issue 335233003: Convert ui::ScaleFactor -> float in favicon/history code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/favicon_base/select_favicon_frames.cc
diff --git a/components/favicon_base/select_favicon_frames.cc b/components/favicon_base/select_favicon_frames.cc
index 888837fe82d40d2ef36e71fa10b959ec57027151..3de7de353a340d608749998d79f562500de0560b 100644
--- a/components/favicon_base/select_favicon_frames.cc
+++ b/components/favicon_base/select_favicon_frames.cc
@@ -48,13 +48,12 @@ enum ResizeMethod { NONE, SAMPLE_NEAREST_NEIGHBOUR, LANCZOS };
size_t GetCandidateIndexWithBestScore(
const std::vector<gfx::Size>& candidate_sizes_in_pixel,
- ui::ScaleFactor scale_factor,
+ float scale,
int desired_size_in_dip,
float* score,
ResizeMethod* resize_method) {
DCHECK_NE(desired_size_in_dip, 0);
- float scale = ui::GetScaleForScaleFactor(scale_factor);
int desired_size_in_pixel =
static_cast<int>(desired_size_in_dip * scale + 0.5f);
@@ -128,7 +127,7 @@ struct SelectionResult {
size_t index;
// The ScaleFactor for which |index| is the best candidate.
- ui::ScaleFactor scale_factor;
+ float scale;
// How the bitmap data that the bitmap with |candidate_sizes[index]| should
// be resized for displaying in the UI.
@@ -137,7 +136,7 @@ struct SelectionResult {
void GetCandidateIndicesWithBestScores(
const std::vector<gfx::Size>& candidate_sizes,
- const std::vector<ui::ScaleFactor>& scale_factors,
+ const std::vector<float>& scales,
int desired_size,
float* match_score,
std::vector<SelectionResult>* results) {
@@ -151,7 +150,7 @@ void GetCandidateIndicesWithBestScores(
// Just return the biggest image available.
SelectionResult result;
result.index = BiggestCandidate(candidate_sizes);
- result.scale_factor = ui::SCALE_FACTOR_100P;
+ result.scale = 1.0f;
result.resize_method = NONE;
results->push_back(result);
if (match_score)
@@ -160,12 +159,12 @@ void GetCandidateIndicesWithBestScores(
}
float total_score = 0;
- for (size_t i = 0; i < scale_factors.size(); ++i) {
+ for (size_t i = 0; i < scales.size(); ++i) {
float score;
SelectionResult result;
- result.scale_factor = scale_factors[i];
+ result.scale = scales[i];
result.index = GetCandidateIndexWithBestScore(candidate_sizes,
- result.scale_factor,
+ result.scale,
desired_size,
&score,
&result.resize_method);
@@ -174,15 +173,14 @@ void GetCandidateIndicesWithBestScores(
}
if (match_score)
- *match_score = total_score / scale_factors.size();
+ *match_score = total_score / scales.size();
}
// Resize |source_bitmap| using |resize_method|.
SkBitmap GetResizedBitmap(const SkBitmap& source_bitmap,
int desired_size_in_dip,
- ui::ScaleFactor scale_factor,
+ float scale,
ResizeMethod resize_method) {
- float scale = ui::GetScaleForScaleFactor(scale_factor);
int desired_size_in_pixel =
static_cast<int>(desired_size_in_dip * scale + 0.5f);
@@ -205,38 +203,36 @@ 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,
- float* match_score) {
+gfx::ImageSkia SelectFaviconFrames(const std::vector<SkBitmap>& bitmaps,
+ const std::vector<gfx::Size>& original_sizes,
+ const std::vector<float>& scales,
+ int desired_size,
+ float* match_score) {
std::vector<SelectionResult> results;
GetCandidateIndicesWithBestScores(
- original_sizes, scale_factors, desired_size, match_score, &results);
+ original_sizes, scales, desired_size, match_score, &results);
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],
desired_size,
- result.scale_factor,
+ result.scale,
result.resize_method);
- multi_image.AddRepresentation(gfx::ImageSkiaRep(
- resized_bitmap, ui::GetScaleForScaleFactor(result.scale_factor)));
+ multi_image.AddRepresentation(
+ gfx::ImageSkiaRep(resized_bitmap, result.scale));
}
return multi_image;
}
-void SelectFaviconFrameIndices(
- const std::vector<gfx::Size>& frame_pixel_sizes,
- const std::vector<ui::ScaleFactor>& scale_factors,
- int desired_size,
- std::vector<size_t>* best_indices,
- float* match_score) {
+void SelectFaviconFrameIndices(const std::vector<gfx::Size>& frame_pixel_sizes,
+ const std::vector<float>& scales,
+ int desired_size,
+ std::vector<size_t>* best_indices,
+ float* match_score) {
std::vector<SelectionResult> results;
GetCandidateIndicesWithBestScores(
- frame_pixel_sizes, scale_factors, desired_size, match_score, &results);
+ frame_pixel_sizes, scales, desired_size, match_score, &results);
std::set<size_t> already_added;
for (size_t i = 0; i < results.size(); ++i) {
« components/favicon_base/favicon_util.cc ('K') | « components/favicon_base/select_favicon_frames.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698