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

Side by Side Diff: ui/gfx/image/image.cc

Issue 10701063: Cleanup gfx::Canvas now that 10562027 has landed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 ImageRepCairoCached; 48 class ImageRepCairoCached;
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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 // Something went seriously wrong... 436 // Something went seriously wrong...
435 return NULL; 437 return NULL;
436 } 438 }
437 439
438 void Image::AddRepresentation(internal::ImageRep* rep) const { 440 void Image::AddRepresentation(internal::ImageRep* rep) const {
439 CHECK(storage_.get()); 441 CHECK(storage_.get());
440 storage_->representations().insert(std::make_pair(rep->type(), rep)); 442 storage_->representations().insert(std::make_pair(rep->type(), rep));
441 } 443 }
442 444
443 } // namespace gfx 445 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698