| 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 | 217 |
| 218 friend class base::RefCounted<ImageStorage>; | 218 friend class base::RefCounted<ImageStorage>; |
| 219 }; | 219 }; |
| 220 | 220 |
| 221 } // namespace internal | 221 } // namespace internal |
| 222 | 222 |
| 223 Image::Image() { | 223 Image::Image() { |
| 224 // |storage_| is NULL for empty Images. | 224 // |storage_| is NULL for empty Images. |
| 225 } | 225 } |
| 226 | 226 |
| 227 Image::Image(const SkBitmap* bitmap) | |
| 228 : storage_(new internal::ImageStorage(Image::kImageRepSkia)) { | |
| 229 internal::ImageRepSkia* rep = new internal::ImageRepSkia( | |
| 230 new ImageSkia(bitmap)); | |
| 231 AddRepresentation(rep); | |
| 232 } | |
| 233 | |
| 234 Image::Image(const SkBitmap& bitmap) | 227 Image::Image(const SkBitmap& bitmap) |
| 235 : storage_(new internal::ImageStorage(Image::kImageRepSkia)) { | 228 : storage_(new internal::ImageStorage(Image::kImageRepSkia)) { |
| 236 internal::ImageRepSkia* rep = | 229 internal::ImageRepSkia* rep = |
| 237 new internal::ImageRepSkia(new ImageSkia(new SkBitmap(bitmap))); | 230 new internal::ImageRepSkia(new ImageSkia(new SkBitmap(bitmap))); |
| 238 AddRepresentation(rep); | 231 AddRepresentation(rep); |
| 239 } | 232 } |
| 240 | 233 |
| 241 Image::Image(const std::vector<const SkBitmap*>& bitmaps) | 234 Image::Image(const std::vector<const SkBitmap*>& bitmaps) |
| 242 : storage_(new internal::ImageStorage(Image::kImageRepSkia)) { | 235 : storage_(new internal::ImageStorage(Image::kImageRepSkia)) { |
| 243 internal::ImageRepSkia* rep = new internal::ImageRepSkia( | 236 internal::ImageRepSkia* rep = new internal::ImageRepSkia( |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 // Something went seriously wrong... | 429 // Something went seriously wrong... |
| 437 return NULL; | 430 return NULL; |
| 438 } | 431 } |
| 439 | 432 |
| 440 void Image::AddRepresentation(internal::ImageRep* rep) const { | 433 void Image::AddRepresentation(internal::ImageRep* rep) const { |
| 441 CHECK(storage_.get()); | 434 CHECK(storage_.get()); |
| 442 storage_->representations().insert(std::make_pair(rep->type(), rep)); | 435 storage_->representations().insert(std::make_pair(rep->type(), rep)); |
| 443 } | 436 } |
| 444 | 437 |
| 445 } // namespace gfx | 438 } // namespace gfx |
| OLD | NEW |