summaryrefslogtreecommitdiffstats
path: root/components/favicon_base/select_favicon_frames.h
diff options
context:
space:
mode:
authorjif@chromium.org <jif@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-28 13:51:29 +0000
committerjif@chromium.org <jif@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-28 13:51:29 +0000
commit2537fcff333b54999c50f1caec16bb75847a029c (patch)
treeee4ac80b4370806b4199f95b7d54b4f230489d0b /components/favicon_base/select_favicon_frames.h
parent3779b3e169ae89170e7783119fd58fc5a2b47c11 (diff)
downloadchromium_src-2537fcff333b54999c50f1caec16bb75847a029c.zip
chromium_src-2537fcff333b54999c50f1caec16bb75847a029c.tar.gz
chromium_src-2537fcff333b54999c50f1caec16bb75847a029c.tar.bz2
Moves SelectFaviconFrames from history to the favicon_base component.
In order to create a favicon component, we are removing dependencies on chrome/. TBR=bsalomon1 BUG=359592 NOTRY=true Review URL: https://codereview.chromium.org/246893004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266547 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/favicon_base/select_favicon_frames.h')
-rw-r--r--components/favicon_base/select_favicon_frames.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/components/favicon_base/select_favicon_frames.h b/components/favicon_base/select_favicon_frames.h
new file mode 100644
index 0000000..cc57a80
--- /dev/null
+++ b/components/favicon_base/select_favicon_frames.h
@@ -0,0 +1,62 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_FAVICON_BASE_SELECT_FAVICON_FRAMES_H_
+#define COMPONENTS_FAVICON_BASE_SELECT_FAVICON_FRAMES_H_
+
+#include <vector>
+
+#include "ui/base/layout.h"
+
+class SkBitmap;
+
+namespace gfx {
+class ImageSkia;
+class Size;
+}
+
+// Score which is smaller than the minimum score returned by
+// SelectFaviconFrames() or SelectFaviconBitmapIDs().
+extern const float kSelectFaviconFramesInvalidScore;
+
+// Takes a list of all bitmaps found in a .ico file, and creates an
+// ImageSkia that's |desired_size| x |desired_size| DIP big. This
+// function adds a representation at every desired scale factor.
+// If |desired_size| is 0, the largest bitmap is returned unmodified.
+// |original_sizes| are the original sizes of the bitmaps. (For instance,
+// WebContents::DownloadImage() does resampling if it is passed a max size.)
+// If score is non-NULL, it receives a score between 0 (bad) and 1 (good)
+// that describes how well |bitmaps| were able to produce an image at
+// |desired_size| for |scale_factors|.
+// The score is arbitrary, but it's best for exact size matches,
+// and gets worse the more resampling needs to happen.
+// If the resampling algorithm is modified, the resampling done in
+// FaviconUtil::SelectFaviconFramesFromPNGs() should probably be modified too as
+// it inspired by this method.
+gfx::ImageSkia SelectFaviconFrames(
+ const std::vector<SkBitmap>& bitmaps,
+ const std::vector<gfx::Size>& original_sizes,
+ const std::vector<ui::ScaleFactor>& scale_factors,
+ int desired_size,
+ float* score);
+
+// Takes a list of the pixel sizes of a favicon's favicon bitmaps and returns
+// the indices of the best sizes to use to create an ImageSkia that's
+// |desired_size| x |desired_size| DIP big. If |desired_size| is 0, the index
+// of the largest size is returned. If score is non-NULL, it receives a score
+// between 0 (bad) and 1 (good) that describes how well the bitmap data with
+// the sizes at |best_indices| will produce an image of |desired_size| DIP for
+// |scale_factors|. The score is arbitrary, but it's best for exact size
+// matches, and gets worse the more resampling needs to happen.
+// TODO(pkotwicz): Remove need to pass in |scale_factors|.
+// TODO(pkotwicz): Remove callers of this method for which |frame_pixel_sizes|
+// are the sizes of the favicon bitmaps after they were resized.
+void SelectFaviconFrameIndices(
+ const std::vector<gfx::Size>& frame_pixel_sizes,
+ const std::vector<ui::ScaleFactor>& scale_factors,
+ int desired_size,
+ std::vector<size_t>* best_indices,
+ float* score);
+
+#endif // COMPONENTS_FAVICON_BASE_SELECT_FAVICON_FRAMES_H_