OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 typedef std::map<RepresentationType, internal::ImageRep*> RepresentationMap; | 51 typedef std::map<RepresentationType, internal::ImageRep*> RepresentationMap; |
52 | 52 |
53 // Creates a new image with the default representation. The object will take | 53 // Creates a new image with the default representation. The object will take |
54 // ownership of the image. | 54 // ownership of the image. |
55 explicit Image(const SkBitmap* bitmap); | 55 explicit Image(const SkBitmap* bitmap); |
56 | 56 |
57 // To create an Image that supports multiple resolutions pass a vector | 57 // To create an Image that supports multiple resolutions pass a vector |
58 // of bitmaps, one for each resolution. | 58 // of bitmaps, one for each resolution. |
59 explicit Image(const std::vector<const SkBitmap*>& bitmaps); | 59 explicit Image(const std::vector<const SkBitmap*>& bitmaps); |
60 | 60 |
61 #if defined(OS_LINUX) | 61 #if defined(TOOLKIT_USES_GTK) |
62 // Does not increase |pixbuf|'s reference count; expects to take ownership. | 62 // Does not increase |pixbuf|'s reference count; expects to take ownership. |
63 explicit Image(GdkPixbuf* pixbuf); | 63 explicit Image(GdkPixbuf* pixbuf); |
64 #elif defined(OS_MACOSX) | 64 #elif defined(OS_MACOSX) |
65 // Does not retain |image|; expects to take ownership. | 65 // Does not retain |image|; expects to take ownership. |
66 // A single NSImage object can contain multiple bitmaps so there's no reason | 66 // A single NSImage object can contain multiple bitmaps so there's no reason |
67 // to pass a vector of these. | 67 // to pass a vector of these. |
68 explicit Image(NSImage* image); | 68 explicit Image(NSImage* image); |
69 #endif | 69 #endif |
70 | 70 |
71 // Initializes a new Image by AddRef()ing |other|'s internal storage. | 71 // Initializes a new Image by AddRef()ing |other|'s internal storage. |
72 Image(const Image& other); | 72 Image(const Image& other); |
73 | 73 |
74 // Copies a reference to |other|'s storage. | 74 // Copies a reference to |other|'s storage. |
75 Image& operator=(const Image& other); | 75 Image& operator=(const Image& other); |
76 | 76 |
77 // Deletes the image and, if the only owner of the storage, all of its cached | 77 // Deletes the image and, if the only owner of the storage, all of its cached |
78 // representations. | 78 // representations. |
79 ~Image(); | 79 ~Image(); |
80 | 80 |
81 // Conversion handlers. | 81 // Conversion handlers. |
82 operator const SkBitmap*() const ; | 82 operator const SkBitmap*() const ; |
83 operator const SkBitmap&() const; | 83 operator const SkBitmap&() const; |
84 #if defined(OS_LINUX) | 84 #if defined(TOOLKIT_USES_GTK) |
85 operator GdkPixbuf*() const; | 85 operator GdkPixbuf*() const; |
86 #elif defined(OS_MACOSX) | 86 #elif defined(OS_MACOSX) |
87 operator NSImage*() const; | 87 operator NSImage*() const; |
88 #endif | 88 #endif |
89 | 89 |
90 // Gets the number of bitmaps in this image. This may cause a conversion | 90 // Gets the number of bitmaps in this image. This may cause a conversion |
91 // to a bitmap representation. Note, this function and GetSkBitmapAtIndex() | 91 // to a bitmap representation. Note, this function and GetSkBitmapAtIndex() |
92 // are primarily meant to be used by the theme provider. | 92 // are primarily meant to be used by the theme provider. |
93 size_t GetNumberOfSkBitmaps() const; | 93 size_t GetNumberOfSkBitmaps() const; |
94 | 94 |
(...skipping 26 matching lines...) Expand all Loading... |
121 // be cheaply copied. | 121 // be cheaply copied. |
122 scoped_refptr<internal::ImageStorage> storage_; | 122 scoped_refptr<internal::ImageStorage> storage_; |
123 | 123 |
124 friend class ::ImageTest; | 124 friend class ::ImageTest; |
125 friend class ::ImageMacTest; | 125 friend class ::ImageMacTest; |
126 }; | 126 }; |
127 | 127 |
128 } // namespace gfx | 128 } // namespace gfx |
129 | 129 |
130 #endif // UI_GFX_IMAGE_H_ | 130 #endif // UI_GFX_IMAGE_H_ |
OLD | NEW |