| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 size_t input_size); | 108 size_t input_size); |
| 109 | 109 |
| 110 // Creates an image from the PNG encoded input. | 110 // Creates an image from the PNG encoded input. |
| 111 static Image CreateFrom1xPNGBytes( | 111 static Image CreateFrom1xPNGBytes( |
| 112 const scoped_refptr<base::RefCountedMemory>& input); | 112 const scoped_refptr<base::RefCountedMemory>& input); |
| 113 | 113 |
| 114 // Converts the Image to the desired representation and stores it internally. | 114 // Converts the Image to the desired representation and stores it internally. |
| 115 // The returned result is a weak pointer owned by and scoped to the life of | 115 // The returned result is a weak pointer owned by and scoped to the life of |
| 116 // the Image. Must only be called if IsEmpty() is false. | 116 // the Image. Must only be called if IsEmpty() is false. |
| 117 const SkBitmap* ToSkBitmap() const; | 117 const SkBitmap* ToSkBitmap() const; |
| 118 const SkBitmap* ToSkBitmap2x() const; |
| 118 const ImageSkia* ToImageSkia() const; | 119 const ImageSkia* ToImageSkia() const; |
| 119 #if defined(OS_IOS) | 120 #if defined(OS_IOS) |
| 120 UIImage* ToUIImage() const; | 121 UIImage* ToUIImage() const; |
| 121 #elif defined(OS_MACOSX) | 122 #elif defined(OS_MACOSX) |
| 122 NSImage* ToNSImage() const; | 123 NSImage* ToNSImage() const; |
| 123 #endif | 124 #endif |
| 124 | 125 |
| 125 // Returns the raw PNG-encoded data for the bitmap at 1x. If the data is | 126 // Returns the raw PNG-encoded data for the bitmap at 1x. If the data is |
| 126 // unavailable, either because the image has no data for 1x or because it is | 127 // unavailable, either because the image has no data for 1x or because it is |
| 127 // empty, an empty RefCountedBytes object is returned. NULL is never | 128 // empty, an empty RefCountedBytes object is returned. NULL is never |
| 128 // returned. | 129 // returned. |
| 129 scoped_refptr<base::RefCountedMemory> As1xPNGBytes() const; | 130 scoped_refptr<base::RefCountedMemory> As1xPNGBytes() const; |
| 130 | 131 |
| 131 // Same as ToSkBitmap(), but returns a null SkBitmap if this image is empty. | 132 // Same as ToSkBitmap(), but returns a null SkBitmap if this image is empty. |
| 132 SkBitmap AsBitmap() const; | 133 SkBitmap AsBitmap() const; |
| 133 | 134 |
| 135 // Same as ToSkBitmap2x(), but returns a null SkBitmap if this image is empty. |
| 136 SkBitmap AsBitmap2x() const; |
| 137 |
| 134 // Same as ToImageSkia(), but returns an empty ImageSkia if this | 138 // Same as ToImageSkia(), but returns an empty ImageSkia if this |
| 135 // image is empty. | 139 // image is empty. |
| 136 ImageSkia AsImageSkia() const; | 140 ImageSkia AsImageSkia() const; |
| 137 | 141 |
| 138 #if defined(OS_MACOSX) && !defined(OS_IOS) | 142 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 139 // Same as ToSkBitmap(), but returns nil if this image is empty. | 143 // Same as ToSkBitmap(), but returns nil if this image is empty. |
| 140 NSImage* AsNSImage() const; | 144 NSImage* AsNSImage() const; |
| 141 #endif | 145 #endif |
| 142 | 146 |
| 143 // Performs a conversion, like above, but returns a copy of the result rather | 147 // Performs a conversion, like above, but returns a copy of the result rather |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 std::unique_ptr<internal::ImageRep> rep) const; | 199 std::unique_ptr<internal::ImageRep> rep) const; |
| 196 | 200 |
| 197 // Internal class that holds all the representations. This allows the Image to | 201 // Internal class that holds all the representations. This allows the Image to |
| 198 // be cheaply copied. | 202 // be cheaply copied. |
| 199 scoped_refptr<internal::ImageStorage> storage_; | 203 scoped_refptr<internal::ImageStorage> storage_; |
| 200 }; | 204 }; |
| 201 | 205 |
| 202 } // namespace gfx | 206 } // namespace gfx |
| 203 | 207 |
| 204 #endif // UI_GFX_IMAGE_IMAGE_H_ | 208 #endif // UI_GFX_IMAGE_IMAGE_H_ |
| OLD | NEW |