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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
413 | 413 |
414 Image::Image(const ImageSkia& image) { | 414 Image::Image(const ImageSkia& image) { |
415 if (!image.isNull()) { | 415 if (!image.isNull()) { |
416 storage_ = new internal::ImageStorage(Image::kImageRepSkia); | 416 storage_ = new internal::ImageStorage(Image::kImageRepSkia); |
417 AddRepresentation( | 417 AddRepresentation( |
418 base::MakeUnique<internal::ImageRepSkia>(new ImageSkia(image))); | 418 base::MakeUnique<internal::ImageRepSkia>(new ImageSkia(image))); |
419 } | 419 } |
420 } | 420 } |
421 | 421 |
422 #if defined(OS_IOS) | 422 #if defined(OS_IOS) |
423 Image::Image(UIImage* image) | 423 Image::Image(UIImage* image) : Image(image, false) {} |
sdefresne
2016/12/06 10:54:11
Image::Image(UIImage* image) : Image(image, base::
stkhapugin
2016/12/06 12:10:56
Done.
| |
424 | |
425 Image::Image(UIImage* image, base::scoped_policy::OwnershipPolicy policy) | |
424 : storage_(new internal::ImageStorage(Image::kImageRepCocoaTouch)) { | 426 : storage_(new internal::ImageStorage(Image::kImageRepCocoaTouch)) { |
425 if (image) | 427 if (image) { |
428 if (policy == base::scoped_policy::RETAIN) | |
429 base::mac::NSObjectRetain(image); | |
426 AddRepresentation(base::MakeUnique<internal::ImageRepCocoaTouch>(image)); | 430 AddRepresentation(base::MakeUnique<internal::ImageRepCocoaTouch>(image)); |
431 } | |
427 } | 432 } |
428 #elif defined(OS_MACOSX) | 433 #elif defined(OS_MACOSX) |
429 Image::Image(NSImage* image) { | 434 Image::Image(NSImage* image) { |
430 if (image) { | 435 if (image) { |
431 storage_ = new internal::ImageStorage(Image::kImageRepCocoa); | 436 storage_ = new internal::ImageStorage(Image::kImageRepCocoa); |
432 AddRepresentation(base::MakeUnique<internal::ImageRepCocoa>(image)); | 437 AddRepresentation(base::MakeUnique<internal::ImageRepCocoa>(image)); |
433 } | 438 } |
434 } | 439 } |
435 #endif | 440 #endif |
436 | 441 |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
756 storage_->representations().insert(std::make_pair(type, std::move(rep))); | 761 storage_->representations().insert(std::make_pair(type, std::move(rep))); |
757 | 762 |
758 // insert should not fail (implies that there was already a representation of | 763 // insert should not fail (implies that there was already a representation of |
759 // that type in the map). | 764 // that type in the map). |
760 CHECK(result.second) << "type was already in map."; | 765 CHECK(result.second) << "type was already in map."; |
761 | 766 |
762 return result.first->second.get(); | 767 return result.first->second.get(); |
763 } | 768 } |
764 | 769 |
765 } // namespace gfx | 770 } // namespace gfx |
OLD | NEW |