| 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 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 #include <map> | 22 #include <map> |
| 23 #include <vector> | 23 #include <vector> |
| 24 | 24 |
| 25 #include "base/basictypes.h" | 25 #include "base/basictypes.h" |
| 26 #include "base/gtest_prod_util.h" | 26 #include "base/gtest_prod_util.h" |
| 27 #include "base/memory/ref_counted_memory.h" | 27 #include "base/memory/ref_counted_memory.h" |
| 28 #include "ui/base/ui_export.h" | 28 #include "ui/base/ui_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) |
| 32 #include <Carbon/Carbon.h> |
| 33 #endif |
| 34 |
| 31 class SkBitmap; | 35 class SkBitmap; |
| 32 | 36 |
| 33 namespace { | 37 namespace { |
| 34 class ImageTest; | 38 class ImageTest; |
| 35 class ImageMacTest; | 39 class ImageMacTest; |
| 36 } | 40 } |
| 37 | 41 |
| 38 namespace gfx { | 42 namespace gfx { |
| 39 struct ImagePNGRep; | 43 struct ImagePNGRep; |
| 40 class ImageSkia; | 44 class ImageSkia; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 bool IsEmpty() const; | 172 bool IsEmpty() const; |
| 169 | 173 |
| 170 // Width and height of image in DIP coordinate system. | 174 // Width and height of image in DIP coordinate system. |
| 171 int Width() const; | 175 int Width() const; |
| 172 int Height() const; | 176 int Height() const; |
| 173 gfx::Size Size() const; | 177 gfx::Size Size() const; |
| 174 | 178 |
| 175 // Swaps this image's internal representations with |other|. | 179 // Swaps this image's internal representations with |other|. |
| 176 void SwapRepresentations(gfx::Image* other); | 180 void SwapRepresentations(gfx::Image* other); |
| 177 | 181 |
| 182 #if defined(OS_MACOSX) |
| 183 // Set the default representation's color space. This is used for converting |
| 184 // to NSImage. This is used to compensate for PNGCodec not writing or reading |
| 185 // colorspace ancillary chunks. (sRGB, iCCP). |
| 186 void SetSourceColorSpace(CGColorSpaceRef color_space); |
| 187 #endif // OS_MACOSX |
| 188 |
| 178 private: | 189 private: |
| 179 // Returns the type of the default representation. | 190 // Returns the type of the default representation. |
| 180 RepresentationType DefaultRepresentationType() const; | 191 RepresentationType DefaultRepresentationType() const; |
| 181 | 192 |
| 182 // Returns the ImageRep of the appropriate type or NULL if there is no | 193 // Returns the ImageRep of the appropriate type or NULL if there is no |
| 183 // representation of that type (and must_exist is false). | 194 // representation of that type (and must_exist is false). |
| 184 internal::ImageRep* GetRepresentation( | 195 internal::ImageRep* GetRepresentation( |
| 185 RepresentationType rep_type, bool must_exist) const; | 196 RepresentationType rep_type, bool must_exist) const; |
| 186 | 197 |
| 187 // Stores a representation into the map. | 198 // Stores a representation into the map. |
| 188 void AddRepresentation(internal::ImageRep* rep) const; | 199 void AddRepresentation(internal::ImageRep* rep) const; |
| 189 | 200 |
| 190 // Internal class that holds all the representations. This allows the Image to | 201 // Internal class that holds all the representations. This allows the Image to |
| 191 // be cheaply copied. | 202 // be cheaply copied. |
| 192 scoped_refptr<internal::ImageStorage> storage_; | 203 scoped_refptr<internal::ImageStorage> storage_; |
| 193 | 204 |
| 194 friend class ::ImageTest; | 205 friend class ::ImageTest; |
| 195 friend class ::ImageMacTest; | 206 friend class ::ImageMacTest; |
| 196 }; | 207 }; |
| 197 | 208 |
| 198 } // namespace gfx | 209 } // namespace gfx |
| 199 | 210 |
| 200 #endif // UI_GFX_IMAGE_IMAGE_H_ | 211 #endif // UI_GFX_IMAGE_IMAGE_H_ |
| OLD | NEW |