Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(911)

Unified Diff: ui/gfx/image/image.cc

Issue 10867076: Enable gfx::Image to be created from empty platform images. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/gfx/image/image_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/image/image.cc
diff --git a/ui/gfx/image/image.cc b/ui/gfx/image/image.cc
index 48cee72c06172f675a098971c547cd242ff85b91..c5c0c76c02152783a00047e2292be58a3117b227 100644
--- a/ui/gfx/image/image.cc
+++ b/ui/gfx/image/image.cc
@@ -315,33 +315,41 @@ Image::Image(const unsigned char* png, size_t input_size)
AddRepresentation(rep);
}
-Image::Image(const ImageSkia& image)
- : storage_(new internal::ImageStorage(Image::kImageRepSkia)) {
- internal::ImageRepSkia* rep = new internal::ImageRepSkia(
- new ImageSkia(image));
- AddRepresentation(rep);
+Image::Image(const ImageSkia& image) {
+ if (!image.isNull()) {
+ storage_ = new internal::ImageStorage(Image::kImageRepSkia);
+ internal::ImageRepSkia* rep = new internal::ImageRepSkia(
+ new ImageSkia(image));
+ AddRepresentation(rep);
+ }
}
-Image::Image(const SkBitmap& bitmap)
- : storage_(new internal::ImageStorage(Image::kImageRepSkia)) {
- internal::ImageRepSkia* rep =
- new internal::ImageRepSkia(new ImageSkia(bitmap));
- AddRepresentation(rep);
+Image::Image(const SkBitmap& bitmap) {
+ if (!bitmap.empty()) {
+ storage_ = new internal::ImageStorage(Image::kImageRepSkia);
+ internal::ImageRepSkia* rep =
+ new internal::ImageRepSkia(new ImageSkia(bitmap));
+ AddRepresentation(rep);
+ }
}
#if defined(TOOLKIT_GTK)
-Image::Image(GdkPixbuf* pixbuf)
- : storage_(new internal::ImageStorage(Image::kImageRepGdk)) {
- internal::ImageRepGdk* rep = new internal::ImageRepGdk(pixbuf);
- AddRepresentation(rep);
+Image::Image(GdkPixbuf* pixbuf) {
+ if (pixbuf) {
+ storage_ = new internal::ImageStorage(Image::kImageRepGdk);
+ internal::ImageRepGdk* rep = new internal::ImageRepGdk(pixbuf);
+ AddRepresentation(rep);
+ }
}
#endif
#if defined(OS_MACOSX)
-Image::Image(NSImage* image)
- : storage_(new internal::ImageStorage(Image::kImageRepCocoa)) {
- internal::ImageRepCocoa* rep = new internal::ImageRepCocoa(image);
- AddRepresentation(rep);
+Image::Image(NSImage* image) {
+ if (image) {
+ storage_ = new internal::ImageStorage(Image::kImageRepCocoa);
+ internal::ImageRepCocoa* rep = new internal::ImageRepCocoa(image);
+ AddRepresentation(rep);
+ }
}
#endif
« no previous file with comments | « no previous file | ui/gfx/image/image_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698