[M73 Dev][EFL] Disable VizDisplayCompositor for EFL port
[platform/framework/web/chromium-efl.git] / components / favicon_base / select_favicon_frames.h
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
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_FAVICON_BASE_SELECT_FAVICON_FRAMES_H_
6 #define COMPONENTS_FAVICON_BASE_SELECT_FAVICON_FRAMES_H_
7
8 #include <stddef.h>
9
10 #include <vector>
11
12
13 class SkBitmap;
14
15 namespace gfx {
16 class ImageSkia;
17 class Size;
18 }
19
20 // Score which is smaller than the minimum score returned by
21 // SelectFaviconFrames() or SelectFaviconFrameIndices().
22 extern const float kSelectFaviconFramesInvalidScore;
23
24 // Takes a list of all bitmaps found in a .ico file, and creates an
25 // ImageSkia that's |desired_size_in_dip| x |desired_size_in_dip| big.
26 // Bitmaps are selected by using |SelectFaviconFrameIndices| and the
27 // platform's supported favicon scales (favicon_base::GetFaviconScales()).
28 // If |desired_size_in_dip| is 0, the largest bitmap is returned unmodified.
29 // |original_sizes| are the original sizes of the bitmaps. (For instance,
30 // WebContents::DownloadImage() does resampling if it is passed a max size.)
31 // If score is non-NULL, it receives a score between 0 (bad) and 1 (good)
32 // that describes how well |bitmaps| were able to produce an image at
33 // |desired_size_in_dip| for |favicon_scales|.
34 // The score is arbitrary, but it's best for exact size matches,
35 // and gets worse the more resampling needs to happen.
36 // If the resampling algorithm is modified, the resampling done in
37 // FaviconUtil::SelectFaviconFramesFromPNGs() should probably be modified too as
38 // it inspired by this method.
39 // If an unsupported scale (not in the favicon_base::GetFaviconScales())
40 // is requested, the ImageSkia will automatically scales using lancoz3.
41 gfx::ImageSkia CreateFaviconImageSkia(
42     const std::vector<SkBitmap>& bitmaps,
43     const std::vector<gfx::Size>& original_sizes,
44     int desired_size_in_dip,
45     float* score);
46
47 // 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
49 // 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
51 // 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
53 // produce the ImageSkia. The score is arbitrary, but it's best for exact
54 // matches, and gets worse the more resampling needs to happen.
55 // TODO(pkotwicz): Change API so that |desired_sizes| being empty indicates
56 // that the index of the largest size is requested.
57 // TODO(pkotwicz): Remove callers of this method for which |frame_pixel_sizes|
58 // are the sizes of the favicon bitmaps after they were resized.
59 void SelectFaviconFrameIndices(const std::vector<gfx::Size>& frame_pixel_sizes,
60                                const std::vector<int>& desired_sizes,
61                                std::vector<size_t>* best_indices,
62                                float* score);
63
64 #endif  // COMPONENTS_FAVICON_BASE_SELECT_FAVICON_FRAMES_H_