| 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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 NSImage* image = NSImageFromImageSkia(*skia_rep->image()); | 330 NSImage* image = NSImageFromImageSkia(*skia_rep->image()); |
| 331 base::mac::NSObjectRetain(image); | 331 base::mac::NSObjectRetain(image); |
| 332 rep = new internal::ImageRepCocoa(image); | 332 rep = new internal::ImageRepCocoa(image); |
| 333 CHECK(rep); | 333 CHECK(rep); |
| 334 AddRepresentation(rep); | 334 AddRepresentation(rep); |
| 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 { |
| 341 return IsEmpty() ? SkBitmap() : *ToSkBitmap(); |
| 342 } |
| 343 |
| 344 ImageSkia Image::AsImageSkia() const { |
| 345 return IsEmpty() ? ImageSkia(SkBitmap()) : *ToImageSkia(); |
| 346 } |
| 347 |
| 340 ImageSkia* Image::CopyImageSkia() const { | 348 ImageSkia* Image::CopyImageSkia() const { |
| 341 return new ImageSkia(*ToImageSkia()); | 349 return new ImageSkia(*ToImageSkia()); |
| 342 } | 350 } |
| 343 | 351 |
| 344 SkBitmap* Image::CopySkBitmap() const { | 352 SkBitmap* Image::CopySkBitmap() const { |
| 345 return new SkBitmap(*ToSkBitmap()); | 353 return new SkBitmap(*ToSkBitmap()); |
| 346 } | 354 } |
| 347 | 355 |
| 348 #if defined(TOOLKIT_GTK) | 356 #if defined(TOOLKIT_GTK) |
| 349 GdkPixbuf* Image::CopyGdkPixbuf() const { | 357 GdkPixbuf* Image::CopyGdkPixbuf() const { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 } | 413 } |
| 406 return it->second; | 414 return it->second; |
| 407 } | 415 } |
| 408 | 416 |
| 409 void Image::AddRepresentation(internal::ImageRep* rep) const { | 417 void Image::AddRepresentation(internal::ImageRep* rep) const { |
| 410 CHECK(storage_.get()); | 418 CHECK(storage_.get()); |
| 411 storage_->representations().insert(std::make_pair(rep->type(), rep)); | 419 storage_->representations().insert(std::make_pair(rep->type(), rep)); |
| 412 } | 420 } |
| 413 | 421 |
| 414 } // namespace gfx | 422 } // namespace gfx |
| OLD | NEW |