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

Unified Diff: chrome/browser/favicon/select_favicon_frames.cc

Issue 10802066: Adds support for saving favicon size into history database. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated comment for History::SetFavicons Created 8 years, 3 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: chrome/browser/favicon/select_favicon_frames.cc
diff --git a/chrome/browser/favicon/select_favicon_frames.cc b/chrome/browser/favicon/select_favicon_frames.cc
index 6fca9adc45f6d3e00310e856495386d691917117..8606862753863e96ccf1f4d01011477f11053622 100644
--- a/chrome/browser/favicon/select_favicon_frames.cc
+++ b/chrome/browser/favicon/select_favicon_frames.cc
@@ -18,6 +18,13 @@ void SizesFromBitmaps(const std::vector<SkBitmap>& bitmaps,
sizes->push_back(gfx::Size(bitmaps[i].width(), bitmaps[i].height()));
}
+void SizesFromFaviconBitmapIDSizes(
sky 2012/09/04 20:52:29 Add description.
+ const std::vector<history::FaviconBitmapIDSize>& bitmap_id_sizes,
+ std::vector<gfx::Size>* sizes) {
+ for (size_t i = 0; i < bitmap_id_sizes.size(); ++i)
+ sizes->push_back(bitmap_id_sizes[i].pixel_size);
+}
+
size_t BiggestCandidate(const std::vector<gfx::Size>& candidate_sizes) {
size_t max_index = 0;
int max_area = candidate_sizes[0].GetArea();
@@ -139,9 +146,14 @@ size_t GetCandidateIndexWithBestScore(
}
const gfx::Size& candidate_size = candidate_sizes[candidate_index];
- bool is_integer_multiple = desired_size % candidate_size.width() == 0 &&
- desired_size % candidate_size.height() == 0;
- *resize_method = is_integer_multiple ? SAMPLE_NEAREST_NEIGHBOUR : LANCZOS;
+ if (candidate_size.IsEmpty()) {
+ *resize_method = NONE;
+ } else if (desired_size % candidate_size.width() == 0 &&
+ desired_size % candidate_size.height() == 0) {
+ *resize_method = SAMPLE_NEAREST_NEIGHBOUR;
+ } else {
+ *resize_method = LANCZOS;
+ }
return candidate_index;
}
@@ -246,3 +258,28 @@ gfx::ImageSkia SelectFaviconFrames(
}
return multi_image;
}
+
+void SelectFaviconBitmapIDs(
+ const std::vector<history::FaviconBitmapIDSize>& bitmap_id_sizes,
+ const std::vector<ui::ScaleFactor>& scale_factors,
+ int desired_size,
+ std::vector<history::FaviconBitmapID>* filtered_favicon_bitmap_ids,
+ float* match_score) {
+ std::vector<gfx::Size> candidate_sizes;
+ SizesFromFaviconBitmapIDSizes(bitmap_id_sizes, &candidate_sizes);
+
+ std::vector<SelectionResult> results;
+ GetCandidateIndicesWithBestScores(candidate_sizes, scale_factors,
+ desired_size, match_score, &results);
+
+ std::set<history::FaviconBitmapID> already_added;
+ for (size_t i = 0; i < results.size(); ++i) {
+ const SelectionResult& result = results[i];
+ history::FaviconBitmapID bitmap_id =
+ bitmap_id_sizes[result.index].bitmap_id;
+ if (already_added.find(bitmap_id) == already_added.end()) {
+ already_added.insert(bitmap_id);
+ filtered_favicon_bitmap_ids->push_back(bitmap_id);
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698