Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Unified Diff: ui/gfx/icon_family.h

Issue 12881003: ShortcutInfo::favicon is now a gfx::ImageFamily instead of gfx::Image. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: web_app_mac: Fix compile error (no Mac to test it on so I'm building in the dark). Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/gfx/icon_family.h
diff --git a/ui/gfx/icon_family.h b/ui/gfx/icon_family.h
new file mode 100644
index 0000000000000000000000000000000000000000..0597e3ca56f93817f2aaf893d53fa34bc9a39e08
--- /dev/null
+++ b/ui/gfx/icon_family.h
@@ -0,0 +1,67 @@
+// Copyright 2012 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 UI_GFX_ICON_FAMILY_H_
+#define UI_GFX_ICON_FAMILY_H_
+
+#include <map>
+
+#include "ui/base/ui_export.h"
+#include "ui/gfx/image/image_skia.h"
+
+namespace gfx {
+class Image;
+
+// A collection of images, representing icons at different sizes. Each image is
+// an ImageSkia, which may contain multi-resolution bitmaps.
+class UI_EXPORT IconFamily {
+ public:
+ // Type for iterating over all icons in the family, in order.
+ typedef std::map<int, gfx::ImageSkia>::const_iterator const_iterator;
+
+ IconFamily();
+ ~IconFamily();
+
+ // Gets an iterator to the first icon.
+ inline const_iterator begin() const { return map_.begin(); }
+ // Gets an iterator to one after the last icon.
+ inline const_iterator end() const { return map_.end(); }
+
+ // Determines whether the icon family has no icons in it.
+ inline bool empty() const { return map_.empty(); }
+
+ // Removes all icons from the family.
+ inline void clear() { return map_.clear(); }
+
+ // Adds an icon to the family. If another icon is already present at the
+ // same size, it will be overwritten. If |icon| does not contain an image,
+ // does nothing.
+ // The icon SHOULD be square; if not, its size will be whichever is smaller
benwells 2013/03/17 22:42:36 What's the reasoning behind this recommendation-bu
Matt Giuca 2013/03/17 22:51:18 Basically that it works fine if images are not squ
Matt Giuca 2013/03/18 07:41:16 Note: I chatted with Ben about this some more. He
+ // of the width and height.
+ void Add(const gfx::Image& icon);
+
+ // Adds an icon to the family. If another icon is already present at the
+ // same size, it will be overwritten.
+ // The icon SHOULD be square; if not, its size will be whichever is smaller
+ // of the width and height.
+ void Add(const gfx::ImageSkia& icon);
+
+ // Gets the best icon to use at |size|.
+ // Returns the smallest icon bigger or equal to |size|. If none exists,
+ // returns the largest icon smaller than |size|. If there are no icons in the
+ // family, returns NULL.
+ const gfx::ImageSkia* Get(int size) const;
+
+ private:
+ // Map from base icon size to multi-resolution image. If an image is
+ // non-square, its size refers to the minimum of its width and height
+ // (although this is not recommended).
+ // If an image contains multiple resolution bitmaps, the size refers to the
+ // width/height at the 100% representation.
+ std::map<int, gfx::ImageSkia> map_;
pkotwicz 2013/03/18 03:22:43 If you want, you can make this into std::map<int,
Matt Giuca 2013/03/18 07:41:16 Well we (Ben and I) designed it so that we could h
pkotwicz 2013/03/18 16:30:23 Comment: Right now I don't think we 2x images into
Matt Giuca 2013/03/18 22:45:20 Correct. But this representation would easily allo
+};
+
+} // namespace gfx
+
+#endif // UI_GFX_ICON_FAMILY_H_

Powered by Google App Engine
This is Rietveld 408576698