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 #-------------------------------------------------------------------------
28 sys.path.append(os.path.dirname(os.path.dirname(__file__)))
32 import khr_util.format
33 import khr_util.registry
34 import khr_util.registry_cache
36 SCRIPTS_DIR = os.path.dirname(__file__)
37 EGL_DIR = os.path.normpath(os.path.join(SCRIPTS_DIR, "..", "..", "framework", "egl"))
38 EGL_WRAPPER_DIR = os.path.normpath(os.path.join(EGL_DIR, "wrapper"))
40 EGL_SOURCE = khr_util.registry_cache.RegistrySource(
43 "3464385212ae9b816d121c77bc4191ed3dfb32ce7bfca1a02b42fcefa3ec2354")
48 # \todo [2014-12-05 pyry] Use 1.5 core functions/enums instead
49 "EGL_KHR_create_context",
50 "EGL_KHR_lock_surface",
53 "EGL_KHR_reusable_sync",
55 "EGL_KHR_gl_texture_2D_image",
56 "EGL_KHR_gl_texture_cubemap_image",
57 "EGL_KHR_gl_renderbuffer_image",
58 "EGL_KHR_gl_texture_3D_image",
59 "EGL_EXT_create_context_robustness",
60 "EGL_EXT_platform_base",
61 "EGL_EXT_platform_x11",
62 "EGL_KHR_platform_wayland",
63 "EGL_ANDROID_image_native_buffer",
64 "EGL_EXT_yuv_surface",
66 "EGL_KHR_partial_update",
67 "EGL_KHR_swap_buffers_with_damage",
68 "EGL_KHR_mutable_render_buffer"
71 "KHRONOS_SUPPORT_INT64"
74 def getEGLRegistry ():
75 return khr_util.registry_cache.getRegistry(EGL_SOURCE)
77 def getInterface (registry, api, version=None, profile=None, **kwargs):
78 spec = khr_util.registry.spec(registry, api, version, profile, **kwargs)
79 return khr_util.registry.createInterface(registry, spec, api)
81 def getDefaultInterface ():
82 return getInterface(getEGLRegistry(), 'egl', VERSION, extensionNames = EXTENSIONS, protects = PROTECTS)
84 def getFunctionTypeName (funcName):
85 return "%sFunc" % funcName
87 def getFunctionMemberName (funcName):
88 assert funcName[:3] == "egl"
89 return "%c%s" % (funcName[3].lower(), funcName[4:])
91 def genCommandList (iface, renderCommand, directory, filename, align=False):
92 lines = map(renderCommand, iface.commands)
94 lines = khr_util.format.indentLines(lines)
95 writeInlFile(os.path.join(directory, filename), lines)
97 def getVersionToken (version):
98 return version.replace(".", "")
100 def genCommandLists (registry, renderCommand, check, directory, filePattern, align=False):
101 for eFeature in registry.features:
102 api = eFeature.get('api')
103 version = eFeature.get('number')
104 profile = check(api, version)
107 elif profile is False:
109 iface = getInterface(registry, api, version=version, profile=profile)
110 filename = filePattern % getVersionToken(version)
111 genCommandList(iface, renderCommand, directory, filename, align)
113 INL_HEADER = khr_util.format.genInlHeader("Khronos EGL API description (egl.xml)", EGL_SOURCE.getRevision())
115 def writeInlFile (filename, source):
116 khr_util.format.writeInlFile(filename, INL_HEADER, source)