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

Side by Side Diff: chrome/common/gtk_util.cc

Issue 87016: Eliminate a circular dependency by making BGRAToRGBA() generic... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 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
« no previous file with comments | « base/linux_util.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/common/gtk_util.h" 5 #include "chrome/common/gtk_util.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "base/gfx/gtk_util.h" 9 #include "base/linux_util.h"
10 #include "skia/include/SkBitmap.h" 10 #include "skia/include/SkBitmap.h"
11 11
12 namespace { 12 namespace {
13 13
14 // Callback used in RemoveAllChildren. 14 // Callback used in RemoveAllChildren.
15 void RemoveWidget(GtkWidget* widget, gpointer container) { 15 void RemoveWidget(GtkWidget* widget, gpointer container) {
16 gtk_container_remove(GTK_CONTAINER(container), widget); 16 gtk_container_remove(GTK_CONTAINER(container), widget);
17 } 17 }
18 18
19 void FreePixels(guchar* pixels, gpointer data) { 19 void FreePixels(guchar* pixels, gpointer data) {
(...skipping 18 matching lines...) Expand all
38 } // namespace event_utils 38 } // namespace event_utils
39 39
40 namespace gfx { 40 namespace gfx {
41 41
42 GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap* bitmap) { 42 GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap* bitmap) {
43 bitmap->lockPixels(); 43 bitmap->lockPixels();
44 int width = bitmap->width(); 44 int width = bitmap->width();
45 int height = bitmap->height(); 45 int height = bitmap->height();
46 int stride = bitmap->rowBytes(); 46 int stride = bitmap->rowBytes();
47 const guchar* orig_data = static_cast<guchar*>(bitmap->getPixels()); 47 const guchar* orig_data = static_cast<guchar*>(bitmap->getPixels());
48 guchar* data = BGRAToRGBA(orig_data, width, height, stride); 48 guchar* data = base::BGRAToRGBA(orig_data, width, height, stride);
49 49
50 // This pixbuf takes ownership of our malloc()ed data and will 50 // This pixbuf takes ownership of our malloc()ed data and will
51 // free it for us when it is destroyed. 51 // free it for us when it is destroyed.
52 GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data( 52 GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(
53 data, 53 data,
54 GDK_COLORSPACE_RGB, // The only colorspace gtk supports. 54 GDK_COLORSPACE_RGB, // The only colorspace gtk supports.
55 true, // There is an alpha channel. 55 true, // There is an alpha channel.
56 8, 56 8,
57 width, height, stride, &FreePixels, data); 57 width, height, stride, &FreePixels, data);
58 58
(...skipping 13 matching lines...) Expand all
72 gtk_container_add(GTK_CONTAINER(alignment), child); 72 gtk_container_add(GTK_CONTAINER(alignment), child);
73 gtk_container_add(GTK_CONTAINER(ebox), alignment); 73 gtk_container_add(GTK_CONTAINER(ebox), alignment);
74 return ebox; 74 return ebox;
75 } 75 }
76 76
77 void RemoveAllChildren(GtkWidget* container) { 77 void RemoveAllChildren(GtkWidget* container) {
78 gtk_container_foreach(GTK_CONTAINER(container), RemoveWidget, container); 78 gtk_container_foreach(GTK_CONTAINER(container), RemoveWidget, container);
79 } 79 }
80 80
81 } // namespace gfx 81 } // namespace gfx
OLDNEW
« no previous file with comments | « base/linux_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698