| 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 #include "ui/gfx/image/image.h" | 5 #include "ui/gfx/image/image.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 private: | 333 private: |
| 334 NSImage* image_; | 334 NSImage* image_; |
| 335 | 335 |
| 336 DISALLOW_COPY_AND_ASSIGN(ImageRepCocoa); | 336 DISALLOW_COPY_AND_ASSIGN(ImageRepCocoa); |
| 337 }; | 337 }; |
| 338 #endif // defined(OS_MACOSX) | 338 #endif // defined(OS_MACOSX) |
| 339 | 339 |
| 340 // The Storage class acts similarly to the pixels in a SkBitmap: the Image | 340 // The Storage class acts similarly to the pixels in a SkBitmap: the Image |
| 341 // class holds a refptr instance of Storage, which in turn holds all the | 341 // class holds a refptr instance of Storage, which in turn holds all the |
| 342 // ImageReps. This way, the Image can be cheaply copied. | 342 // ImageReps. This way, the Image can be cheaply copied. |
| 343 // |
| 344 // This class is deliberately not RefCountedThreadSafe. Making it so does not |
| 345 // solve threading issues, as gfx::Image and its internal classes are |
| 346 // themselves not threadsafe. |
| 343 class ImageStorage : public base::RefCounted<ImageStorage> { | 347 class ImageStorage : public base::RefCounted<ImageStorage> { |
| 344 public: | 348 public: |
| 345 ImageStorage(Image::RepresentationType default_type) | 349 ImageStorage(Image::RepresentationType default_type) |
| 346 : default_representation_type_(default_type) | 350 : default_representation_type_(default_type) |
| 347 #if defined(OS_MACOSX) && !defined(OS_IOS) | 351 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 348 , | 352 , |
| 349 default_representation_color_space_( | 353 default_representation_color_space_( |
| 350 base::mac::GetGenericRGBColorSpace()) | 354 base::mac::GetGenericRGBColorSpace()) |
| 351 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | 355 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
| 352 { | 356 { |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 storage_->representations().insert(std::make_pair(type, std::move(rep))); | 765 storage_->representations().insert(std::make_pair(type, std::move(rep))); |
| 762 | 766 |
| 763 // insert should not fail (implies that there was already a representation of | 767 // insert should not fail (implies that there was already a representation of |
| 764 // that type in the map). | 768 // that type in the map). |
| 765 CHECK(result.second) << "type was already in map."; | 769 CHECK(result.second) << "type was already in map."; |
| 766 | 770 |
| 767 return result.first->second.get(); | 771 return result.first->second.get(); |
| 768 } | 772 } |
| 769 | 773 |
| 770 } // namespace gfx | 774 } // namespace gfx |
| OLD | NEW |