OLD | NEW |
---|---|
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 "base/at_exit.h" | 5 #include "base/at_exit.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #if defined(OS_MACOSX) | 8 #if defined(OS_MACOSX) |
9 #include "base/mac/scoped_nsautorelease_pool.h" | 9 #include "base/mac/scoped_nsautorelease_pool.h" |
10 #endif | 10 #endif |
11 #if defined(OS_WIN) | |
12 #include "base/strings/utf_string_conversions.h" | |
13 #endif | |
11 #include "ui/gl/gl_surface.h" | 14 #include "ui/gl/gl_surface.h" |
12 | 15 |
13 extern "C" { | 16 extern "C" { |
14 #if defined(GLES2_CONFORM_SUPPORT_ONLY) | 17 #if defined(GLES2_CONFORM_SUPPORT_ONLY) |
15 #include "gpu/gles2_conform_support/gtf/gtf_stubs.h" | 18 #include "gpu/gles2_conform_support/gtf/gtf_stubs.h" |
16 #else | 19 #else |
17 #include "third_party/gles2_conform/GTF_ES/glsl/GTF/Source/GTFMain.h" | 20 #include "third_party/gles2_conform/GTF_ES/glsl/GTF/Source/GTFMain.h" |
18 #endif | 21 #endif |
19 } | 22 } |
20 | 23 |
21 int main(int argc, char *argv[]) { | 24 int main(int argc, char *argv[]) { |
22 base::AtExitManager at_exit; | 25 base::AtExitManager at_exit; |
23 CommandLine::Init(argc, argv); | 26 CommandLine::Init(argc, argv); |
24 base::MessageLoopForUI message_loop; | 27 base::MessageLoopForUI message_loop; |
25 | 28 |
29 CommandLine::StringVector args = | |
30 CommandLine::ForCurrentProcess()->GetArgs(); | |
31 | |
26 #if defined(OS_MACOSX) | 32 #if defined(OS_MACOSX) |
27 base::mac::ScopedNSAutoreleasePool pool; | 33 base::mac::ScopedNSAutoreleasePool pool; |
28 #endif | 34 #endif |
29 GTFMain(argc, argv); | 35 |
36 char const** argsArray = new const char *[args.size()]; | |
piman
2014/08/26 18:57:07
nit: scoped_ptr<char const*[]>
nit: new const char
Jamie Madill
2014/08/26 19:29:54
Done.
| |
37 | |
38 #if defined(OS_WIN) | |
39 std::vector<std::string> argsNonWide; | |
40 for (size_t index = 0; index < args.size(); ++index) { | |
41 argsNonWide.push_back(base::UTF16ToUTF8(args[index])); | |
42 argsArray[index] = argsNonWide[index].c_str(); | |
piman
2014/08/26 18:57:07
I'm not sure that's safe. when you push_back a new
Jamie Madill
2014/08/26 19:29:54
Good point. I split the operation into two loops.
| |
43 } | |
44 #else | |
45 for (size_t index = 0; index < args.size(); ++index) { | |
46 argsArray[index] = args[index].c_str(); | |
47 } | |
48 #endif | |
49 | |
50 GTFMain(static_cast<int>(args.size()), | |
51 const_cast<char**>(argsArray)); | |
52 delete [] argsArray; | |
30 | 53 |
31 return 0; | 54 return 0; |
32 } | 55 } |
33 | 56 |
OLD | NEW |