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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 // the Image. | 100 // the Image. |
101 const SkBitmap* ToSkBitmap() const; | 101 const SkBitmap* ToSkBitmap() const; |
102 const ImageSkia* ToImageSkia() const; | 102 const ImageSkia* ToImageSkia() const; |
103 #if defined(TOOLKIT_GTK) | 103 #if defined(TOOLKIT_GTK) |
104 GdkPixbuf* ToGdkPixbuf() const; | 104 GdkPixbuf* ToGdkPixbuf() const; |
105 CairoCachedSurface* const ToCairo() const; | 105 CairoCachedSurface* const ToCairo() const; |
106 #elif defined(OS_MACOSX) | 106 #elif defined(OS_MACOSX) |
107 NSImage* ToNSImage() const; | 107 NSImage* ToNSImage() const; |
108 #endif | 108 #endif |
109 | 109 |
| 110 // Same as ToSkBitmap(), but returns a null SkBitmap if this image is empty. |
| 111 SkBitmap AsBitmap() const; |
| 112 |
| 113 // Same as ToSkBitmap(), but returns a ImageSkia with a null SkBitmap if this |
| 114 // image is empty. |
| 115 ImageSkia AsImageSkia() const; |
| 116 |
110 // Performs a conversion, like above, but returns a copy of the result rather | 117 // Performs a conversion, like above, but returns a copy of the result rather |
111 // than a weak pointer. The caller is responsible for deleting the result. | 118 // than a weak pointer. The caller is responsible for deleting the result. |
112 // Note that the result is only a copy in terms of memory management; the | 119 // Note that the result is only a copy in terms of memory management; the |
113 // backing pixels are shared amongst all copies (a fact of each of the | 120 // backing pixels are shared amongst all copies (a fact of each of the |
114 // converted representations, rather than a limitation imposed by Image) and | 121 // converted representations, rather than a limitation imposed by Image) and |
115 // so the result should be considered immutable. | 122 // so the result should be considered immutable. |
116 ImageSkia* CopyImageSkia() const; | 123 ImageSkia* CopyImageSkia() const; |
117 SkBitmap* CopySkBitmap() const; | 124 SkBitmap* CopySkBitmap() const; |
118 #if defined(TOOLKIT_GTK) | 125 #if defined(TOOLKIT_GTK) |
119 GdkPixbuf* CopyGdkPixbuf() const; | 126 GdkPixbuf* CopyGdkPixbuf() const; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 // be cheaply copied. | 163 // be cheaply copied. |
157 scoped_refptr<internal::ImageStorage> storage_; | 164 scoped_refptr<internal::ImageStorage> storage_; |
158 | 165 |
159 friend class ::ImageTest; | 166 friend class ::ImageTest; |
160 friend class ::ImageMacTest; | 167 friend class ::ImageMacTest; |
161 }; | 168 }; |
162 | 169 |
163 } // namespace gfx | 170 } // namespace gfx |
164 | 171 |
165 #endif // UI_GFX_IMAGE_IMAGE_H_ | 172 #endif // UI_GFX_IMAGE_IMAGE_H_ |
OLD | NEW |