OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // An Image wraps an image any flavor, be it platform-native GdkBitmap/NSImage, | 5 // An Image wraps an image any flavor, be it platform-native GdkBitmap/NSImage, |
6 // or a SkBitmap. This also provides easy conversion to other image types | 6 // or a SkBitmap. This also provides easy conversion to other image types |
7 // through operator overloading. It will cache the converted representations | 7 // through operator overloading. It will cache the converted representations |
8 // internally to prevent double-conversion. | 8 // internally to prevent double-conversion. |
9 // | 9 // |
10 // The lifetime of both the initial representation and any converted ones are | 10 // The lifetime of both the initial representation and any converted ones are |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 typedef std::map<RepresentationType, internal::ImageRep*> RepresentationMap; | 59 typedef std::map<RepresentationType, internal::ImageRep*> RepresentationMap; |
60 | 60 |
61 // Creates an empty image with no representations. | 61 // Creates an empty image with no representations. |
62 Image(); | 62 Image(); |
63 | 63 |
64 // Creates a new image with the default representation. The object will take | 64 // Creates a new image with the default representation. The object will take |
65 // ownership of the image. | 65 // ownership of the image. |
66 explicit Image(const SkBitmap* bitmap); | 66 explicit Image(const SkBitmap* bitmap); |
67 | 67 |
| 68 // Creates a new image by copying the bitmap for use as the default |
| 69 // representation. |
| 70 explicit Image(const SkBitmap& bitmap); |
| 71 |
68 // To create an Image that supports multiple resolutions pass a vector | 72 // To create an Image that supports multiple resolutions pass a vector |
69 // of bitmaps, one for each resolution. | 73 // of bitmaps, one for each resolution. |
70 explicit Image(const std::vector<const SkBitmap*>& bitmaps); | 74 explicit Image(const std::vector<const SkBitmap*>& bitmaps); |
71 | 75 |
72 #if defined(TOOLKIT_USES_GTK) | 76 #if defined(TOOLKIT_USES_GTK) |
73 // Does not increase |pixbuf|'s reference count; expects to take ownership. | 77 // Does not increase |pixbuf|'s reference count; expects to take ownership. |
74 explicit Image(GdkPixbuf* pixbuf); | 78 explicit Image(GdkPixbuf* pixbuf); |
75 #elif defined(OS_MACOSX) | 79 #elif defined(OS_MACOSX) |
76 // Does not retain |image|; expects to take ownership. | 80 // Does not retain |image|; expects to take ownership. |
77 // A single NSImage object can contain multiple bitmaps so there's no reason | 81 // A single NSImage object can contain multiple bitmaps so there's no reason |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // be cheaply copied. | 165 // be cheaply copied. |
162 scoped_refptr<internal::ImageStorage> storage_; | 166 scoped_refptr<internal::ImageStorage> storage_; |
163 | 167 |
164 friend class ::ImageTest; | 168 friend class ::ImageTest; |
165 friend class ::ImageMacTest; | 169 friend class ::ImageMacTest; |
166 }; | 170 }; |
167 | 171 |
168 } // namespace gfx | 172 } // namespace gfx |
169 | 173 |
170 #endif // UI_GFX_IMAGE_IMAGE_H_ | 174 #endif // UI_GFX_IMAGE_IMAGE_H_ |
OLD | NEW |