1 # -*- coding: utf-8 -*-
3 #-------------------------------------------------------------------------
4 # drawElements Quality Program utilities
5 # --------------------------------------
7 # Copyright 2015 The Android Open Source Project
9 # Licensed under the Apache License, Version 2.0 (the "License");
10 # you may not use this file except in compliance with the License.
11 # You may obtain a copy of the License at
13 # http://www.apache.org/licenses/LICENSE-2.0
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS,
17 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 # See the License for the specific language governing permissions and
19 # limitations under the License.
21 #-------------------------------------------------------------------------
23 from src_util import *
25 def getExtensionCommands (registry, iface, api, extension):
28 # Build interface with just the single extension and no core APIs.
29 # Aliases will not be set in this iface so we will use it only for
30 # slicing the complete (hybrid) iface.
31 extIface = getInterface(registry, api, version=False, profile='core', extensionNames=[extension])
32 if not extIface.commands:
36 for command in iface.commands:
37 cmdMap[command.name] = command
39 for extCommand in extIface.commands:
40 assert extCommand.name in cmdMap
41 commands.append(cmdMap[extCommand.name])
45 def genExtensions (registry, iface, api):
46 for extName in EXTENSIONS:
47 extCommands = getExtensionCommands(registry, iface, api, extName)
48 if len(extCommands) == 0:
49 continue # Not applicable for this api
52 yield "if (de::contains(extSet, \"%s\"))" % extName
55 def genInit (command):
56 ifaceName = command.alias.name if command.alias else command.name
57 return "gl->%s\t= (%s)\tloader->get(\"%s\");" % (
58 getFunctionMemberName(ifaceName),
59 getFunctionTypeName(ifaceName),
62 for line in indentLines(genInit(command) for command in extCommands):
67 def genExtInit (registry, iface):
68 nonStrippedIface = getHybridInterface(stripAliasedExtCommands = False)
70 writeInlFile(os.path.join(OPENGL_INC_DIR, "glwInitExtES.inl"), genExtensions(registry, nonStrippedIface, 'gles2'))
71 writeInlFile(os.path.join(OPENGL_INC_DIR, "glwInitExtGL.inl"), genExtensions(registry, nonStrippedIface, 'gl'))
73 if __name__ == '__main__':
74 genExtInit(getGLRegistry(), getHybridInterface())