OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef GFX_SCOPED_IMAGE_H_ | 5 #ifndef GFX_SCOPED_IMAGE_H_ |
6 #define GFX_SCOPED_IMAGE_H_ | 6 #define GFX_SCOPED_IMAGE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
11 #include "gfx/native_widget_types.h" | 11 #include "gfx/native_widget_types.h" |
12 #include "third_party/skia/include/core/SkBitmap.h" | 12 #include "third_party/skia/include/core/SkBitmap.h" |
13 | 13 |
14 #if defined(OS_LINUX) | 14 #if defined(OS_LINUX) |
15 #include <glib-object.h> | 15 #include <glib-object.h> |
16 #elif defined(OS_MACOSX) | 16 #elif defined(OS_MACOSX) |
17 #include "base/mac_util.h" | 17 #include "base/mac/mac_util.h" |
18 #endif | 18 #endif |
19 | 19 |
20 namespace gfx { | 20 namespace gfx { |
21 | 21 |
22 namespace internal { | 22 namespace internal { |
23 | 23 |
24 // ScopedImage is class that encapsulates one of the three platform-specific | 24 // ScopedImage is class that encapsulates one of the three platform-specific |
25 // images used: SkBitmap, NSImage, and GdkPixbuf. This is the abstract interface | 25 // images used: SkBitmap, NSImage, and GdkPixbuf. This is the abstract interface |
26 // that all ScopedImages respond to. This wrapper expects to own the image it | 26 // that all ScopedImages respond to. This wrapper expects to own the image it |
27 // holds, unless it is Release()ed or Free()ed. | 27 // holds, unless it is Release()ed or Free()ed. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 template <> | 99 template <> |
100 class ScopedImage<NSImage> : public gfx::internal::ScopedImage<NSImage> { | 100 class ScopedImage<NSImage> : public gfx::internal::ScopedImage<NSImage> { |
101 public: | 101 public: |
102 explicit ScopedImage(NSImage* image) | 102 explicit ScopedImage(NSImage* image) |
103 : gfx::internal::ScopedImage<NSImage>(image) {} | 103 : gfx::internal::ScopedImage<NSImage>(image) {} |
104 virtual ~ScopedImage() { | 104 virtual ~ScopedImage() { |
105 Free(); | 105 Free(); |
106 } | 106 } |
107 | 107 |
108 virtual void Free() { | 108 virtual void Free() { |
109 mac_util::NSObjectRelease(image_); | 109 base::mac::NSObjectRelease(image_); |
110 image_ = NULL; | 110 image_ = NULL; |
111 } | 111 } |
112 | 112 |
113 private: | 113 private: |
114 DISALLOW_COPY_AND_ASSIGN(ScopedImage); | 114 DISALLOW_COPY_AND_ASSIGN(ScopedImage); |
115 }; | 115 }; |
116 #endif // defined(OS_MACOSX) | 116 #endif // defined(OS_MACOSX) |
117 | 117 |
118 // Specialization for the GdkPixbuf type on Linux. | 118 // Specialization for the GdkPixbuf type on Linux. |
119 #if defined(OS_LINUX) | 119 #if defined(OS_LINUX) |
(...skipping 18 matching lines...) Expand all Loading... |
138 }; | 138 }; |
139 #endif // defined(OS_LINUX) | 139 #endif // defined(OS_LINUX) |
140 | 140 |
141 // Typedef ScopedNativeImage to the default template argument. This allows for | 141 // Typedef ScopedNativeImage to the default template argument. This allows for |
142 // easy exchange between gfx::NativeImage and a gfx::ScopedNativeImage. | 142 // easy exchange between gfx::NativeImage and a gfx::ScopedNativeImage. |
143 typedef ScopedImage<> ScopedNativeImage; | 143 typedef ScopedImage<> ScopedNativeImage; |
144 | 144 |
145 } // namespace gfx | 145 } // namespace gfx |
146 | 146 |
147 #endif // GFX_SCOPED_IMAGE_H_ | 147 #endif // GFX_SCOPED_IMAGE_H_ |
OLD | NEW |