Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Side by Side Diff: ui/gfx/image/image.h

Issue 1456703004: ScopedPtrMap -> std::map from /ui/gfx/image (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/gfx/image/image.cc » ('j') | ui/gfx/image/image.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <map>
22 #include <vector> 23 #include <vector>
23 24
24 #include "base/basictypes.h" 25 #include "base/basictypes.h"
25 #include "base/containers/scoped_ptr_map.h"
26 #include "base/memory/ref_counted_memory.h" 26 #include "base/memory/ref_counted_memory.h"
27 #include "base/memory/scoped_ptr.h" 27 #include "base/memory/scoped_ptr.h"
28 #include "ui/gfx/gfx_export.h" 28 #include "ui/gfx/gfx_export.h"
29 #include "ui/gfx/native_widget_types.h" 29 #include "ui/gfx/native_widget_types.h"
30 30
31 #if defined(OS_MACOSX) && !defined(OS_IOS) 31 #if defined(OS_MACOSX) && !defined(OS_IOS)
32 typedef struct CGColorSpace* CGColorSpaceRef; 32 typedef struct CGColorSpace* CGColorSpaceRef;
33 #endif 33 #endif
34 34
35 class SkBitmap; 35 class SkBitmap;
(...skipping 10 matching lines...) Expand all
46 46
47 class GFX_EXPORT Image { 47 class GFX_EXPORT Image {
48 public: 48 public:
49 enum RepresentationType { 49 enum RepresentationType {
50 kImageRepCocoa, 50 kImageRepCocoa,
51 kImageRepCocoaTouch, 51 kImageRepCocoaTouch,
52 kImageRepSkia, 52 kImageRepSkia,
53 kImageRepPNG, 53 kImageRepPNG,
54 }; 54 };
55 55
56 typedef base::ScopedPtrMap<RepresentationType, scoped_ptr<internal::ImageRep>> 56 using RepresentationMap =
57 RepresentationMap; 57 std::map<RepresentationType, scoped_ptr<internal::ImageRep>>;
58 58
59 // Creates an empty image with no representations. 59 // Creates an empty image with no representations.
60 Image(); 60 Image();
61 61
62 // Creates a new image by copying the raw PNG-encoded input for use as the 62 // Creates a new image by copying the raw PNG-encoded input for use as the
63 // default representation. 63 // default representation.
64 explicit Image(const std::vector<ImagePNGRep>& image_reps); 64 explicit Image(const std::vector<ImagePNGRep>& image_reps);
65 65
66 // Creates a new image by copying the ImageSkia for use as the default 66 // Creates a new image by copying the ImageSkia for use as the default
67 // representation. 67 // representation.
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 void AddRepresentation(scoped_ptr<internal::ImageRep> rep) const; 185 void AddRepresentation(scoped_ptr<internal::ImageRep> rep) const;
186 186
187 // 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
188 // be cheaply copied. 188 // be cheaply copied.
189 scoped_refptr<internal::ImageStorage> storage_; 189 scoped_refptr<internal::ImageStorage> storage_;
190 }; 190 };
191 191
192 } // namespace gfx 192 } // namespace gfx
193 193
194 #endif // UI_GFX_IMAGE_IMAGE_H_ 194 #endif // UI_GFX_IMAGE_IMAGE_H_
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/image/image.cc » ('j') | ui/gfx/image/image.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698