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