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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 desired_size_in_pixel, | 166 desired_size_in_pixel, |
167 desired_size_in_pixel); | 167 desired_size_in_pixel); |
168 } | 168 } |
169 | 169 |
170 class FaviconImageSource : public gfx::ImageSkiaSource { | 170 class FaviconImageSource : public gfx::ImageSkiaSource { |
171 public: | 171 public: |
172 FaviconImageSource() {} | 172 FaviconImageSource() {} |
173 virtual ~FaviconImageSource() {} | 173 virtual ~FaviconImageSource() {} |
174 | 174 |
175 // gfx::ImageSkiaSource: | 175 // gfx::ImageSkiaSource: |
176 virtual gfx::ImageSkiaRep GetImageForScale(float scale) OVERRIDE { | 176 virtual gfx::ImageSkiaRep GetImageForScale(float scale) override { |
177 const gfx::ImageSkiaRep* rep = NULL; | 177 const gfx::ImageSkiaRep* rep = NULL; |
178 // gfx::ImageSkia passes one of the resource scale factors. The source | 178 // gfx::ImageSkia passes one of the resource scale factors. The source |
179 // should return: | 179 // should return: |
180 // 1) The ImageSkiaRep with the highest scale if all available | 180 // 1) The ImageSkiaRep with the highest scale if all available |
181 // scales are smaller than |scale|. | 181 // scales are smaller than |scale|. |
182 // 2) The ImageSkiaRep with the smallest one that is larger than |scale|. | 182 // 2) The ImageSkiaRep with the smallest one that is larger than |scale|. |
183 // Note: Keep this logic consistent with the PNGImageSource in | 183 // Note: Keep this logic consistent with the PNGImageSource in |
184 // ui/gfx/image.cc. | 184 // ui/gfx/image.cc. |
185 // TODO(oshima): consolidate these logic into one place. | 185 // TODO(oshima): consolidate these logic into one place. |
186 for (std::vector<gfx::ImageSkiaRep>::const_iterator iter = | 186 for (std::vector<gfx::ImageSkiaRep>::const_iterator iter = |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 // GetCandidateIndicesWithBestScores() will return duplicate indices if the | 269 // GetCandidateIndicesWithBestScores() will return duplicate indices if the |
270 // bitmap data with |frame_pixel_sizes[index]| should be used for multiple | 270 // bitmap data with |frame_pixel_sizes[index]| should be used for multiple |
271 // scale factors. Remove duplicates here such that |best_indices| contains | 271 // scale factors. Remove duplicates here such that |best_indices| contains |
272 // no duplicates. | 272 // no duplicates. |
273 if (already_added.find(index) == already_added.end()) { | 273 if (already_added.find(index) == already_added.end()) { |
274 already_added.insert(index); | 274 already_added.insert(index); |
275 best_indices->push_back(index); | 275 best_indices->push_back(index); |
276 } | 276 } |
277 } | 277 } |
278 } | 278 } |
OLD | NEW |