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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ui/base/layout.h" | |
11 | |
12 class SkBitmap; | 10 class SkBitmap; |
13 | 11 |
14 namespace gfx { | 12 namespace gfx { |
15 class ImageSkia; | 13 class ImageSkia; |
16 class Size; | 14 class Size; |
17 } | 15 } |
18 | 16 |
19 // Score which is smaller than the minimum score returned by | 17 // Score which is smaller than the minimum score returned by |
20 // SelectFaviconFrames() or SelectFaviconFrameIndices(). | 18 // SelectFaviconFrames() or SelectFaviconFrameIndices(). |
21 extern const float kSelectFaviconFramesInvalidScore; | 19 extern const float kSelectFaviconFramesInvalidScore; |
22 | 20 |
23 // Takes a list of all bitmaps found in a .ico file, and creates an | 21 // Takes a list of all bitmaps found in a .ico file, and creates an |
24 // ImageSkia that's |desired_size_in_dip| x |desired_size_in_dip| big. This | 22 // ImageSkia that's |desired_size_in_dip| x |desired_size_in_dip| big. This |
25 // function adds a representation at every desired scale factor. | 23 // function adds a representation at every desired scales. |
pkotwicz
2014/06/20 00:35:41
Nit: "at every desired scales" -> "for each entry
oshima
2014/06/20 04:16:34
Done.
| |
26 // If |desired_size_in_dip| is 0, the largest bitmap is returned unmodified. | 24 // If |desired_size_in_dip| is 0, the largest bitmap is returned unmodified. |
27 // |original_sizes| are the original sizes of the bitmaps. (For instance, | 25 // |original_sizes| are the original sizes of the bitmaps. (For instance, |
28 // WebContents::DownloadImage() does resampling if it is passed a max size.) | 26 // WebContents::DownloadImage() does resampling if it is passed a max size.) |
29 // If score is non-NULL, it receives a score between 0 (bad) and 1 (good) | 27 // If score is non-NULL, it receives a score between 0 (bad) and 1 (good) |
30 // 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 |
31 // |desired_size_in_dip| for |scale_factors|. | 29 // |desired_size_in_dip| for |favicon_scales|. |
32 // 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, |
33 // and gets worse the more resampling needs to happen. | 31 // and gets worse the more resampling needs to happen. |
34 // If the resampling algorithm is modified, the resampling done in | 32 // If the resampling algorithm is modified, the resampling done in |
35 // FaviconUtil::SelectFaviconFramesFromPNGs() should probably be modified too as | 33 // FaviconUtil::SelectFaviconFramesFromPNGs() should probably be modified too as |
36 // it inspired by this method. | 34 // it inspired by this method. |
37 gfx::ImageSkia SelectFaviconFrames( | 35 gfx::ImageSkia SelectFaviconFrames(const std::vector<SkBitmap>& bitmaps, |
38 const std::vector<SkBitmap>& bitmaps, | 36 const std::vector<gfx::Size>& original_sizes, |
39 const std::vector<gfx::Size>& original_sizes, | 37 const std::vector<float>& favicon_scales, |
40 const std::vector<ui::ScaleFactor>& scale_factors, | 38 int desired_size_in_dip, |
41 int desired_size_in_dip, | 39 float* score); |
42 float* score); | |
43 | 40 |
44 // Takes a list of the pixel sizes of a favicon's favicon bitmaps and returns | 41 // Takes a list of the pixel sizes of a favicon's favicon bitmaps and returns |
45 // the indices of the best sizes to use to create an ImageSkia with | 42 // the indices of the best sizes to use to create an ImageSkia with |
46 // ImageSkiaReps with edge sizes |desired_sizes|. If '0' is one of | 43 // ImageSkiaReps with edge sizes |desired_sizes|. If '0' is one of |
47 // |desired_sizes|, the index of the largest size is returned. If |score| is | 44 // |desired_sizes|, the index of the largest size is returned. If |score| is |
48 // non-NULL, |score| is set to a value between 0 (bad) and 1 (good) that | 45 // non-NULL, |score| is set to a value between 0 (bad) and 1 (good) that |
49 // describes how well the bitmap data with the sizes at |best_indices| will | 46 // describes how well the bitmap data with the sizes at |best_indices| will |
50 // produce the ImageSkia. The score is arbitrary, but it's best for exact | 47 // produce the ImageSkia. The score is arbitrary, but it's best for exact |
51 // matches, and gets worse the more resampling needs to happen. | 48 // matches, and gets worse the more resampling needs to happen. |
52 // TODO(pkotwicz): Change API so that |desired_sizes| being empty indicates | 49 // TODO(pkotwicz): Change API so that |desired_sizes| being empty indicates |
53 // that the index of the largest size is requested. | 50 // that the index of the largest size is requested. |
54 // TODO(pkotwicz): Remove callers of this method for which |frame_pixel_sizes| | 51 // TODO(pkotwicz): Remove callers of this method for which |frame_pixel_sizes| |
55 // are the sizes of the favicon bitmaps after they were resized. | 52 // are the sizes of the favicon bitmaps after they were resized. |
56 void SelectFaviconFrameIndices( | 53 void SelectFaviconFrameIndices(const std::vector<gfx::Size>& frame_pixel_sizes, |
57 const std::vector<gfx::Size>& frame_pixel_sizes, | 54 const std::vector<int>& desired_sizes, |
58 const std::vector<int>& desired_sizes, | 55 std::vector<size_t>* best_indices, |
59 std::vector<size_t>* best_indices, | 56 float* score); |
60 float* score); | |
61 | 57 |
62 #endif // COMPONENTS_FAVICON_BASE_SELECT_FAVICON_FRAMES_H_ | 58 #endif // COMPONENTS_FAVICON_BASE_SELECT_FAVICON_FRAMES_H_ |
OLD | NEW |