• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# -*- coding: utf-8 -*-
2
3#-------------------------------------------------------------------------
4# drawElements Quality Program utilities
5# --------------------------------------
6#
7# Copyright 2015 The Android Open Source Project
8#
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
12#
13#      http://www.apache.org/licenses/LICENSE-2.0
14#
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.
20#
21#-------------------------------------------------------------------------
22
23import os
24import re
25import sys
26
27def registerPaths():
28	sys.path.append(os.path.dirname(os.path.dirname(__file__)))
29
30registerPaths()
31
32import khr_util.format
33import khr_util.registry
34import khr_util.registry_cache
35
36SCRIPTS_DIR			= os.path.dirname(__file__)
37EGL_DIR				= os.path.normpath(os.path.join(SCRIPTS_DIR, "..", "..", "framework", "egl"))
38EGL_WRAPPER_DIR		= os.path.normpath(os.path.join(EGL_DIR, "wrapper"))
39
40EGL_SOURCE			= khr_util.registry_cache.RegistrySource(
41						"egl.xml",
42						31042,
43						"f5a731f46958a7cb6a5a96c811086fbaede9cc078541a26de009228eb089ae2c")
44
45VERSION				= '1.5'
46
47EXTENSIONS			= [
48	# \todo [2014-12-05 pyry] Use 1.5 core functions/enums instead
49	"EGL_KHR_create_context",
50	"EGL_KHR_lock_surface",
51	"EGL_KHR_image_base",
52	"EGL_KHR_fence_sync",
53	"EGL_KHR_reusable_sync",
54	"EGL_KHR_wait_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_ANDROID_image_native_buffer",
63	"EGL_EXT_yuv_surface"
64]
65PROTECTS			= [
66	"KHRONOS_SUPPORT_INT64"
67]
68
69def getEGLRegistry ():
70	return khr_util.registry_cache.getRegistry(EGL_SOURCE)
71
72def getInterface (registry, api, version=None, profile=None, **kwargs):
73	spec = khr_util.registry.spec(registry, api, version, profile, **kwargs)
74	return khr_util.registry.createInterface(registry, spec, api)
75
76def getDefaultInterface ():
77	return getInterface(getEGLRegistry(), 'egl', VERSION, extensionNames = EXTENSIONS, protects = PROTECTS)
78
79def getFunctionTypeName (funcName):
80	return "%sFunc" % funcName
81
82def getFunctionMemberName (funcName):
83	assert funcName[:3] == "egl"
84	return "%c%s" % (funcName[3].lower(), funcName[4:])
85
86def genCommandList (iface, renderCommand, directory, filename, align=False):
87	lines = map(renderCommand, iface.commands)
88	if align:
89		lines = khr_util.format.indentLines(lines)
90	writeInlFile(os.path.join(directory, filename), lines)
91
92def getVersionToken (version):
93	return version.replace(".", "")
94
95def genCommandLists (registry, renderCommand, check, directory, filePattern, align=False):
96	for eFeature in registry.features:
97		api			= eFeature.get('api')
98		version		= eFeature.get('number')
99		profile		= check(api, version)
100		if profile is True:
101			profile = None
102		elif profile is False:
103			continue
104		iface		= getInterface(registry, api, version=version, profile=profile)
105		filename	= filePattern % getVersionToken(version)
106		genCommandList(iface, renderCommand, directory, filename, align)
107
108INL_HEADER = khr_util.format.genInlHeader("Khronos EGL API description (egl.xml)", EGL_SOURCE.getRevision())
109
110def writeInlFile (filename, source):
111	khr_util.format.writeInlFile(filename, INL_HEADER, source)
112