| 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 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 | 239 |
| 240 private: | 240 private: |
| 241 Image::RepresentationType type_; | 241 Image::RepresentationType type_; |
| 242 }; | 242 }; |
| 243 | 243 |
| 244 class ImageRepPNG : public ImageRep { | 244 class ImageRepPNG : public ImageRep { |
| 245 public: | 245 public: |
| 246 ImageRepPNG() : ImageRep(Image::kImageRepPNG) { | 246 ImageRepPNG() : ImageRep(Image::kImageRepPNG) { |
| 247 } | 247 } |
| 248 | 248 |
| 249 ImageRepPNG(const std::vector<ImagePNGRep>& image_png_reps) | 249 explicit ImageRepPNG(const std::vector<ImagePNGRep>& image_png_reps) |
| 250 : ImageRep(Image::kImageRepPNG), | 250 : ImageRep(Image::kImageRepPNG), |
| 251 image_png_reps_(image_png_reps) { | 251 image_png_reps_(image_png_reps) { |
| 252 } | 252 } |
| 253 | 253 |
| 254 virtual ~ImageRepPNG() { | 254 virtual ~ImageRepPNG() { |
| 255 } | 255 } |
| 256 | 256 |
| 257 const std::vector<ImagePNGRep>& image_reps() { return image_png_reps_; } | 257 const std::vector<ImagePNGRep>& image_reps() { return image_png_reps_; } |
| 258 | 258 |
| 259 private: | 259 private: |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 | 370 |
| 371 DISALLOW_COPY_AND_ASSIGN(ImageRepCocoa); | 371 DISALLOW_COPY_AND_ASSIGN(ImageRepCocoa); |
| 372 }; | 372 }; |
| 373 #endif // defined(OS_MACOSX) | 373 #endif // defined(OS_MACOSX) |
| 374 | 374 |
| 375 // The Storage class acts similarly to the pixels in a SkBitmap: the Image | 375 // The Storage class acts similarly to the pixels in a SkBitmap: the Image |
| 376 // class holds a refptr instance of Storage, which in turn holds all the | 376 // class holds a refptr instance of Storage, which in turn holds all the |
| 377 // ImageReps. This way, the Image can be cheaply copied. | 377 // ImageReps. This way, the Image can be cheaply copied. |
| 378 class ImageStorage : public base::RefCounted<ImageStorage> { | 378 class ImageStorage : public base::RefCounted<ImageStorage> { |
| 379 public: | 379 public: |
| 380 ImageStorage(gfx::Image::RepresentationType default_type) | 380 explicit ImageStorage(gfx::Image::RepresentationType default_type) |
| 381 : default_representation_type_(default_type), | 381 : default_representation_type_(default_type), |
| 382 representations_deleter_(&representations_) { | 382 representations_deleter_(&representations_) { |
| 383 } | 383 } |
| 384 | 384 |
| 385 gfx::Image::RepresentationType default_representation_type() { | 385 gfx::Image::RepresentationType default_representation_type() { |
| 386 return default_representation_type_; | 386 return default_representation_type_; |
| 387 } | 387 } |
| 388 gfx::Image::RepresentationMap& representations() { return representations_; } | 388 gfx::Image::RepresentationMap& representations() { return representations_; } |
| 389 | 389 |
| 390 private: | 390 private: |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 } | 808 } |
| 809 return it->second; | 809 return it->second; |
| 810 } | 810 } |
| 811 | 811 |
| 812 void Image::AddRepresentation(internal::ImageRep* rep) const { | 812 void Image::AddRepresentation(internal::ImageRep* rep) const { |
| 813 CHECK(storage_.get()); | 813 CHECK(storage_.get()); |
| 814 storage_->representations().insert(std::make_pair(rep->type(), rep)); | 814 storage_->representations().insert(std::make_pair(rep->type(), rep)); |
| 815 } | 815 } |
| 816 | 816 |
| 817 } // namespace gfx | 817 } // namespace gfx |
| OLD | NEW |