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 14 matching lines...) Expand all Loading... |
25 #endif | 25 #endif |
26 | 26 |
27 namespace gfx { | 27 namespace gfx { |
28 | 28 |
29 namespace internal { | 29 namespace internal { |
30 | 30 |
31 #if defined(TOOLKIT_GTK) | 31 #if defined(TOOLKIT_GTK) |
32 const ImageSkia ImageSkiaFromGdkPixbuf(GdkPixbuf* pixbuf) { | 32 const ImageSkia ImageSkiaFromGdkPixbuf(GdkPixbuf* pixbuf) { |
33 CHECK(pixbuf); | 33 CHECK(pixbuf); |
34 gfx::Canvas canvas(gfx::Size(gdk_pixbuf_get_width(pixbuf), | 34 gfx::Canvas canvas(gfx::Size(gdk_pixbuf_get_width(pixbuf), |
35 gdk_pixbuf_get_height(pixbuf)), false); | 35 gdk_pixbuf_get_height(pixbuf)), |
| 36 ui::SCALE_FACTOR_100P, |
| 37 false); |
36 skia::ScopedPlatformPaint scoped_platform_paint(canvas.sk_canvas()); | 38 skia::ScopedPlatformPaint scoped_platform_paint(canvas.sk_canvas()); |
37 cairo_t* cr = scoped_platform_paint.GetPlatformSurface(); | 39 cairo_t* cr = scoped_platform_paint.GetPlatformSurface(); |
38 gdk_cairo_set_source_pixbuf(cr, pixbuf, 0, 0); | 40 gdk_cairo_set_source_pixbuf(cr, pixbuf, 0, 0); |
39 cairo_paint(cr); | 41 cairo_paint(cr); |
40 return ImageSkia(SkBitmap(canvas.ExtractBitmap())); | 42 return ImageSkia(canvas.ExtractImageRep()); |
41 } | 43 } |
42 #endif | 44 #endif |
43 | 45 |
44 class ImageRepSkia; | 46 class ImageRepSkia; |
45 class ImageRepGdk; | 47 class ImageRepGdk; |
46 class ImageRepCairo; | 48 class ImageRepCairo; |
47 class ImageRepCocoa; | 49 class ImageRepCocoa; |
48 | 50 |
49 // An ImageRep is the object that holds the backing memory for an Image. Each | 51 // An ImageRep is the object that holds the backing memory for an Image. Each |
50 // RepresentationType has an ImageRep subclass that is responsible for freeing | 52 // RepresentationType has an ImageRep subclass that is responsible for freeing |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 } | 405 } |
404 return it->second; | 406 return it->second; |
405 } | 407 } |
406 | 408 |
407 void Image::AddRepresentation(internal::ImageRep* rep) const { | 409 void Image::AddRepresentation(internal::ImageRep* rep) const { |
408 CHECK(storage_.get()); | 410 CHECK(storage_.get()); |
409 storage_->representations().insert(std::make_pair(rep->type(), rep)); | 411 storage_->representations().insert(std::make_pair(rep->type(), rep)); |
410 } | 412 } |
411 | 413 |
412 } // namespace gfx | 414 } // namespace gfx |
OLD | NEW |