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 17 matching lines...) Expand all Loading... |
28 | 28 |
29 class SkBitmap; | 29 class SkBitmap; |
30 | 30 |
31 namespace { | 31 namespace { |
32 class ImageTest; | 32 class ImageTest; |
33 class ImageMacTest; | 33 class ImageMacTest; |
34 } | 34 } |
35 | 35 |
36 namespace gfx { | 36 namespace gfx { |
37 | 37 |
| 38 #if defined(TOOLKIT_USES_GTK) |
| 39 class CairoCachedSurface; |
| 40 #endif |
| 41 |
38 namespace internal { | 42 namespace internal { |
39 class ImageRep; | 43 class ImageRep; |
40 class ImageStorage; | 44 class ImageStorage; |
41 } | 45 } |
42 | 46 |
43 class UI_EXPORT Image { | 47 class UI_EXPORT Image { |
44 public: | 48 public: |
45 enum RepresentationType { | 49 enum RepresentationType { |
46 kImageRepGdk, | 50 kImageRepGdk, |
47 kImageRepCocoa, | 51 kImageRepCocoa, |
| 52 kImageRepCairoCache, |
48 kImageRepSkia, | 53 kImageRepSkia, |
49 }; | 54 }; |
50 | 55 |
51 typedef std::map<RepresentationType, internal::ImageRep*> RepresentationMap; | 56 typedef std::map<RepresentationType, internal::ImageRep*> RepresentationMap; |
52 | 57 |
53 // Creates a new image with the default representation. The object will take | 58 // Creates a new image with the default representation. The object will take |
54 // ownership of the image. | 59 // ownership of the image. |
55 explicit Image(const SkBitmap* bitmap); | 60 explicit Image(const SkBitmap* bitmap); |
56 | 61 |
57 // To create an Image that supports multiple resolutions pass a vector | 62 // To create an Image that supports multiple resolutions pass a vector |
(...skipping 19 matching lines...) Expand all Loading... |
77 // Deletes the image and, if the only owner of the storage, all of its cached | 82 // Deletes the image and, if the only owner of the storage, all of its cached |
78 // representations. | 83 // representations. |
79 ~Image(); | 84 ~Image(); |
80 | 85 |
81 // Converts the Image to the desired representation and stores it internally. | 86 // Converts the Image to the desired representation and stores it internally. |
82 // The returned result is a weak pointer owned by and scoped to the life of | 87 // The returned result is a weak pointer owned by and scoped to the life of |
83 // the Image. | 88 // the Image. |
84 const SkBitmap* ToSkBitmap() const; | 89 const SkBitmap* ToSkBitmap() const; |
85 #if defined(TOOLKIT_USES_GTK) | 90 #if defined(TOOLKIT_USES_GTK) |
86 GdkPixbuf* ToGdkPixbuf() const; | 91 GdkPixbuf* ToGdkPixbuf() const; |
| 92 CairoCachedSurface* const ToCairo() const; |
87 #elif defined(OS_MACOSX) | 93 #elif defined(OS_MACOSX) |
88 NSImage* ToNSImage() const; | 94 NSImage* ToNSImage() const; |
89 #endif | 95 #endif |
90 | 96 |
91 // Performs a conversion, like above, but returns a copy of the result rather | 97 // Performs a conversion, like above, but returns a copy of the result rather |
92 // than a weak pointer. The caller is responsible for deleting the result. | 98 // than a weak pointer. The caller is responsible for deleting the result. |
93 // Note that the result is only a copy in terms of memory management; the | 99 // Note that the result is only a copy in terms of memory management; the |
94 // backing pixels are shared amongst all copies (a fact of each of the | 100 // backing pixels are shared amongst all copies (a fact of each of the |
95 // converted representations, rather than a limitation imposed by Image) and | 101 // converted representations, rather than a limitation imposed by Image) and |
96 // so the result should be considered immutable. | 102 // so the result should be considered immutable. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 // be cheaply copied. | 152 // be cheaply copied. |
147 scoped_refptr<internal::ImageStorage> storage_; | 153 scoped_refptr<internal::ImageStorage> storage_; |
148 | 154 |
149 friend class ::ImageTest; | 155 friend class ::ImageTest; |
150 friend class ::ImageMacTest; | 156 friend class ::ImageMacTest; |
151 }; | 157 }; |
152 | 158 |
153 } // namespace gfx | 159 } // namespace gfx |
154 | 160 |
155 #endif // UI_GFX_IMAGE_IMAGE_H_ | 161 #endif // UI_GFX_IMAGE_IMAGE_H_ |
OLD | NEW |