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 |
11 // tied to the lifetime of the Image's internal storage. To allow Images to be | 11 // tied to the lifetime of the Image's internal storage. To allow Images to be |
12 // cheaply passed around by value, the actual image data is stored in a ref- | 12 // cheaply passed around by value, the actual image data is stored in a ref- |
13 // counted member. When all Images referencing this storage are deleted, the | 13 // counted member. When all Images referencing this storage are deleted, the |
14 // actual representations are deleted, too. | 14 // actual representations are deleted, too. |
15 // | 15 // |
16 // Images can be empty, in which case they have no backing representation. | 16 // Images can be empty, in which case they have no backing representation. |
17 // Attempting to use an empty Image will result in a crash. | 17 // Attempting to use an empty Image will result in a crash. |
18 | 18 |
19 #ifndef UI_GFX_IMAGE_IMAGE_H_ | 19 #ifndef UI_GFX_IMAGE_IMAGE_H_ |
20 #define UI_GFX_IMAGE_IMAGE_H_ | 20 #define UI_GFX_IMAGE_IMAGE_H_ |
21 | 21 |
22 #include <vector> | 22 #include <vector> |
23 | 23 |
24 #include "base/basictypes.h" | 24 #include "base/basictypes.h" |
25 #include "base/containers/scoped_ptr_map.h" | 25 #include "base/containers/scoped_ptr_map.h" |
26 #include "base/gtest_prod_util.h" | |
27 #include "base/memory/ref_counted_memory.h" | 26 #include "base/memory/ref_counted_memory.h" |
28 #include "base/memory/scoped_ptr.h" | 27 #include "base/memory/scoped_ptr.h" |
29 #include "ui/gfx/gfx_export.h" | 28 #include "ui/gfx/gfx_export.h" |
30 #include "ui/gfx/native_widget_types.h" | 29 #include "ui/gfx/native_widget_types.h" |
31 | 30 |
32 #if defined(OS_MACOSX) && !defined(OS_IOS) | 31 #if defined(OS_MACOSX) && !defined(OS_IOS) |
33 typedef struct CGColorSpace* CGColorSpaceRef; | 32 typedef struct CGColorSpace* CGColorSpaceRef; |
34 #endif | 33 #endif |
35 | 34 |
36 class SkBitmap; | 35 class SkBitmap; |
37 | 36 |
38 namespace { | |
39 class ImageTest; | |
40 class ImageMacTest; | |
41 } | |
42 | |
43 namespace gfx { | 37 namespace gfx { |
44 struct ImagePNGRep; | 38 struct ImagePNGRep; |
45 class ImageSkia; | 39 class ImageSkia; |
46 class Size; | 40 class Size; |
47 | 41 |
48 namespace internal { | 42 namespace internal { |
49 class ImageRep; | 43 class ImageRep; |
50 class ImageStorage; | 44 class ImageStorage; |
51 } | 45 } |
52 | 46 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 // representation of that type (and must_exist is false). | 180 // representation of that type (and must_exist is false). |
187 internal::ImageRep* GetRepresentation( | 181 internal::ImageRep* GetRepresentation( |
188 RepresentationType rep_type, bool must_exist) const; | 182 RepresentationType rep_type, bool must_exist) const; |
189 | 183 |
190 // Stores a representation into the map. | 184 // Stores a representation into the map. |
191 void AddRepresentation(scoped_ptr<internal::ImageRep> rep) const; | 185 void AddRepresentation(scoped_ptr<internal::ImageRep> rep) const; |
192 | 186 |
193 // Internal class that holds all the representations. This allows the Image to | 187 // Internal class that holds all the representations. This allows the Image to |
194 // be cheaply copied. | 188 // be cheaply copied. |
195 scoped_refptr<internal::ImageStorage> storage_; | 189 scoped_refptr<internal::ImageStorage> storage_; |
196 | |
197 friend class ::ImageTest; | |
198 friend class ::ImageMacTest; | |
199 }; | 190 }; |
200 | 191 |
201 } // namespace gfx | 192 } // namespace gfx |
202 | 193 |
203 #endif // UI_GFX_IMAGE_IMAGE_H_ | 194 #endif // UI_GFX_IMAGE_IMAGE_H_ |
OLD | NEW |