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

Side by Side Diff: ui/gl/generate_bindings.py

Issue 1203513004: Respect the disabled extension list during binding initialization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: split extension binding loading from static binding loading; pass enabled extensions Created 5 years, 6 months 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
« no previous file with comments | « no previous file | ui/gl/gl_bindings.h » ('j') | ui/gl/gl_egl_api_implementation.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """code generator for GL/GLES extension wrangler.""" 6 """code generator for GL/GLES extension wrangler."""
7 7
8 import optparse 8 import optparse
9 import os 9 import os
10 import collections 10 import collections
(...skipping 1887 matching lines...) Expand 10 before | Expand all | Expand 10 after
1898 first_version = False 1898 first_version = False
1899 1899
1900 # TODO(jmadill): make more robust 1900 # TODO(jmadill): make more robust
1901 def IsClientExtensionFunc(func): 1901 def IsClientExtensionFunc(func):
1902 assert len(func['versions']) > 0 1902 assert len(func['versions']) > 0
1903 if 'client_extensions' in func['versions'][0]: 1903 if 'client_extensions' in func['versions'][0]:
1904 assert len(func['versions']) == 1 1904 assert len(func['versions']) == 1
1905 return True 1905 return True
1906 return False 1906 return False
1907 1907
1908 if set_name == 'egl': 1908 file.write("}\n\n");
1909 file.write("""std::string client_extensions(GetClientExtensions());
1910 client_extensions += " ";
1911 ALLOW_UNUSED_LOCAL(client_extensions);
1912
1913 """)
1914 for extension in sorted(used_client_extensions):
1915 # Extra space at the end of the extension name is intentional,
1916 # it is used as a separator
1917 file.write(
1918 ' ext.b_%s = client_extensions.find("%s ") != std::string::npos;\n' %
1919 (extension, extension))
1920 for func in functions:
1921 if not 'static_binding' in func and IsClientExtensionFunc(func):
1922 file.write('\n')
1923 file.write(' debug_fn.%sFn = 0;\n' % func['known_as'])
1924 WriteConditionalFuncBinding(file, func)
1925 1909
1926 if set_name == 'gl': 1910 if set_name == 'gl':
1927 # Write the deferred bindings for GL that need a current context and depend 1911 file.write("""\
1928 # on GL_VERSION and GL_EXTENSIONS. 1912 void DriverGL::InitializeExtensionBindings(
1929 file.write('}\n\n') 1913 GLContext* context,
1930 file.write("""void DriverGL::InitializeDynamicBindings(GLContext* context) { 1914 const std::set<std::string> &enabled_extensions) {
1931 DCHECK(context && context->IsCurrent(NULL)); 1915 DCHECK(context && context->IsCurrent(NULL));
1932 const GLVersionInfo* ver = context->GetVersionInfo(); 1916 const GLVersionInfo* ver = context->GetVersionInfo();
1933 ALLOW_UNUSED_LOCAL(ver); 1917 ALLOW_UNUSED_LOCAL(ver);
1934 std::string extensions = context->GetExtensions() + " ";
1935 ALLOW_UNUSED_LOCAL(extensions);
1936
1937 """) 1918 """)
1938 else: 1919 else:
1939 file.write("""std::string extensions(GetPlatformExtensions()); 1920 file.write("""\
1940 extensions += " "; 1921 void Driver%s::InitializeExtensionBindings(
1941 ALLOW_UNUSED_LOCAL(extensions); 1922 const std::set<std::string> &enabled_extensions) {
1923 """ % (set_name.upper(),))
1942 1924
1943 """) 1925 for extension in sorted(used_client_extensions) + sorted(used_extensions):
1926 # Extra space at the end of the extension name is intentional,
1927 # it is used as a separator
1928 file.write('ext.b_{0} = enabled_extensions.find("{0}") != enabled_extensions .end();'.format(
1929 extension))
1944 1930
1945 for extension in sorted(used_extensions): 1931 for func in sorted(functions, key = lambda func: not IsClientExtensionFunc(fun c)):
1946 # Extra space at the end of the extension name is intentional, it is used 1932 if not 'static_binding' in func:
1947 # as a separator
1948 file.write(' ext.b_%s = extensions.find("%s ") != std::string::npos;\n' %
1949 (extension, extension))
1950
1951 for func in functions:
1952 if not 'static_binding' in func and not IsClientExtensionFunc(func):
1953 file.write('\n') 1933 file.write('\n')
1954 file.write(' debug_fn.%sFn = 0;\n' % func['known_as']) 1934 file.write(' debug_fn.%sFn = 0;\n' % func['known_as'])
1955 WriteConditionalFuncBinding(file, func) 1935 WriteConditionalFuncBinding(file, func)
1956 1936
1957 # Some new function pointers have been added, so update them in debug bindings 1937 # Some new function pointers have been added, so update them in debug bindings
1958 file.write('\n') 1938 file.write('\n')
1959 file.write(' if (g_debugBindingsInitialized)\n') 1939 file.write(' if (g_debugBindingsInitialized)\n')
1960 file.write(' InitializeDebugBindings();\n') 1940 file.write(' InitializeDebugBindings();\n')
1961 file.write('}\n') 1941 file.write('}\n')
1962 file.write('\n') 1942 file.write('\n')
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
2607 'gl_enums_implementation_autogen.h'), 2587 'gl_enums_implementation_autogen.h'),
2608 'wb') 2588 'wb')
2609 GenerateEnumUtils(header_file, enum_header_filenames) 2589 GenerateEnumUtils(header_file, enum_header_filenames)
2610 header_file.close() 2590 header_file.close()
2611 ClangFormat(header_file.name) 2591 ClangFormat(header_file.name)
2612 return 0 2592 return 0
2613 2593
2614 2594
2615 if __name__ == '__main__': 2595 if __name__ == '__main__':
2616 sys.exit(main(sys.argv[1:])) 2596 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | ui/gl/gl_bindings.h » ('j') | ui/gl/gl_egl_api_implementation.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698