OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_HISTORY_SELECT_FAVICON_FRAMES_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_SELECT_FAVICON_FRAMES_H_ |
6 #define CHROME_BROWSER_HISTORY_SELECT_FAVICON_FRAMES_H_ | 6 #define CHROME_BROWSER_HISTORY_SELECT_FAVICON_FRAMES_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
| 10 #include "chrome/browser/history/history_types.h" |
10 #include "ui/base/layout.h" | 11 #include "ui/base/layout.h" |
11 | 12 |
12 class SkBitmap; | 13 class SkBitmap; |
13 | 14 |
14 namespace gfx { | 15 namespace gfx { |
15 class ImageSkia; | 16 class ImageSkia; |
16 } | 17 } |
17 | 18 |
| 19 // Score which is smaller than the minimum score returned by |
| 20 // SelectFaviconFrames() or SelectFaviconBitmapIDs(). |
| 21 extern const float kSelectFaviconFramesInvalidScore; |
| 22 |
18 // Takes a list of all bitmaps found in a .ico file, and creates an | 23 // Takes a list of all bitmaps found in a .ico file, and creates an |
19 // ImageSkia that's desired_size x desired_size pixels big. This | 24 // ImageSkia that's |desired_size| x |desired_size| DIP big. This |
20 // function adds a representation at every desired scale factor. | 25 // function adds a representation at every desired scale factor. |
21 // If desired_size is 0, the largest bitmap is returned unmodified. | 26 // If |desired_size| is 0, the largest bitmap is returned unmodified. |
22 // If score is non-NULL, it receive a score between 0 (bad) and 1 (good) | 27 // If score is non-NULL, it receives a score between 0 (bad) and 1 (good) |
23 // that describes how well |bitmaps| were able to produce an image at | 28 // that describes how well |bitmaps| were able to produce an image at |
24 // |desired_size| for |scale_factors|. | 29 // |desired_size| for |scale_factors|. |
25 // The score is arbitrary, but it's best for exact size matches, | 30 // The score is arbitrary, but it's best for exact size matches, |
26 // and gets worse the more resampling needs to happen. | 31 // and gets worse the more resampling needs to happen. |
27 gfx::ImageSkia SelectFaviconFrames( | 32 gfx::ImageSkia SelectFaviconFrames( |
28 const std::vector<SkBitmap>& bitmaps, | 33 const std::vector<SkBitmap>& bitmaps, |
29 const std::vector<ui::ScaleFactor>& scale_factors, | 34 const std::vector<ui::ScaleFactor>& scale_factors, |
30 int desired_size, | 35 int desired_size, |
31 float* score); | 36 float* score); |
32 | 37 |
| 38 // Takes a list of all history::FaviconBitmapIDSize for a favicon and returns |
| 39 // the FaviconBitmapIDs (in |filtered_favicon_bitmap_ids|) whose bitmap data |
| 40 // should be fetched in order to create an ImageSkia that's |desired_size| x |
| 41 // |desired_size| DIP big. |
| 42 // If |desired_size| is 0, the FaviconBitmapID with the largest size is |
| 43 // returned. If score is non-NULL, it receives a score between 0 (bad) and |
| 44 // 1 (good) that describes how well |filtered_favicon_bitmap_ids| will |
| 45 // produce an image at |desired_size| for |scale_factors|. The score is |
| 46 // arbitrary, but it's best for exact size matches, and gets worse the |
| 47 // more resampling needs to happen. |
| 48 // TODO(pkotwicz): Remove need to pass in |scale_factors|. |
| 49 void SelectFaviconBitmapIDs( |
| 50 const std::vector<history::FaviconBitmapIDSize>& bitmap_id_sizes, |
| 51 const std::vector<ui::ScaleFactor>& scale_factors, |
| 52 int desired_size, |
| 53 std::vector<history::FaviconBitmapID>* filtered_favicon_bitmap_ids, |
| 54 float* score); |
| 55 |
33 #endif // CHROME_BROWSER_HISTORY_SELECT_FAVICON_FRAMES_H_ | 56 #endif // CHROME_BROWSER_HISTORY_SELECT_FAVICON_FRAMES_H_ |
OLD | NEW |