OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 5 #include "ui/gfx/image.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 namespace internal { | 24 namespace internal { |
25 | 25 |
26 #if defined(OS_MACOSX) | 26 #if defined(OS_MACOSX) |
27 // This is a wrapper around gfx::NSImageToSkBitmap() because this cross-platform | 27 // This is a wrapper around gfx::NSImageToSkBitmap() because this cross-platform |
28 // file cannot include the [square brackets] of ObjC. | 28 // file cannot include the [square brackets] of ObjC. |
29 const SkBitmap* NSImageToSkBitmap(NSImage* image); | 29 const SkBitmap* NSImageToSkBitmap(NSImage* image); |
30 #endif | 30 #endif |
31 | 31 |
32 #if defined(OS_LINUX) | 32 #if defined(OS_LINUX) |
33 const SkBitmap* GdkPixbufToSkBitmap(GdkPixbuf* pixbuf) { | 33 const SkBitmap* GdkPixbufToSkBitmap(GdkPixbuf* pixbuf) { |
34 gfx::CanvasSkia canvas(gdk_pixbuf_get_width(pixbuf), | 34 gfx::CanvasSkia canvas; |
35 gdk_pixbuf_get_height(pixbuf), | 35 canvas.Init(gdk_pixbuf_get_width(pixbuf), |
36 /*is_opaque=*/false); | 36 gdk_pixbuf_get_height(pixbuf), |
| 37 false); // is_opaque |
37 canvas.DrawGdkPixbuf(pixbuf, 0, 0); | 38 canvas.DrawGdkPixbuf(pixbuf, 0, 0); |
38 return new SkBitmap(canvas.ExtractBitmap()); | 39 return new SkBitmap(canvas.ExtractBitmap()); |
39 } | 40 } |
40 #endif | 41 #endif |
41 | 42 |
42 class SkBitmapRep; | 43 class SkBitmapRep; |
43 class GdkPixbufRep; | 44 class GdkPixbufRep; |
44 class NSImageRep; | 45 class NSImageRep; |
45 | 46 |
46 // An ImageRep is the object that holds the backing memory for an Image. Each | 47 // An ImageRep is the object that holds the backing memory for an Image. Each |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 | 279 |
279 // Something went seriously wrong... | 280 // Something went seriously wrong... |
280 return NULL; | 281 return NULL; |
281 } | 282 } |
282 | 283 |
283 void Image::AddRepresentation(internal::ImageRep* rep) { | 284 void Image::AddRepresentation(internal::ImageRep* rep) { |
284 representations_.insert(std::make_pair(rep->type(), rep)); | 285 representations_.insert(std::make_pair(rep->type(), rep)); |
285 } | 286 } |
286 | 287 |
287 } // namespace gfx | 288 } // namespace gfx |
OLD | NEW |