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