summaryrefslogtreecommitdiffstats
path: root/ui/gfx/gl/generate_bindings.py
diff options
context:
space:
mode:
authorapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-01 19:29:59 +0000
committerapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-01 19:29:59 +0000
commitf8542546f98722339a849487c02ef11d08547c5b (patch)
treebbda6f4919f3a0bebc0b18cd62d514e126de09fa /ui/gfx/gl/generate_bindings.py
parent269cd38b3da568b0fbdae1a944e290c5bea263fa (diff)
downloadchromium_src-f8542546f98722339a849487c02ef11d08547c5b.zip
chromium_src-f8542546f98722339a849487c02ef11d08547c5b.tar.gz
chromium_src-f8542546f98722339a849487c02ef11d08547c5b.tar.bz2
Added booleans that indicate which GL extensions are available.
This is because some implementations of eglGetProcAddress do not return null for entry points that are not available. This gives a convenient and efficient way of determining whether a particular entry point can be called. Review URL: http://codereview.chromium.org/8416054 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108153 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/gl/generate_bindings.py')
-rw-r--r--ui/gfx/gl/generate_bindings.py24
1 files changed, 18 insertions, 6 deletions
diff --git a/ui/gfx/gl/generate_bindings.py b/ui/gfx/gl/generate_bindings.py
index 6260a8e..71623e6 100644
--- a/ui/gfx/gl/generate_bindings.py
+++ b/ui/gfx/gl/generate_bindings.py
@@ -476,7 +476,7 @@ FUNCTION_SETS = [
'../../../third_party/mesa/MesaLib/include/GL/glxext.h']],
]
-def GenerateHeader(file, functions, set_name):
+def GenerateHeader(file, functions, set_name, used_extension_functions):
"""Generates gl_binding_autogen_x.h"""
# Write file header.
@@ -507,6 +507,11 @@ def GenerateHeader(file, functions, set_name):
file.write('typedef %s (GL_BINDING_CALL *%sProc)(%s);\n' %
(return_type, names[0], arguments))
+ # Write declarations for booleans indicating which extensions are available.
+ file.write('\n')
+ for extension, ext_functions in used_extension_functions:
+ file.write('GL_EXPORT extern bool g_%s;\n' % extension)
+
# Write declarations for function pointers. Always use the GL name for the
# declaration.
file.write('\n')
@@ -541,10 +546,15 @@ def GenerateSource(file, functions, set_name, used_extension_functions):
file.write('#include "ui/gfx/gl/gl_context.h"\n')
file.write('#include "ui/gfx/gl/gl_implementation.h"\n')
- # Write definitions of function pointers.
+ # Write definitions for booleans indicating which extensions are available.
file.write('\n')
file.write('namespace gfx {\n')
file.write('\n')
+ for extension, ext_functions in used_extension_functions:
+ file.write('bool g_%s;\n' % extension)
+
+ # Write definitions of function pointers.
+ file.write('\n')
file.write('static bool g_debugBindingsInitialized;\n')
file.write('static void UpdateDebugGLExtensionBindings();\n')
file.write('\n')
@@ -576,7 +586,8 @@ def GenerateSource(file, functions, set_name, used_extension_functions):
set_name.upper())
file.write(' DCHECK(context && context->IsCurrent(NULL));\n')
for extension, ext_functions in used_extension_functions:
- file.write(' if (context->HasExtension("%s")) {\n' % extension)
+ file.write(' if ((g_%s = context->HasExtension("%s"))) {\n' %
+ (extension, extension))
queried_entry_points = set()
for entry_point_name, function_name in ext_functions:
# Replace the pointer unconditionally unless this extension has several
@@ -836,15 +847,16 @@ def main(argv):
dir = '.'
for [functions, set_name, extension_headers] in FUNCTION_SETS:
+ used_extension_functions = GetUsedExtensionFunctions(
+ functions, extension_headers)
+
header_file = open(
os.path.join(dir, 'gl_bindings_autogen_%s.h' % set_name), 'wb')
- GenerateHeader(header_file, functions, set_name)
+ GenerateHeader(header_file, functions, set_name, used_extension_functions)
header_file.close()
source_file = open(
os.path.join(dir, 'gl_bindings_autogen_%s.cc' % set_name), 'wb')
- used_extension_functions = GetUsedExtensionFunctions(
- functions, extension_headers)
GenerateSource(source_file, functions, set_name, used_extension_functions)
source_file.close()