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

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: only apply disabled extensions list to GL and EGL 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_bindings_autogen_egl.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 def extensionPreconditions(extension, extensions_variable):
1909 conditions = []
1910 if set_name in ('gl', 'egl'):
1911 conditions.append(
1912 'std::find({0}.begin(), {0}.end(), "{1}") == {0}.end()'.format(
1913 'disabled_extensions',
1914 extension))
1915 # Extra space at the end of the extension name is intentional, it is used
1916 # as a separator
1917 conditions.append('{0}.find("{1} ") != std::string::npos'.format(
1918 extensions_variable,
1919 extension))
1920 return conditions;
1921
1908 if set_name == 'egl': 1922 if set_name == 'egl':
1923 # Write the deferred bindings for GL that need a current context and depend
1924 # on GL_VERSION and GL_EXTENSIONS.
1925 file.write("""\
1926 }
1927
1928
1929 void DriverEGL::InitializeExtensionBindings(
1930 const std::vector<std::string> &disabled_extensions) {
1931 """)
1932
1909 file.write("""std::string client_extensions(GetClientExtensions()); 1933 file.write("""std::string client_extensions(GetClientExtensions());
1910 client_extensions += " "; 1934 client_extensions += " ";
1911 ALLOW_UNUSED_LOCAL(client_extensions); 1935 ALLOW_UNUSED_LOCAL(client_extensions);
1912 1936
1913 """) 1937 """)
1914 for extension in sorted(used_client_extensions): 1938 for extension in sorted(used_client_extensions):
1915 # Extra space at the end of the extension name is intentional, 1939 # Extra space at the end of the extension name is intentional,
1916 # it is used as a separator 1940 # it is used as a separator
1917 file.write( 1941 file.write('ext.b_%s = %s;' % (
1918 ' ext.b_%s = client_extensions.find("%s ") != std::string::npos;\n' % 1942 extension,
1919 (extension, extension)) 1943 ' && '.join(extensionPreconditions(extension, 'client_extensions'))))
1944
1920 for func in functions: 1945 for func in functions:
1921 if not 'static_binding' in func and IsClientExtensionFunc(func): 1946 if not 'static_binding' in func and IsClientExtensionFunc(func):
1922 file.write('\n') 1947 file.write('\n')
1923 file.write(' debug_fn.%sFn = 0;\n' % func['known_as']) 1948 file.write(' debug_fn.%sFn = 0;\n' % func['known_as'])
1924 WriteConditionalFuncBinding(file, func) 1949 WriteConditionalFuncBinding(file, func)
1925 1950
1926 if set_name == 'gl': 1951 if set_name == 'gl':
1927 # Write the deferred bindings for GL that need a current context and depend 1952 # Write the deferred bindings for GL that need a current context and depend
1928 # on GL_VERSION and GL_EXTENSIONS. 1953 # on GL_VERSION and GL_EXTENSIONS.
1929 file.write('}\n\n') 1954 file.write("""\
1930 file.write("""void DriverGL::InitializeDynamicBindings(GLContext* context) { 1955 }
1956
1957
1958 void DriverGL::InitializeDynamicBindings(
1959 GLContext* context,
1960 const std::vector<std::string> &disabled_extensions) {
1931 DCHECK(context && context->IsCurrent(NULL)); 1961 DCHECK(context && context->IsCurrent(NULL));
1932 const GLVersionInfo* ver = context->GetVersionInfo(); 1962 const GLVersionInfo* ver = context->GetVersionInfo();
1933 ALLOW_UNUSED_LOCAL(ver); 1963 ALLOW_UNUSED_LOCAL(ver);
1934 std::string extensions = context->GetExtensions() + " "; 1964 std::string extensions = context->GetExtensions() + " ";
1935 ALLOW_UNUSED_LOCAL(extensions); 1965 ALLOW_UNUSED_LOCAL(extensions);
1936 1966
1937 """) 1967 """)
1938 else: 1968 else:
1939 file.write("""std::string extensions(GetPlatformExtensions()); 1969 file.write("""std::string extensions(GetPlatformExtensions());
1940 extensions += " "; 1970 extensions += " ";
1941 ALLOW_UNUSED_LOCAL(extensions); 1971 ALLOW_UNUSED_LOCAL(extensions);
1942 1972
1943 """) 1973 """)
1944 1974
1945 for extension in sorted(used_extensions): 1975 for extension in sorted(used_extensions):
1946 # Extra space at the end of the extension name is intentional, it is used 1976 file.write('ext.b_%s = %s;' % (
1947 # as a separator 1977 extension,
1948 file.write(' ext.b_%s = extensions.find("%s ") != std::string::npos;\n' % 1978 ' && '.join(extensionPreconditions(extension, 'extensions'))))
1949 (extension, extension))
1950 1979
1951 for func in functions: 1980 for func in functions:
1952 if not 'static_binding' in func and not IsClientExtensionFunc(func): 1981 if not 'static_binding' in func and not IsClientExtensionFunc(func):
1953 file.write('\n') 1982 file.write('\n')
1954 file.write(' debug_fn.%sFn = 0;\n' % func['known_as']) 1983 file.write(' debug_fn.%sFn = 0;\n' % func['known_as'])
1955 WriteConditionalFuncBinding(file, func) 1984 WriteConditionalFuncBinding(file, func)
1956 1985
1957 # Some new function pointers have been added, so update them in debug bindings 1986 # Some new function pointers have been added, so update them in debug bindings
1958 file.write('\n') 1987 file.write('\n')
1959 file.write(' if (g_debugBindingsInitialized)\n') 1988 file.write(' if (g_debugBindingsInitialized)\n')
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
2607 'gl_enums_implementation_autogen.h'), 2636 'gl_enums_implementation_autogen.h'),
2608 'wb') 2637 'wb')
2609 GenerateEnumUtils(header_file, enum_header_filenames) 2638 GenerateEnumUtils(header_file, enum_header_filenames)
2610 header_file.close() 2639 header_file.close()
2611 ClangFormat(header_file.name) 2640 ClangFormat(header_file.name)
2612 return 0 2641 return 0
2613 2642
2614 2643
2615 if __name__ == '__main__': 2644 if __name__ == '__main__':
2616 sys.exit(main(sys.argv[1:])) 2645 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | ui/gl/gl_bindings.h » ('j') | ui/gl/gl_bindings_autogen_egl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698