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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 } | 335 } |
336 return rep->AsImageRepCocoa()->image(); | 336 return rep->AsImageRepCocoa()->image(); |
337 } | 337 } |
338 #endif | 338 #endif |
339 | 339 |
340 SkBitmap Image::AsBitmap() const { | 340 SkBitmap Image::AsBitmap() const { |
341 return IsEmpty() ? SkBitmap() : *ToSkBitmap(); | 341 return IsEmpty() ? SkBitmap() : *ToSkBitmap(); |
342 } | 342 } |
343 | 343 |
344 ImageSkia Image::AsImageSkia() const { | 344 ImageSkia Image::AsImageSkia() const { |
345 return IsEmpty() ? ImageSkia(SkBitmap()) : *ToImageSkia(); | 345 return IsEmpty() ? ImageSkia() : *ToImageSkia(); |
346 } | 346 } |
347 | 347 |
| 348 #if defined(OS_MACOSX) |
| 349 NSImage* Image::AsNSImage() const { |
| 350 return IsEmpty() ? nil : ToNSImage(); |
| 351 } |
| 352 #endif |
| 353 |
348 ImageSkia* Image::CopyImageSkia() const { | 354 ImageSkia* Image::CopyImageSkia() const { |
349 return new ImageSkia(*ToImageSkia()); | 355 return new ImageSkia(*ToImageSkia()); |
350 } | 356 } |
351 | 357 |
352 SkBitmap* Image::CopySkBitmap() const { | 358 SkBitmap* Image::CopySkBitmap() const { |
353 return new SkBitmap(*ToSkBitmap()); | 359 return new SkBitmap(*ToSkBitmap()); |
354 } | 360 } |
355 | 361 |
356 #if defined(TOOLKIT_GTK) | 362 #if defined(TOOLKIT_GTK) |
357 GdkPixbuf* Image::CopyGdkPixbuf() const { | 363 GdkPixbuf* Image::CopyGdkPixbuf() const { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 } | 419 } |
414 return it->second; | 420 return it->second; |
415 } | 421 } |
416 | 422 |
417 void Image::AddRepresentation(internal::ImageRep* rep) const { | 423 void Image::AddRepresentation(internal::ImageRep* rep) const { |
418 CHECK(storage_.get()); | 424 CHECK(storage_.get()); |
419 storage_->representations().insert(std::make_pair(rep->type(), rep)); | 425 storage_->representations().insert(std::make_pair(rep->type(), rep)); |
420 } | 426 } |
421 | 427 |
422 } // namespace gfx | 428 } // namespace gfx |
OLD | NEW |