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

Side by Side Diff: gfx/gtk_util.cc

Issue 4508004: gtk: refactor copy-pasted code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years, 1 month 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 | « gfx/gtk_util.h ('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 "gfx/gtk_util.h" 5 #include "gfx/gtk_util.h"
6 6
7 #include <gdk/gdk.h> 7 #include <gdk/gdk.h>
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/command_line.h"
12 #include "base/linux_util.h" 13 #include "base/linux_util.h"
13 #include "gfx/rect.h" 14 #include "gfx/rect.h"
14 #include "third_party/skia/include/core/SkBitmap.h" 15 #include "third_party/skia/include/core/SkBitmap.h"
15 #include "third_party/skia/include/core/SkUnPreMultiply.h" 16 #include "third_party/skia/include/core/SkUnPreMultiply.h"
16 17
17 namespace { 18 namespace {
18 19
19 void FreePixels(guchar* pixels, gpointer data) { 20 void FreePixels(guchar* pixels, gpointer data) {
20 free(data); 21 free(data);
21 } 22 }
(...skipping 23 matching lines...) Expand all
45 } 46 }
46 } 47 }
47 48
48 return ret; 49 return ret;
49 } 50 }
50 51
51 } // namespace 52 } // namespace
52 53
53 namespace gfx { 54 namespace gfx {
54 55
56 void GtkInitFromCommandLine(const CommandLine& command_line) {
57 const std::vector<std::string>& args = command_line.argv();
58 int argc = args.size();
59 scoped_array<char *> argv(new char *[argc + 1]);
Evan Stade 2010/11/05 20:35:03 are these weird spaces necessary?
60 for (size_t i = 0; i < args.size(); ++i) {
61 // TODO(piman@google.com): can gtk_init modify argv? Just being safe
Evan Stade 2010/11/05 20:35:03 I think you can just remove the comment
62 // here.
63 argv[i] = strdup(args[i].c_str());
64 }
65 argv[argc] = NULL;
66 char **argv_pointer = argv.get();
Evan Stade 2010/11/05 20:35:03 * on left
67
68 gtk_init(&argc, &argv_pointer);
69 for (size_t i = 0; i < args.size(); ++i) {
70 free(argv[i]);
71 }
72 }
73
55 GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap* bitmap) { 74 GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap* bitmap) {
56 if (bitmap->isNull()) 75 if (bitmap->isNull())
57 return NULL; 76 return NULL;
58 77
59 bitmap->lockPixels(); 78 bitmap->lockPixels();
60 79
61 int width = bitmap->width(); 80 int width = bitmap->width();
62 int height = bitmap->height(); 81 int height = bitmap->height();
63 int stride = bitmap->rowBytes(); 82 int stride = bitmap->rowBytes();
64 83
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 new_pixels[idx + 1] = pixels[idx + 1]; 168 new_pixels[idx + 1] = pixels[idx + 1];
150 new_pixels[idx + 2] = pixels[idx]; 169 new_pixels[idx + 2] = pixels[idx];
151 new_pixels[idx + 3] = pixels[idx + 3]; 170 new_pixels[idx + 3] = pixels[idx + 3];
152 } 171 }
153 } 172 }
154 173
155 return new_pixels; 174 return new_pixels;
156 } 175 }
157 176
158 } // namespace gfx 177 } // namespace gfx
OLDNEW
« no previous file with comments | « gfx/gtk_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698