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 #ifndef COMPONENTS_FAVICON_BASE_SELECT_FAVICON_FRAMES_H_ | 5 #ifndef COMPONENTS_FAVICON_BASE_SELECT_FAVICON_FRAMES_H_ |
6 #define COMPONENTS_FAVICON_BASE_SELECT_FAVICON_FRAMES_H_ | 6 #define COMPONENTS_FAVICON_BASE_SELECT_FAVICON_FRAMES_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
(...skipping 26 matching lines...) Expand all Loading... |
37 // FaviconUtil::SelectFaviconFramesFromPNGs() should probably be modified too as | 37 // FaviconUtil::SelectFaviconFramesFromPNGs() should probably be modified too as |
38 // it inspired by this method. | 38 // it inspired by this method. |
39 // If an unsupported scale (not in the favicon_base::GetFaviconScales()) | 39 // If an unsupported scale (not in the favicon_base::GetFaviconScales()) |
40 // is requested, the ImageSkia will automatically scales using lancoz3. | 40 // is requested, the ImageSkia will automatically scales using lancoz3. |
41 gfx::ImageSkia CreateFaviconImageSkia( | 41 gfx::ImageSkia CreateFaviconImageSkia( |
42 const std::vector<SkBitmap>& bitmaps, | 42 const std::vector<SkBitmap>& bitmaps, |
43 const std::vector<gfx::Size>& original_sizes, | 43 const std::vector<gfx::Size>& original_sizes, |
44 int desired_size_in_dip, | 44 int desired_size_in_dip, |
45 float* score); | 45 float* score); |
46 | 46 |
| 47 // |desired_scale_factors| can contain 0 to represent that the corresponding |
| 48 // image shouldn't be resized. In that case, the scale factor will be computed |
| 49 // from |original_sizes|. |
| 50 gfx::ImageSkia CreateFaviconImageSkiaWithScaleFactors( |
| 51 const std::vector<SkBitmap>& bitmaps, |
| 52 const std::vector<gfx::Size>& original_sizes, |
| 53 const std::vector<float>& desired_scale_factors, |
| 54 int desired_size_in_dip); |
| 55 |
47 // Takes a list of the pixel sizes of a favicon's favicon bitmaps and returns | 56 // Takes a list of the pixel sizes of a favicon's favicon bitmaps and returns |
48 // the indices of the best sizes to use to create an ImageSkia with | 57 // the indices of the best sizes to use to create an ImageSkia with |
49 // ImageSkiaReps with edge sizes |desired_sizes|. If '0' is one of | 58 // ImageSkiaReps with edge sizes |desired_sizes|. If '0' is one of |
50 // |desired_sizes|, the index of the largest size is returned. If |score| is | 59 // |desired_sizes|, the index of the largest size is returned. If |score| is |
51 // non-NULL, |score| is set to a value between 0 (bad) and 1 (good) that | 60 // non-NULL, |score| is set to a value between 0 (bad) and 1 (good) that |
52 // describes how well the bitmap data with the sizes at |best_indices| will | 61 // describes how well the bitmap data with the sizes at |best_indices| will |
53 // produce the ImageSkia. The score is arbitrary, but it's best for exact | 62 // produce the ImageSkia. The score is arbitrary, but it's best for exact |
54 // matches, and gets worse the more resampling needs to happen. | 63 // matches, and gets worse the more resampling needs to happen. |
55 // TODO(pkotwicz): Change API so that |desired_sizes| being empty indicates | 64 // TODO(pkotwicz): Change API so that |desired_sizes| being empty indicates |
56 // that the index of the largest size is requested. | 65 // that the index of the largest size is requested. |
57 // TODO(pkotwicz): Remove callers of this method for which |frame_pixel_sizes| | 66 // TODO(pkotwicz): Remove callers of this method for which |frame_pixel_sizes| |
58 // are the sizes of the favicon bitmaps after they were resized. | 67 // are the sizes of the favicon bitmaps after they were resized. |
59 void SelectFaviconFrameIndices(const std::vector<gfx::Size>& frame_pixel_sizes, | 68 void SelectFaviconFrameIndices(const std::vector<gfx::Size>& frame_pixel_sizes, |
60 const std::vector<int>& desired_sizes, | 69 const std::vector<int>& desired_sizes, |
61 std::vector<size_t>* best_indices, | 70 std::vector<size_t>* best_indices, |
62 float* score); | 71 float* score); |
63 | 72 |
| 73 // Returns an arbitrary, implementation specific score between [0..1] that is |
| 74 // higher for better matches, and 1.0f for exact matches. Order of preference: |
| 75 // 1) Non-huge bitmaps are preferred over huge ones (8x bigger than |
| 76 // desired_size). |
| 77 // 2) Bitmaps which need to be scaled down instead of up. |
| 78 // 3) Bitmaps which do not need to be scaled as much. |
| 79 float GetFaviconCandidateScore(const gfx::Size& candidate_size, |
| 80 int desired_size); |
| 81 |
64 #endif // COMPONENTS_FAVICON_BASE_SELECT_FAVICON_FRAMES_H_ | 82 #endif // COMPONENTS_FAVICON_BASE_SELECT_FAVICON_FRAMES_H_ |
OLD | NEW |