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 <EGL/egl.h> | 5 #include <EGL/egl.h> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/environment.h" | |
9 #include "base/strings/string_split.h" | |
8 #include "gpu/command_buffer/client/gles2_lib.h" | 10 #include "gpu/command_buffer/client/gles2_lib.h" |
11 #include "gpu/command_buffer/service/gpu_switches.h" | |
12 #include "gpu/config/gpu_util.h" | |
9 #include "gpu/gles2_conform_support/egl/display.h" | 13 #include "gpu/gles2_conform_support/egl/display.h" |
10 #include "ui/gl/gl_context.h" | 14 #include "ui/gl/gl_context.h" |
11 #include "ui/gl/gl_surface.h" | 15 #include "ui/gl/gl_surface.h" |
12 | 16 |
13 #if REGAL_STATIC_EGL | 17 #if REGAL_STATIC_EGL |
14 extern "C" { | 18 extern "C" { |
15 | 19 |
16 typedef EGLContext RegalSystemContext; | 20 typedef EGLContext RegalSystemContext; |
17 #define REGAL_DECL | 21 #define REGAL_DECL |
18 REGAL_DECL void RegalMakeCurrent( RegalSystemContext ctx ); | 22 REGAL_DECL void RegalMakeCurrent( RegalSystemContext ctx ); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 if (dpy == EGL_NO_DISPLAY) | 104 if (dpy == EGL_NO_DISPLAY) |
101 return EglError(EGL_BAD_DISPLAY, EGL_FALSE); | 105 return EglError(EGL_BAD_DISPLAY, EGL_FALSE); |
102 | 106 |
103 egl::Display* display = static_cast<egl::Display*>(dpy); | 107 egl::Display* display = static_cast<egl::Display*>(dpy); |
104 if (!display->Initialize()) | 108 if (!display->Initialize()) |
105 return EglError(EGL_NOT_INITIALIZED, EGL_FALSE); | 109 return EglError(EGL_NOT_INITIALIZED, EGL_FALSE); |
106 | 110 |
107 // eglInitialize can be called multiple times, prevent InitializeOneOff from | 111 // eglInitialize can be called multiple times, prevent InitializeOneOff from |
108 // being called multiple times. | 112 // being called multiple times. |
109 if (gfx::GetGLImplementation() == gfx::kGLImplementationNone) { | 113 if (gfx::GetGLImplementation() == gfx::kGLImplementationNone) { |
110 int argc = 1; | 114 scoped_ptr<base::Environment> env(base::Environment::Create()); |
111 const char* const argv[] = {"dummy"}; | 115 std::vector<std::string> args; |
112 base::CommandLine::Init(argc, argv); | 116 std::string env_args; |
117 if (env->GetVar("CHROME_COMMAND_BUFFER_GLES2_ARGS", &env_args)) { | |
118 args = base::SplitString(env_args, " ", base::TRIM_WHITESPACE, | |
119 base::SPLIT_WANT_NONEMPTY); | |
120 } | |
121 if (args.size() == 0) { | |
hendrikw
2015/12/17 18:39:18
Nit:
if (args.empty())
Kimmo Kinnunen
2015/12/18 08:07:05
Done.
| |
122 args.push_back("dummy"); | |
123 } | |
124 scoped_ptr<const char* []> argv(new const char*[args.size()]); | |
125 for (size_t i = 0; i < args.size(); ++i) { | |
hendrikw
2015/12/17 18:39:18
Nit:
range-for instead >> for (auto& arg : args)
Kimmo Kinnunen
2015/12/18 08:07:05
The index is used in the lhs of the assignment.
| |
126 argv[i] = args[i].c_str(); | |
127 } | |
128 base::CommandLine::Init(args.size(), argv.get()); | |
129 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
130 if (!command_line->HasSwitch(switches::kDisableGpuDriverBugWorkarounds)) { | |
131 gpu::ApplyGpuDriverBugWorkarounds(command_line); | |
132 } | |
133 | |
113 gfx::GLSurface::InitializeOneOff(); | 134 gfx::GLSurface::InitializeOneOff(); |
114 } | 135 } |
115 | 136 |
116 *major = 1; | 137 *major = 1; |
117 *minor = 4; | 138 *minor = 4; |
118 return EglSuccess(EGL_TRUE); | 139 return EglSuccess(EGL_TRUE); |
119 } | 140 } |
120 | 141 |
121 EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy) { | 142 EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy) { |
122 EGLint error_code = ValidateDisplay(dpy); | 143 EGLint error_code = ValidateDisplay(dpy); |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
431 return EGL_FALSE; | 452 return EGL_FALSE; |
432 } | 453 } |
433 | 454 |
434 /* Now, define eglGetProcAddress using the generic function ptr. type */ | 455 /* Now, define eglGetProcAddress using the generic function ptr. type */ |
435 EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY | 456 EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY |
436 eglGetProcAddress(const char* procname) { | 457 eglGetProcAddress(const char* procname) { |
437 return reinterpret_cast<__eglMustCastToProperFunctionPointerType>( | 458 return reinterpret_cast<__eglMustCastToProperFunctionPointerType>( |
438 gles2::GetGLFunctionPointer(procname)); | 459 gles2::GetGLFunctionPointer(procname)); |
439 } | 460 } |
440 } // extern "C" | 461 } // extern "C" |
OLD | NEW |