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

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

Issue 340613004: Use ImageSkiaSource to create ImageSkia from ImagePNGReps (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test util fix Created 6 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/gfx/image/image_unittest.cc » ('j') | no next file with comments »
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 #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 9
9 #include "base/logging.h" 10 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "base/stl_util.h" 12 #include "base/stl_util.h"
12 #include "third_party/skia/include/core/SkBitmap.h" 13 #include "third_party/skia/include/core/SkBitmap.h"
13 #include "ui/gfx/image/image_png_rep.h" 14 #include "ui/gfx/image/image_png_rep.h"
14 #include "ui/gfx/image/image_skia.h" 15 #include "ui/gfx/image/image_skia.h"
16 #include "ui/gfx/image/image_skia_source.h"
15 #include "ui/gfx/size.h" 17 #include "ui/gfx/size.h"
16 18
17 #if !defined(OS_IOS) 19 #if !defined(OS_IOS)
18 #include "ui/gfx/codec/png_codec.h" 20 #include "ui/gfx/codec/png_codec.h"
19 #endif 21 #endif
20 22
21 #if defined(OS_IOS) 23 #if defined(OS_IOS)
22 #include "base/mac/foundation_util.h" 24 #include "base/mac/foundation_util.h"
23 #include "ui/gfx/image/image_skia_util_ios.h" 25 #include "ui/gfx/image/image_skia_util_ios.h"
24 #elif defined(OS_MACOSX) 26 #elif defined(OS_MACOSX)
25 #include "base/mac/mac_util.h" 27 #include "base/mac/mac_util.h"
26 #include "ui/gfx/image/image_skia_util_mac.h" 28 #include "ui/gfx/image/image_skia_util_mac.h"
27 #endif 29 #endif
28 30
29 namespace gfx { 31 namespace gfx {
30 32
31 namespace internal { 33 namespace internal {
32 34
33 #if defined(OS_IOS) 35 #if defined(OS_IOS)
34 scoped_refptr<base::RefCountedMemory> Get1xPNGBytesFromUIImage( 36 scoped_refptr<base::RefCountedMemory> Get1xPNGBytesFromUIImage(
35 UIImage* uiimage); 37 UIImage* uiimage);
36 // Caller takes ownership of the returned UIImage. 38 // Caller takes ownership of the returned UIImage.
37 UIImage* CreateUIImageFromPNG( 39 UIImage* CreateUIImageFromPNG(
38 const std::vector<gfx::ImagePNGRep>& image_png_reps); 40 const std::vector<ImagePNGRep>& image_png_reps);
39 gfx::Size UIImageSize(UIImage* image); 41 gfx::Size UIImageSize(UIImage* image);
40 #elif defined(OS_MACOSX) 42 #elif defined(OS_MACOSX)
41 scoped_refptr<base::RefCountedMemory> Get1xPNGBytesFromNSImage( 43 scoped_refptr<base::RefCountedMemory> Get1xPNGBytesFromNSImage(
42 NSImage* nsimage); 44 NSImage* nsimage);
43 // Caller takes ownership of the returned NSImage. 45 // Caller takes ownership of the returned NSImage.
44 NSImage* NSImageFromPNG(const std::vector<gfx::ImagePNGRep>& image_png_reps, 46 NSImage* NSImageFromPNG(const std::vector<ImagePNGRep>& image_png_reps,
45 CGColorSpaceRef color_space); 47 CGColorSpaceRef color_space);
46 gfx::Size NSImageSize(NSImage* image); 48 gfx::Size NSImageSize(NSImage* image);
47 #endif // defined(OS_MACOSX) 49 #endif // defined(OS_MACOSX)
48 50
49 #if defined(OS_IOS) 51 #if defined(OS_IOS)
50 ImageSkia* ImageSkiaFromPNG( 52 ImageSkia* ImageSkiaFromPNG(
51 const std::vector<gfx::ImagePNGRep>& image_png_reps); 53 const std::vector<ImagePNGRep>& image_png_reps);
52 scoped_refptr<base::RefCountedMemory> Get1xPNGBytesFromImageSkia( 54 scoped_refptr<base::RefCountedMemory> Get1xPNGBytesFromImageSkia(
53 const ImageSkia* skia); 55 const ImageSkia* skia);
54 #else 56 #else
55 // Returns a 16x16 red image to visually show error in decoding PNG. 57 // Returns a 16x16 red image to visually show error in decoding PNG.
56 // Caller takes ownership of returned ImageSkia. 58 // Caller takes ownership of returned ImageSkia.
57 ImageSkia* GetErrorImageSkia() { 59 ImageSkia* GetErrorImageSkia() {
58 SkBitmap bitmap; 60 SkBitmap bitmap;
59 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 16, 16); 61 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 16, 16);
60 bitmap.allocPixels(); 62 bitmap.allocPixels();
61 bitmap.eraseARGB(0xff, 0xff, 0, 0); 63 bitmap.eraseARGB(0xff, 0xff, 0, 0);
62 return new gfx::ImageSkia(gfx::ImageSkiaRep(bitmap, 1.0f)); 64 return new ImageSkia(ImageSkiaRep(bitmap, 1.0f));
63 } 65 }
64 66
67 class PNGImageSource : public ImageSkiaSource {
68 public:
69 PNGImageSource() {}
70 virtual ~PNGImageSource() {}
71
72 virtual ImageSkiaRep GetImageForScale(float scale) OVERRIDE {
73 if (image_skia_reps_.empty())
74 return ImageSkiaRep();
75
76 const ImageSkiaRep* rep = NULL;
77 // gfx::ImageSkia passes one of the resource scale factor, and
pkotwicz 2014/06/19 21:09:09 How about: "gfx::ImageSkia passes one of the resou
oshima 2014/06/19 21:29:58 I'm planning to do some cleanup there.
oshima 2014/06/19 21:29:58 Done.
78 // the source should return
79 // 1) the highest scale if all available scales are smaller than |scale|.
80 // 2) or the smallest one that is larger than |scale|.
81 for (ImageSkiaRepSet::const_iterator iter = image_skia_reps_.begin();
82 iter != image_skia_reps_.end(); ++iter) {
83 if ((*iter).scale() == scale)
84 return (*iter);
85 if (!rep || rep->scale() < (*iter).scale())
86 rep = &(*iter);
87 if (rep->scale() >= scale)
88 break;
89 }
90 return rep ? *rep : ImageSkiaRep();
91 }
92
93 const gfx::Size size() const {
94 return size_;
95 }
96
97 bool AddPngData(const ImagePNGRep& png_rep) {
98 const gfx::ImageSkiaRep rep = ToImageSkiaRep(png_rep);
pkotwicz 2014/06/19 21:09:09 Nit: the const here is unnecessary
oshima 2014/06/19 21:29:58 I think this is fine. It guarantees that rep won't
pkotwicz 2014/06/19 21:41:46 We insert |rep| by copy into |image_skia_reps_| so
99 if (rep.is_null())
100 return false;
101 if (size_.IsEmpty())
102 size_ = gfx::Size(rep.GetWidth(), rep.GetHeight());
103 image_skia_reps_.insert(rep);
104 return true;
105 }
106
107 static ImageSkiaRep ToImageSkiaRep(const ImagePNGRep& png_rep) {
108 scoped_refptr<base::RefCountedMemory> raw_data = png_rep.raw_data;
109 CHECK(raw_data.get());
110 SkBitmap bitmap;
111 if (!PNGCodec::Decode(raw_data->front(), raw_data->size(),
112 &bitmap)) {
113 LOG(ERROR) << "Unable to decode PNG for " << png_rep.scale << ".";
114 return ImageSkiaRep();
115 }
116 return ImageSkiaRep(bitmap, png_rep.scale);
117 }
118
119 private:
120 struct Compare {
121 bool operator()(const ImageSkiaRep& rep1, const ImageSkiaRep& rep2) {
122 return rep1.scale() < rep2.scale();
123 }
124 };
125
126 typedef std::set<ImageSkiaRep, Compare> ImageSkiaRepSet;
127 ImageSkiaRepSet image_skia_reps_;
128 gfx::Size size_;
129
130 DISALLOW_COPY_AND_ASSIGN(PNGImageSource);
131 };
132
65 ImageSkia* ImageSkiaFromPNG( 133 ImageSkia* ImageSkiaFromPNG(
66 const std::vector<gfx::ImagePNGRep>& image_png_reps) { 134 const std::vector<ImagePNGRep>& image_png_reps) {
67 if (image_png_reps.empty()) 135 if (image_png_reps.empty())
68 return GetErrorImageSkia(); 136 return GetErrorImageSkia();
137 scoped_ptr<PNGImageSource> image_source(new PNGImageSource);
69 138
70 scoped_ptr<gfx::ImageSkia> image_skia(new ImageSkia());
71 for (size_t i = 0; i < image_png_reps.size(); ++i) { 139 for (size_t i = 0; i < image_png_reps.size(); ++i) {
72 scoped_refptr<base::RefCountedMemory> raw_data = 140 if (!image_source->AddPngData(image_png_reps[i]))
73 image_png_reps[i].raw_data;
74 CHECK(raw_data.get());
75 SkBitmap bitmap;
76 if (!gfx::PNGCodec::Decode(raw_data->front(), raw_data->size(),
77 &bitmap)) {
78 LOG(ERROR) << "Unable to decode PNG for "
79 << image_png_reps[i].scale
80 << ".";
81 return GetErrorImageSkia(); 141 return GetErrorImageSkia();
82 }
83 image_skia->AddRepresentation(gfx::ImageSkiaRep(
84 bitmap, image_png_reps[i].scale));
85 } 142 }
86 return image_skia.release(); 143 const gfx::Size& size = image_source->size();
144 DCHECK(!size.IsEmpty());
145 if (size.IsEmpty())
146 return GetErrorImageSkia();
147 return new ImageSkia(image_source.release(), size);
87 } 148 }
88 149
89 scoped_refptr<base::RefCountedMemory> Get1xPNGBytesFromImageSkia( 150 scoped_refptr<base::RefCountedMemory> Get1xPNGBytesFromImageSkia(
90 const ImageSkia* image_skia) { 151 const ImageSkia* image_skia) {
91 ImageSkiaRep image_skia_rep = image_skia->GetRepresentation(1.0f); 152 ImageSkiaRep image_skia_rep = image_skia->GetRepresentation(1.0f);
92 153
93 scoped_refptr<base::RefCountedBytes> png_bytes(new base::RefCountedBytes()); 154 scoped_refptr<base::RefCountedBytes> png_bytes(new base::RefCountedBytes());
94 if (image_skia_rep.scale() != 1.0f || 155 if (image_skia_rep.scale() != 1.0f ||
95 !gfx::PNGCodec::EncodeBGRASkBitmap(image_skia_rep.sk_bitmap(), false, 156 !PNGCodec::EncodeBGRASkBitmap(image_skia_rep.sk_bitmap(), false,
96 &png_bytes->data())) { 157 &png_bytes->data())) {
97 return NULL; 158 return NULL;
98 } 159 }
99 return png_bytes; 160 return png_bytes;
100 } 161 }
101 #endif 162 #endif
102 163
103 class ImageRepPNG; 164 class ImageRepPNG;
104 class ImageRepSkia; 165 class ImageRepSkia;
105 class ImageRepCocoa; 166 class ImageRepCocoa;
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 356
296 DISALLOW_COPY_AND_ASSIGN(ImageRepCocoa); 357 DISALLOW_COPY_AND_ASSIGN(ImageRepCocoa);
297 }; 358 };
298 #endif // defined(OS_MACOSX) 359 #endif // defined(OS_MACOSX)
299 360
300 // The Storage class acts similarly to the pixels in a SkBitmap: the Image 361 // The Storage class acts similarly to the pixels in a SkBitmap: the Image
301 // class holds a refptr instance of Storage, which in turn holds all the 362 // class holds a refptr instance of Storage, which in turn holds all the
302 // ImageReps. This way, the Image can be cheaply copied. 363 // ImageReps. This way, the Image can be cheaply copied.
303 class ImageStorage : public base::RefCounted<ImageStorage> { 364 class ImageStorage : public base::RefCounted<ImageStorage> {
304 public: 365 public:
305 ImageStorage(gfx::Image::RepresentationType default_type) 366 ImageStorage(Image::RepresentationType default_type)
306 : default_representation_type_(default_type), 367 : default_representation_type_(default_type),
307 #if defined(OS_MACOSX) && !defined(OS_IOS) 368 #if defined(OS_MACOSX) && !defined(OS_IOS)
308 default_representation_color_space_( 369 default_representation_color_space_(
309 base::mac::GetGenericRGBColorSpace()), 370 base::mac::GetGenericRGBColorSpace()),
310 #endif // defined(OS_MACOSX) && !defined(OS_IOS) 371 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
311 representations_deleter_(&representations_) { 372 representations_deleter_(&representations_) {
312 } 373 }
313 374
314 gfx::Image::RepresentationType default_representation_type() { 375 Image::RepresentationType default_representation_type() {
315 return default_representation_type_; 376 return default_representation_type_;
316 } 377 }
317 gfx::Image::RepresentationMap& representations() { return representations_; } 378 Image::RepresentationMap& representations() { return representations_; }
318 379
319 #if defined(OS_MACOSX) && !defined(OS_IOS) 380 #if defined(OS_MACOSX) && !defined(OS_IOS)
320 void set_default_representation_color_space(CGColorSpaceRef color_space) { 381 void set_default_representation_color_space(CGColorSpaceRef color_space) {
321 default_representation_color_space_ = color_space; 382 default_representation_color_space_ = color_space;
322 } 383 }
323 CGColorSpaceRef default_representation_color_space() { 384 CGColorSpaceRef default_representation_color_space() {
324 return default_representation_color_space_; 385 return default_representation_color_space_;
325 } 386 }
326 #endif // defined(OS_MACOSX) && !defined(OS_IOS) 387 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
327 388
328 private: 389 private:
329 friend class base::RefCounted<ImageStorage>; 390 friend class base::RefCounted<ImageStorage>;
330 391
331 ~ImageStorage() {} 392 ~ImageStorage() {}
332 393
333 // The type of image that was passed to the constructor. This key will always 394 // The type of image that was passed to the constructor. This key will always
334 // exist in the |representations_| map. 395 // exist in the |representations_| map.
335 gfx::Image::RepresentationType default_representation_type_; 396 Image::RepresentationType default_representation_type_;
336 397
337 #if defined(OS_MACOSX) && !defined(OS_IOS) 398 #if defined(OS_MACOSX) && !defined(OS_IOS)
338 // The default representation's colorspace. This is used for converting to 399 // The default representation's colorspace. This is used for converting to
339 // NSImage. This field exists to compensate for PNGCodec not writing or 400 // NSImage. This field exists to compensate for PNGCodec not writing or
340 // reading colorspace ancillary chunks. (sRGB, iCCP). 401 // reading colorspace ancillary chunks. (sRGB, iCCP).
341 // Not owned. 402 // Not owned.
342 CGColorSpaceRef default_representation_color_space_; 403 CGColorSpaceRef default_representation_color_space_;
343 #endif // defined(OS_MACOSX) && !defined(OS_IOS) 404 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
344 405
345 // All the representations of an Image. Size will always be at least one, with 406 // All the representations of an Image. Size will always be at least one, with
346 // more for any converted representations. 407 // more for any converted representations.
347 gfx::Image::RepresentationMap representations_; 408 Image::RepresentationMap representations_;
348 409
349 STLValueDeleter<Image::RepresentationMap> representations_deleter_; 410 STLValueDeleter<Image::RepresentationMap> representations_deleter_;
350 411
351 DISALLOW_COPY_AND_ASSIGN(ImageStorage); 412 DISALLOW_COPY_AND_ASSIGN(ImageStorage);
352 }; 413 };
353 414
354 } // namespace internal 415 } // namespace internal
355 416
356 Image::Image() { 417 Image::Image() {
357 // |storage_| is NULL for empty Images. 418 // |storage_| is NULL for empty Images.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 Image& Image::operator=(const Image& other) { 467 Image& Image::operator=(const Image& other) {
407 storage_ = other.storage_; 468 storage_ = other.storage_;
408 return *this; 469 return *this;
409 } 470 }
410 471
411 Image::~Image() { 472 Image::~Image() {
412 } 473 }
413 474
414 // static 475 // static
415 Image Image::CreateFrom1xBitmap(const SkBitmap& bitmap) { 476 Image Image::CreateFrom1xBitmap(const SkBitmap& bitmap) {
416 return gfx::Image(ImageSkia::CreateFrom1xBitmap(bitmap)); 477 return Image(ImageSkia::CreateFrom1xBitmap(bitmap));
417 } 478 }
418 479
419 // static 480 // static
420 Image Image::CreateFrom1xPNGBytes(const unsigned char* input, 481 Image Image::CreateFrom1xPNGBytes(const unsigned char* input,
421 size_t input_size) { 482 size_t input_size) {
422 if (input_size == 0u) 483 if (input_size == 0u)
423 return gfx::Image(); 484 return Image();
424 485
425 scoped_refptr<base::RefCountedBytes> raw_data(new base::RefCountedBytes()); 486 scoped_refptr<base::RefCountedBytes> raw_data(new base::RefCountedBytes());
426 raw_data->data().assign(input, input + input_size); 487 raw_data->data().assign(input, input + input_size);
427 488
428 return CreateFrom1xPNGBytes(raw_data); 489 return CreateFrom1xPNGBytes(raw_data);
429 } 490 }
430 491
431 Image Image::CreateFrom1xPNGBytes( 492 Image Image::CreateFrom1xPNGBytes(
432 const scoped_refptr<base::RefCountedMemory>& input) { 493 const scoped_refptr<base::RefCountedMemory>& input) {
433 if (!input.get() || input->size() == 0u) 494 if (!input.get() || input->size() == 0u)
434 return gfx::Image(); 495 return Image();
435 496
436 std::vector<gfx::ImagePNGRep> image_reps; 497 std::vector<ImagePNGRep> image_reps;
437 image_reps.push_back(ImagePNGRep(input, 1.0f)); 498 image_reps.push_back(ImagePNGRep(input, 1.0f));
438 return gfx::Image(image_reps); 499 return Image(image_reps);
439 } 500 }
440 501
441 const SkBitmap* Image::ToSkBitmap() const { 502 const SkBitmap* Image::ToSkBitmap() const {
442 // Possibly create and cache an intermediate ImageRepSkia. 503 // Possibly create and cache an intermediate ImageRepSkia.
443 return ToImageSkia()->bitmap(); 504 return ToImageSkia()->bitmap();
444 } 505 }
445 506
446 const ImageSkia* Image::ToImageSkia() const { 507 const ImageSkia* Image::ToImageSkia() const {
447 internal::ImageRep* rep = GetRepresentation(kImageRepSkia, false); 508 internal::ImageRep* rep = GetRepresentation(kImageRepSkia, false);
448 if (!rep) { 509 if (!rep) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 } 604 }
544 #endif 605 #endif
545 606
546 scoped_refptr<base::RefCountedMemory> Image::As1xPNGBytes() const { 607 scoped_refptr<base::RefCountedMemory> Image::As1xPNGBytes() const {
547 if (IsEmpty()) 608 if (IsEmpty())
548 return new base::RefCountedBytes(); 609 return new base::RefCountedBytes();
549 610
550 internal::ImageRep* rep = GetRepresentation(kImageRepPNG, false); 611 internal::ImageRep* rep = GetRepresentation(kImageRepPNG, false);
551 612
552 if (rep) { 613 if (rep) {
553 const std::vector<gfx::ImagePNGRep>& image_png_reps = 614 const std::vector<ImagePNGRep>& image_png_reps =
554 rep->AsImageRepPNG()->image_reps(); 615 rep->AsImageRepPNG()->image_reps();
555 for (size_t i = 0; i < image_png_reps.size(); ++i) { 616 for (size_t i = 0; i < image_png_reps.size(); ++i) {
556 if (image_png_reps[i].scale == 1.0f) 617 if (image_png_reps[i].scale == 1.0f)
557 return image_png_reps[i].raw_data; 618 return image_png_reps[i].raw_data;
558 } 619 }
559 return new base::RefCountedBytes(); 620 return new base::RefCountedBytes();
560 } 621 }
561 622
562 scoped_refptr<base::RefCountedMemory> png_bytes(NULL); 623 scoped_refptr<base::RefCountedMemory> png_bytes(NULL);
563 switch (DefaultRepresentationType()) { 624 switch (DefaultRepresentationType()) {
(...skipping 30 matching lines...) Expand all
594 return new base::RefCountedBytes(); 655 return new base::RefCountedBytes();
595 } 656 }
596 657
597 // Do not insert representations for scale factors other than 1x even if 658 // Do not insert representations for scale factors other than 1x even if
598 // they are available because: 659 // they are available because:
599 // - Only the 1x PNG bytes can be accessed. 660 // - Only the 1x PNG bytes can be accessed.
600 // - ImageRepPNG is not used as an intermediate type in converting to a 661 // - ImageRepPNG is not used as an intermediate type in converting to a
601 // final type eg (converting from ImageRepSkia to ImageRepPNG to get an 662 // final type eg (converting from ImageRepSkia to ImageRepPNG to get an
602 // ImageRepCocoa). 663 // ImageRepCocoa).
603 std::vector<ImagePNGRep> image_png_reps; 664 std::vector<ImagePNGRep> image_png_reps;
604 image_png_reps.push_back(gfx::ImagePNGRep(png_bytes, 1.0f)); 665 image_png_reps.push_back(ImagePNGRep(png_bytes, 1.0f));
605 rep = new internal::ImageRepPNG(image_png_reps); 666 rep = new internal::ImageRepPNG(image_png_reps);
606 AddRepresentation(rep); 667 AddRepresentation(rep);
607 return png_bytes; 668 return png_bytes;
608 } 669 }
609 670
610 SkBitmap Image::AsBitmap() const { 671 SkBitmap Image::AsBitmap() const {
611 return IsEmpty() ? SkBitmap() : *ToSkBitmap(); 672 return IsEmpty() ? SkBitmap() : *ToSkBitmap();
612 } 673 }
613 674
614 ImageSkia Image::AsImageSkia() const { 675 ImageSkia Image::AsImageSkia() const {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 return 0; 737 return 0;
677 return GetRepresentation(DefaultRepresentationType(), true)->Height(); 738 return GetRepresentation(DefaultRepresentationType(), true)->Height();
678 } 739 }
679 740
680 gfx::Size Image::Size() const { 741 gfx::Size Image::Size() const {
681 if (IsEmpty()) 742 if (IsEmpty())
682 return gfx::Size(); 743 return gfx::Size();
683 return GetRepresentation(DefaultRepresentationType(), true)->Size(); 744 return GetRepresentation(DefaultRepresentationType(), true)->Size();
684 } 745 }
685 746
686 void Image::SwapRepresentations(gfx::Image* other) { 747 void Image::SwapRepresentations(Image* other) {
687 storage_.swap(other->storage_); 748 storage_.swap(other->storage_);
688 } 749 }
689 750
690 #if defined(OS_MACOSX) && !defined(OS_IOS) 751 #if defined(OS_MACOSX) && !defined(OS_IOS)
691 void Image::SetSourceColorSpace(CGColorSpaceRef color_space) { 752 void Image::SetSourceColorSpace(CGColorSpaceRef color_space) {
692 if (storage_.get()) 753 if (storage_.get())
693 storage_->set_default_representation_color_space(color_space); 754 storage_->set_default_representation_color_space(color_space);
694 } 755 }
695 #endif // defined(OS_MACOSX) && !defined(OS_IOS) 756 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
696 757
(...skipping 12 matching lines...) Expand all
709 } 770 }
710 return it->second; 771 return it->second;
711 } 772 }
712 773
713 void Image::AddRepresentation(internal::ImageRep* rep) const { 774 void Image::AddRepresentation(internal::ImageRep* rep) const {
714 CHECK(storage_.get()); 775 CHECK(storage_.get());
715 storage_->representations().insert(std::make_pair(rep->type(), rep)); 776 storage_->representations().insert(std::make_pair(rep->type(), rep));
716 } 777 }
717 778
718 } // namespace gfx 779 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/image/image_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698