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/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 Image::Image() { | 236 Image::Image() { |
237 // |storage_| is NULL for empty Images. | 237 // |storage_| is NULL for empty Images. |
238 } | 238 } |
239 | 239 |
240 Image::Image(const SkBitmap* bitmap) | 240 Image::Image(const SkBitmap* bitmap) |
241 : storage_(new internal::ImageStorage(Image::kImageRepSkia)) { | 241 : storage_(new internal::ImageStorage(Image::kImageRepSkia)) { |
242 internal::ImageRepSkia* rep = new internal::ImageRepSkia(bitmap); | 242 internal::ImageRepSkia* rep = new internal::ImageRepSkia(bitmap); |
243 AddRepresentation(rep); | 243 AddRepresentation(rep); |
244 } | 244 } |
245 | 245 |
| 246 Image::Image(const SkBitmap& bitmap) |
| 247 : storage_(new internal::ImageStorage(Image::kImageRepSkia)) { |
| 248 internal::ImageRepSkia* rep = |
| 249 new internal::ImageRepSkia(new SkBitmap(bitmap)); |
| 250 AddRepresentation(rep); |
| 251 } |
| 252 |
246 Image::Image(const std::vector<const SkBitmap*>& bitmaps) | 253 Image::Image(const std::vector<const SkBitmap*>& bitmaps) |
247 : storage_(new internal::ImageStorage(Image::kImageRepSkia)) { | 254 : storage_(new internal::ImageStorage(Image::kImageRepSkia)) { |
248 internal::ImageRepSkia* rep = new internal::ImageRepSkia(bitmaps); | 255 internal::ImageRepSkia* rep = new internal::ImageRepSkia(bitmaps); |
249 AddRepresentation(rep); | 256 AddRepresentation(rep); |
250 } | 257 } |
251 | 258 |
252 #if defined(TOOLKIT_USES_GTK) | 259 #if defined(TOOLKIT_USES_GTK) |
253 Image::Image(GdkPixbuf* pixbuf) | 260 Image::Image(GdkPixbuf* pixbuf) |
254 : storage_(new internal::ImageStorage(Image::kImageRepGdk)) { | 261 : storage_(new internal::ImageStorage(Image::kImageRepGdk)) { |
255 internal::ImageRepGdk* rep = new internal::ImageRepGdk(pixbuf); | 262 internal::ImageRepGdk* rep = new internal::ImageRepGdk(pixbuf); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 return GetRepresentation(Image::kImageRepSkia)->AsImageRepSkia()-> | 466 return GetRepresentation(Image::kImageRepSkia)->AsImageRepSkia()-> |
460 bitmaps().size(); | 467 bitmaps().size(); |
461 } | 468 } |
462 | 469 |
463 const SkBitmap* Image::GetSkBitmapAtIndex(size_t index) const { | 470 const SkBitmap* Image::GetSkBitmapAtIndex(size_t index) const { |
464 return GetRepresentation(Image::kImageRepSkia)->AsImageRepSkia()-> | 471 return GetRepresentation(Image::kImageRepSkia)->AsImageRepSkia()-> |
465 bitmaps()[index]; | 472 bitmaps()[index]; |
466 } | 473 } |
467 | 474 |
468 } // namespace gfx | 475 } // namespace gfx |
OLD | NEW |