| Index: ui/gl/generate_bindings.py
|
| diff --git a/ui/gl/generate_bindings.py b/ui/gl/generate_bindings.py
|
| index d06481ab5a733f916caf027e6efd9d24d1436bec..5ef8b9f2ef0c7284f04fe31f7aaaa2eb76b9e977 100755
|
| --- a/ui/gl/generate_bindings.py
|
| +++ b/ui/gl/generate_bindings.py
|
| @@ -2556,8 +2556,8 @@ namespace gl {
|
| """ % includes_string)
|
|
|
| file.write('\n')
|
| - file.write('static bool g_debugBindingsInitialized;\n')
|
| - file.write('Driver%s g_driver_%s;\n' % (set_name.upper(), set_name.lower()))
|
| + if set_name != 'gl':
|
| + file.write('Driver%s g_driver_%s;\n' % (set_name.upper(), set_name.lower()))
|
| file.write('\n')
|
|
|
| # Write stub functions that take the place of some functions before a context
|
| @@ -2650,11 +2650,8 @@ namespace gl {
|
| if set_name == 'gl':
|
| file.write("""\
|
| void DriverGL::InitializeDynamicBindings(
|
| - GLContext* context) {
|
| - DCHECK(context && context->IsCurrent(NULL));
|
| - const GLVersionInfo* ver = context->GetVersionInfo();
|
| - ALLOW_UNUSED_LOCAL(ver);
|
| - std::string extensions = context->GetExtensions() + " ";
|
| + const GLVersionInfo* ver, const std::string& context_extensions) {
|
| + std::string extensions = context_extensions + " ";
|
| ALLOW_UNUSED_LOCAL(extensions);
|
|
|
| """)
|
| @@ -2685,7 +2682,6 @@ void Driver%s::InitializeExtensionBindings() {
|
| for func in extension_funcs:
|
| if not 'static_binding' in func:
|
| file.write('\n')
|
| - file.write(' debug_fn.%sFn = 0;\n' % func['known_as'])
|
| WriteConditionalFuncBinding(file, func)
|
|
|
| OutputExtensionBindings(
|
| @@ -2708,22 +2704,67 @@ void DriverEGL::InitializeExtensionBindings() {
|
| 'extensions',
|
| sorted(used_extensions),
|
| [ f for f in functions if not IsClientExtensionFunc(f) ])
|
| -
|
| - # Some new function pointers have been added, so update them in debug bindings
|
| - file.write('\n')
|
| - file.write(' if (g_debugBindingsInitialized)\n')
|
| - file.write(' InitializeDebugBindings();\n')
|
| file.write('}\n')
|
| +
|
| + # Write function to clear all function pointers.
|
| file.write('\n')
|
| + file.write("""void Driver%s::ClearBindings() {
|
| + memset(this, 0, sizeof(*this));
|
| +}
|
| +""" % set_name.upper())
|
| +
|
| + def MakeArgNames(arguments):
|
| + argument_names = re.sub(
|
| + r'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r'\2', arguments)
|
| + argument_names = re.sub(
|
| + r'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r'\2', argument_names)
|
| + if argument_names == 'void' or argument_names == '':
|
| + argument_names = ''
|
| + return argument_names
|
| +
|
| + # Write GLApiBase functions
|
| + for func in functions:
|
| + function_name = func['known_as']
|
| + return_type = func['return_type']
|
| + arguments = func['arguments']
|
| + file.write('\n')
|
| + file.write('%s %sApiBase::%sFn(%s) {\n' %
|
| + (return_type, set_name.upper(), function_name, arguments))
|
| + argument_names = MakeArgNames(arguments)
|
| + if return_type == 'void':
|
| + file.write(' driver_->fn.%sFn(%s);\n' %
|
| + (function_name, argument_names))
|
| + else:
|
| + file.write(' return driver_->fn.%sFn(%s);\n' %
|
| + (function_name, argument_names))
|
| + file.write('}\n')
|
| +
|
| + # Write TraceGLApi functions
|
| + for func in functions:
|
| + function_name = func['known_as']
|
| + return_type = func['return_type']
|
| + arguments = func['arguments']
|
| + file.write('\n')
|
| + file.write('%s Trace%sApi::%sFn(%s) {\n' %
|
| + (return_type, set_name.upper(), function_name, arguments))
|
| + argument_names = MakeArgNames(arguments)
|
| + file.write(' TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::%s")\n' %
|
| + function_name)
|
| + if return_type == 'void':
|
| + file.write(' %s_api_->%sFn(%s);\n' %
|
| + (set_name.lower(), function_name, argument_names))
|
| + else:
|
| + file.write(' return %s_api_->%sFn(%s);\n' %
|
| + (set_name.lower(), function_name, argument_names))
|
| + file.write('}\n')
|
|
|
| - # Write logging wrappers for each function.
|
| - file.write('extern "C" {\n')
|
| + # Write DebugGLApi functions
|
| for func in functions:
|
| return_type = func['return_type']
|
| arguments = func['arguments']
|
| file.write('\n')
|
| - file.write('static %s GL_BINDING_CALL Debug_%s(%s) {\n' %
|
| - (return_type, func['known_as'], arguments))
|
| + file.write('%s Debug%sApi::%sFn(%s) {\n' %
|
| + (return_type, set_name.upper(), func['known_as'], arguments))
|
| argument_names = re.sub(
|
| r'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r'\2', arguments)
|
| argument_names = re.sub(
|
| @@ -2764,23 +2805,20 @@ void DriverEGL::InitializeExtensionBindings() {
|
| if return_type == 'void':
|
| file.write(' GL_SERVICE_LOG("%s" << "(" %s << ")");\n' %
|
| (function_name, log_argument_names))
|
| - file.write(' DCHECK(g_driver_%s.debug_fn.%sFn != nullptr);\n' %
|
| - (set_name.lower(), function_name))
|
| - file.write(' g_driver_%s.debug_fn.%sFn(%s);\n' %
|
| + file.write(' %s_api_->%sFn(%s);\n' %
|
| (set_name.lower(), function_name, argument_names))
|
| if 'logging_code' in func:
|
| file.write("%s\n" % func['logging_code'])
|
| if options.generate_dchecks and set_name == 'gl':
|
| file.write(' {\n')
|
| - file.write(' GLenum error = g_driver_gl.debug_fn.glGetErrorFn();\n')
|
| + file.write(' GLenum error = %s_api_->glGetErrorFn();\n'
|
| + % set_name.lower())
|
| file.write(' DCHECK(error == 0);\n')
|
| file.write(' }\n')
|
| else:
|
| file.write(' GL_SERVICE_LOG("%s" << "(" %s << ")");\n' %
|
| (function_name, log_argument_names))
|
| - file.write(' DCHECK(g_driver_%s.debug_fn.%sFn != nullptr);\n' %
|
| - (set_name.lower(), function_name))
|
| - file.write(' %s result = g_driver_%s.debug_fn.%sFn(%s);\n' %
|
| + file.write(' %s result = %s_api_->%sFn(%s);\n' %
|
| (return_type, set_name.lower(), function_name, argument_names))
|
| if 'logging_code' in func:
|
| file.write("%s\n" % func['logging_code'])
|
| @@ -2788,77 +2826,12 @@ void DriverEGL::InitializeExtensionBindings() {
|
| file.write(' GL_SERVICE_LOG("GL_RESULT: " << result);\n')
|
| if options.generate_dchecks and set_name == 'gl':
|
| file.write(' {\n')
|
| - file.write(' GLenum _error = g_driver_gl.debug_fn.glGetErrorFn();\n')
|
| + file.write(' GLenum _error = %s_api_->glGetErrorFn();\n' %
|
| + set_name.lower())
|
| file.write(' DCHECK(_error == 0);\n')
|
| file.write(' }\n')
|
| file.write(' return result;\n')
|
| file.write('}\n')
|
| - file.write('} // extern "C"\n')
|
| -
|
| - # Write function to initialize the debug function pointers.
|
| - file.write('\n')
|
| - file.write('void Driver%s::InitializeDebugBindings() {\n' %
|
| - set_name.upper())
|
| - for func in functions:
|
| - first_name = func['known_as']
|
| - file.write(' if (!debug_fn.%sFn) {\n' % first_name)
|
| - file.write(' debug_fn.%sFn = fn.%sFn;\n' % (first_name, first_name))
|
| - file.write(' fn.%sFn = Debug_%s;\n' % (first_name, first_name))
|
| - file.write(' }\n')
|
| - file.write(' g_debugBindingsInitialized = true;\n')
|
| - file.write('}\n')
|
| -
|
| - # Write function to clear all function pointers.
|
| - file.write('\n')
|
| - file.write("""void Driver%s::ClearBindings() {
|
| - memset(this, 0, sizeof(*this));
|
| -}
|
| -""" % set_name.upper())
|
| -
|
| - def MakeArgNames(arguments):
|
| - argument_names = re.sub(
|
| - r'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r'\2', arguments)
|
| - argument_names = re.sub(
|
| - r'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r'\2', argument_names)
|
| - if argument_names == 'void' or argument_names == '':
|
| - argument_names = ''
|
| - return argument_names
|
| -
|
| - # Write GLApiBase functions
|
| - for func in functions:
|
| - function_name = func['known_as']
|
| - return_type = func['return_type']
|
| - arguments = func['arguments']
|
| - file.write('\n')
|
| - file.write('%s %sApiBase::%sFn(%s) {\n' %
|
| - (return_type, set_name.upper(), function_name, arguments))
|
| - argument_names = MakeArgNames(arguments)
|
| - if return_type == 'void':
|
| - file.write(' driver_->fn.%sFn(%s);\n' %
|
| - (function_name, argument_names))
|
| - else:
|
| - file.write(' return driver_->fn.%sFn(%s);\n' %
|
| - (function_name, argument_names))
|
| - file.write('}\n')
|
| -
|
| - # Write TraceGLApi functions
|
| - for func in functions:
|
| - function_name = func['known_as']
|
| - return_type = func['return_type']
|
| - arguments = func['arguments']
|
| - file.write('\n')
|
| - file.write('%s Trace%sApi::%sFn(%s) {\n' %
|
| - (return_type, set_name.upper(), function_name, arguments))
|
| - argument_names = MakeArgNames(arguments)
|
| - file.write(' TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::%s")\n' %
|
| - function_name)
|
| - if return_type == 'void':
|
| - file.write(' %s_api_->%sFn(%s);\n' %
|
| - (set_name.lower(), function_name, argument_names))
|
| - else:
|
| - file.write(' return %s_api_->%sFn(%s);\n' %
|
| - (set_name.lower(), function_name, argument_names))
|
| - file.write('}\n')
|
|
|
| # Write NoContextGLApi functions
|
| if set_name.upper() == "GL":
|
|
|