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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 kImageRepCocoa, | 55 kImageRepCocoa, |
56 kImageRepCairoCache, | 56 kImageRepCairoCache, |
57 kImageRepSkia, | 57 kImageRepSkia, |
58 }; | 58 }; |
59 | 59 |
60 typedef std::map<RepresentationType, internal::ImageRep*> RepresentationMap; | 60 typedef std::map<RepresentationType, internal::ImageRep*> RepresentationMap; |
61 | 61 |
62 // Creates an empty image with no representations. | 62 // Creates an empty image with no representations. |
63 Image(); | 63 Image(); |
64 | 64 |
| 65 // Creates a new image with the default representation. |
| 66 explicit Image(const ImageSkia& image); |
| 67 |
65 // Creates a new image with the default representation. The object will take | 68 // Creates a new image with the default representation. The object will take |
66 // ownership of the image. | 69 // ownership of the image. |
67 explicit Image(const SkBitmap* bitmap); | 70 explicit Image(const SkBitmap* bitmap); |
68 | 71 |
69 // Creates a new image by copying the bitmap for use as the default | 72 // Creates a new image by copying the bitmap for use as the default |
70 // representation. | 73 // representation. |
71 explicit Image(const SkBitmap& bitmap); | 74 explicit Image(const SkBitmap& bitmap); |
72 | 75 |
73 // To create an Image that supports multiple resolutions pass a vector | |
74 // of bitmaps, one for each resolution. | |
75 explicit Image(const std::vector<const SkBitmap*>& bitmaps); | |
76 | |
77 #if defined(TOOLKIT_GTK) | 76 #if defined(TOOLKIT_GTK) |
78 // Does not increase |pixbuf|'s reference count; expects to take ownership. | 77 // Does not increase |pixbuf|'s reference count; expects to take ownership. |
79 explicit Image(GdkPixbuf* pixbuf); | 78 explicit Image(GdkPixbuf* pixbuf); |
80 #elif defined(OS_MACOSX) | 79 #elif defined(OS_MACOSX) |
81 // Does not retain |image|; expects to take ownership. | 80 // Does not retain |image|; expects to take ownership. |
82 // 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 |
83 // to pass a vector of these. | 82 // to pass a vector of these. |
84 explicit Image(NSImage* image); | 83 explicit Image(NSImage* image); |
85 #endif | 84 #endif |
86 | 85 |
(...skipping 18 matching lines...) Expand all Loading... |
105 #elif defined(OS_MACOSX) | 104 #elif defined(OS_MACOSX) |
106 NSImage* ToNSImage() const; | 105 NSImage* ToNSImage() const; |
107 #endif | 106 #endif |
108 | 107 |
109 // Performs a conversion, like above, but returns a copy of the result rather | 108 // Performs a conversion, like above, but returns a copy of the result rather |
110 // than a weak pointer. The caller is responsible for deleting the result. | 109 // than a weak pointer. The caller is responsible for deleting the result. |
111 // Note that the result is only a copy in terms of memory management; the | 110 // Note that the result is only a copy in terms of memory management; the |
112 // backing pixels are shared amongst all copies (a fact of each of the | 111 // backing pixels are shared amongst all copies (a fact of each of the |
113 // converted representations, rather than a limitation imposed by Image) and | 112 // converted representations, rather than a limitation imposed by Image) and |
114 // so the result should be considered immutable. | 113 // so the result should be considered immutable. |
| 114 ImageSkia* CopyImageSkia() const; |
115 SkBitmap* CopySkBitmap() const; | 115 SkBitmap* CopySkBitmap() const; |
116 #if defined(TOOLKIT_GTK) | 116 #if defined(TOOLKIT_GTK) |
117 GdkPixbuf* CopyGdkPixbuf() const; | 117 GdkPixbuf* CopyGdkPixbuf() const; |
118 #elif defined(OS_MACOSX) | 118 #elif defined(OS_MACOSX) |
119 NSImage* CopyNSImage() const; | 119 NSImage* CopyNSImage() const; |
120 #endif | 120 #endif |
121 | 121 |
122 // DEPRECATED ---------------------------------------------------------------- | 122 // DEPRECATED ---------------------------------------------------------------- |
123 // Conversion handlers. These wrap the ToType() variants. | 123 // Conversion handlers. These wrap the ToType() variants. |
124 #if defined(OS_MACOSX) | 124 #if defined(OS_MACOSX) |
(...skipping 28 matching lines...) Expand all Loading... |
153 // be cheaply copied. | 153 // be cheaply copied. |
154 scoped_refptr<internal::ImageStorage> storage_; | 154 scoped_refptr<internal::ImageStorage> storage_; |
155 | 155 |
156 friend class ::ImageTest; | 156 friend class ::ImageTest; |
157 friend class ::ImageMacTest; | 157 friend class ::ImageMacTest; |
158 }; | 158 }; |
159 | 159 |
160 } // namespace gfx | 160 } // namespace gfx |
161 | 161 |
162 #endif // UI_GFX_IMAGE_IMAGE_H_ | 162 #endif // UI_GFX_IMAGE_IMAGE_H_ |
OLD | NEW |