summaryrefslogtreecommitdiffstats
path: root/ui/gfx
diff options
context:
space:
mode:
authorcevans@chromium.org <cevans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-11 20:07:28 +0000
committercevans@chromium.org <cevans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-11 20:07:28 +0000
commit74ab7dd14936d25806a057a5ce95d65390c1673f (patch)
tree15c6889b35cee2f58a8d37b29d1213c0a97476c7 /ui/gfx
parent216f979ec24d74984b326eae7e9fa55f28515b0f (diff)
downloadchromium_src-74ab7dd14936d25806a057a5ce95d65390c1673f.zip
chromium_src-74ab7dd14936d25806a057a5ce95d65390c1673f.tar.gz
chromium_src-74ab7dd14936d25806a057a5ce95d65390c1673f.tar.bz2
Use gdk_init() instead of gtk_init() to open the display. It's much lighter and
doesn't create wasteful threads (which get in the way of sandboxing). Review URL: https://chromiumcodereview.appspot.com/10051009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131821 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx')
-rw-r--r--ui/gfx/gtk_util.cc13
-rw-r--r--ui/gfx/gtk_util.h7
2 files changed, 15 insertions, 5 deletions
diff --git a/ui/gfx/gtk_util.cc b/ui/gfx/gtk_util.cc
index a02b043..68a983a 100644
--- a/ui/gfx/gtk_util.cc
+++ b/ui/gfx/gtk_util.cc
@@ -60,7 +60,8 @@ void FreePixels(guchar* pixels, gpointer data) {
namespace gfx {
-void GtkInitFromCommandLine(const CommandLine& command_line) {
+static void CommonInitFromCommandLine(
+ const CommandLine& command_line, void (*init_func)(gint*, gchar***)) {
const std::vector<std::string>& args = command_line.argv();
int argc = args.size();
scoped_array<char *> argv(new char *[argc + 1]);
@@ -72,12 +73,20 @@ void GtkInitFromCommandLine(const CommandLine& command_line) {
argv[argc] = NULL;
char **argv_pointer = argv.get();
- gtk_init(&argc, &argv_pointer);
+ init_func(&argc, &argv_pointer);
for (size_t i = 0; i < args.size(); ++i) {
free(argv[i]);
}
}
+void GtkInitFromCommandLine(const CommandLine& command_line) {
+ CommonInitFromCommandLine(command_line, gtk_init);
+}
+
+void GdkInitFromCommandLine(const CommandLine& command_line) {
+ CommonInitFromCommandLine(command_line, gdk_init);
+}
+
GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap* bitmap) {
if (bitmap->isNull())
return NULL;
diff --git a/ui/gfx/gtk_util.h b/ui/gfx/gtk_util.h
index 52d2bc4..323f1df 100644
--- a/ui/gfx/gtk_util.h
+++ b/ui/gfx/gtk_util.h
@@ -21,10 +21,11 @@ namespace gfx {
class Rect;
-// Call gtk_init() using the argc and argv from command_line.
-// gtk_init() wants an argc and argv that it can mutate; we provide those,
-// but leave the original CommandLine unaltered.
+// Call gtk_init() / gdk_init() using the argc and argv from command_line.
+// These init functions want an argc and argv that they can mutate; we provide
+// those, but leave the original CommandLine unaltered.
UI_EXPORT void GtkInitFromCommandLine(const CommandLine& command_line);
+UI_EXPORT void GdkInitFromCommandLine(const CommandLine& command_line);
// Convert and copy a SkBitmap to a GdkPixbuf. NOTE: this uses BGRAToRGBA, so
// it is an expensive operation. The returned GdkPixbuf will have a refcount of