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. The object will take | 65 // Creates a new image with the default representation. The object will take |
sky
2012/05/08 22:38:07
Remove second sentence since it isn't applicable a
| |
66 // ownership of the image. | 66 // ownership of the image. |
67 explicit Image(const ImageSkia& image); | |
68 | |
69 // Creates a new image with the default representation. The object will take | |
70 // ownership of the image. | |
67 explicit Image(const SkBitmap* bitmap); | 71 explicit Image(const SkBitmap* bitmap); |
68 | 72 |
69 // Creates a new image by copying the bitmap for use as the default | 73 // Creates a new image by copying the bitmap for use as the default |
70 // representation. | 74 // representation. |
71 explicit Image(const SkBitmap& bitmap); | 75 explicit Image(const SkBitmap& bitmap); |
72 | 76 |
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) | 77 #if defined(TOOLKIT_GTK) |
78 // Does not increase |pixbuf|'s reference count; expects to take ownership. | 78 // Does not increase |pixbuf|'s reference count; expects to take ownership. |
79 explicit Image(GdkPixbuf* pixbuf); | 79 explicit Image(GdkPixbuf* pixbuf); |
80 #elif defined(OS_MACOSX) | 80 #elif defined(OS_MACOSX) |
81 // Does not retain |image|; expects to take ownership. | 81 // Does not retain |image|; expects to take ownership. |
82 // A single NSImage object can contain multiple bitmaps so there's no reason | 82 // A single NSImage object can contain multiple bitmaps so there's no reason |
83 // to pass a vector of these. | 83 // to pass a vector of these. |
84 explicit Image(NSImage* image); | 84 explicit Image(NSImage* image); |
85 #endif | 85 #endif |
86 | 86 |
(...skipping 18 matching lines...) Expand all Loading... | |
105 #elif defined(OS_MACOSX) | 105 #elif defined(OS_MACOSX) |
106 NSImage* ToNSImage() const; | 106 NSImage* ToNSImage() const; |
107 #endif | 107 #endif |
108 | 108 |
109 // Performs a conversion, like above, but returns a copy of the result rather | 109 // 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. | 110 // 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 | 111 // 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 | 112 // backing pixels are shared amongst all copies (a fact of each of the |
113 // converted representations, rather than a limitation imposed by Image) and | 113 // converted representations, rather than a limitation imposed by Image) and |
114 // so the result should be considered immutable. | 114 // so the result should be considered immutable. |
115 ImageSkia* CopyImageSkia() const; | |
115 SkBitmap* CopySkBitmap() const; | 116 SkBitmap* CopySkBitmap() const; |
116 #if defined(TOOLKIT_GTK) | 117 #if defined(TOOLKIT_GTK) |
117 GdkPixbuf* CopyGdkPixbuf() const; | 118 GdkPixbuf* CopyGdkPixbuf() const; |
118 #elif defined(OS_MACOSX) | 119 #elif defined(OS_MACOSX) |
119 NSImage* CopyNSImage() const; | 120 NSImage* CopyNSImage() const; |
120 #endif | 121 #endif |
121 | 122 |
122 // DEPRECATED ---------------------------------------------------------------- | 123 // DEPRECATED ---------------------------------------------------------------- |
123 // Conversion handlers. These wrap the ToType() variants. | 124 // Conversion handlers. These wrap the ToType() variants. |
124 #if defined(OS_MACOSX) | 125 #if defined(OS_MACOSX) |
(...skipping 28 matching lines...) Expand all Loading... | |
153 // be cheaply copied. | 154 // be cheaply copied. |
154 scoped_refptr<internal::ImageStorage> storage_; | 155 scoped_refptr<internal::ImageStorage> storage_; |
155 | 156 |
156 friend class ::ImageTest; | 157 friend class ::ImageTest; |
157 friend class ::ImageMacTest; | 158 friend class ::ImageMacTest; |
158 }; | 159 }; |
159 | 160 |
160 } // namespace gfx | 161 } // namespace gfx |
161 | 162 |
162 #endif // UI_GFX_IMAGE_IMAGE_H_ | 163 #endif // UI_GFX_IMAGE_IMAGE_H_ |
OLD | NEW |