diff options
-rw-r--r-- | content/gpu/gpu_main.cc | 2 | ||||
-rw-r--r-- | ui/gfx/gtk_util.cc | 13 | ||||
-rw-r--r-- | ui/gfx/gtk_util.h | 7 |
3 files changed, 16 insertions, 6 deletions
diff --git a/content/gpu/gpu_main.cc b/content/gpu/gpu_main.cc index f62db1f..2562cb3 100644 --- a/content/gpu/gpu_main.cc +++ b/content/gpu/gpu_main.cc @@ -58,7 +58,7 @@ int GpuMain(const content::MainFunctionParams& parameters) { ui::SetDefaultX11ErrorHandlers(); #endif #if defined(TOOLKIT_GTK) - gfx::GtkInitFromCommandLine(*CommandLine::ForCurrentProcess()); + gfx::GdkInitFromCommandLine(*CommandLine::ForCurrentProcess()); #endif } 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 |