1e5c31af7Sopenharmony_ci# -*- coding: utf-8 -*- 2e5c31af7Sopenharmony_ci 3e5c31af7Sopenharmony_ci#------------------------------------------------------------------------- 4e5c31af7Sopenharmony_ci# drawElements Quality Program utilities 5e5c31af7Sopenharmony_ci# -------------------------------------- 6e5c31af7Sopenharmony_ci# 7e5c31af7Sopenharmony_ci# Copyright 2015-2017 The Android Open Source Project 8e5c31af7Sopenharmony_ci# 9e5c31af7Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 10e5c31af7Sopenharmony_ci# you may not use this file except in compliance with the License. 11e5c31af7Sopenharmony_ci# You may obtain a copy of the License at 12e5c31af7Sopenharmony_ci# 13e5c31af7Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 14e5c31af7Sopenharmony_ci# 15e5c31af7Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software 16e5c31af7Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, 17e5c31af7Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18e5c31af7Sopenharmony_ci# See the License for the specific language governing permissions and 19e5c31af7Sopenharmony_ci# limitations under the License. 20e5c31af7Sopenharmony_ci# 21e5c31af7Sopenharmony_ci#------------------------------------------------------------------------- 22e5c31af7Sopenharmony_ci 23e5c31af7Sopenharmony_ciimport os 24e5c31af7Sopenharmony_ciimport re 25e5c31af7Sopenharmony_ciimport sys 26e5c31af7Sopenharmony_ci 27e5c31af7Sopenharmony_cidef registerPaths(): 28e5c31af7Sopenharmony_ci sys.path.append(os.path.dirname(os.path.dirname(__file__))) 29e5c31af7Sopenharmony_ci 30e5c31af7Sopenharmony_ciregisterPaths() 31e5c31af7Sopenharmony_ci 32e5c31af7Sopenharmony_ciimport khr_util.format 33e5c31af7Sopenharmony_ciimport khr_util.registry 34e5c31af7Sopenharmony_ciimport khr_util.registry_cache 35e5c31af7Sopenharmony_ci 36e5c31af7Sopenharmony_ciSCRIPTS_DIR = os.path.dirname(__file__) 37e5c31af7Sopenharmony_ciEGL_DIR = os.path.normpath(os.path.join(SCRIPTS_DIR, "..", "..", "framework", "egl")) 38e5c31af7Sopenharmony_ciEGL_WRAPPER_DIR = os.path.normpath(os.path.join(EGL_DIR, "wrapper")) 39e5c31af7Sopenharmony_ci 40e5c31af7Sopenharmony_ciEGL_SOURCE = khr_util.registry_cache.RegistrySource( 41e5c31af7Sopenharmony_ci "https://raw.githubusercontent.com/KhronosGroup/EGL-Registry", 42e5c31af7Sopenharmony_ci "api/egl.xml", 43e5c31af7Sopenharmony_ci "6550e9b12e0b4f11182bda30ae2a8dd56d0b02c8", 44e5c31af7Sopenharmony_ci "cb965fcee1335723beb11e2e174a5cf69d2f896e459cc25be8074356eb59871c") 45e5c31af7Sopenharmony_ci 46e5c31af7Sopenharmony_ciVERSION = '1.5' 47e5c31af7Sopenharmony_ci 48e5c31af7Sopenharmony_ciEXTENSIONS = [ 49e5c31af7Sopenharmony_ci # \todo [2014-12-05 pyry] Use 1.5 core functions/enums instead 50e5c31af7Sopenharmony_ci "EGL_KHR_create_context", 51e5c31af7Sopenharmony_ci "EGL_KHR_create_context_no_error", 52e5c31af7Sopenharmony_ci "EGL_KHR_lock_surface", 53e5c31af7Sopenharmony_ci "EGL_KHR_image_base", 54e5c31af7Sopenharmony_ci "EGL_KHR_fence_sync", 55e5c31af7Sopenharmony_ci "EGL_KHR_reusable_sync", 56e5c31af7Sopenharmony_ci "EGL_KHR_wait_sync", 57e5c31af7Sopenharmony_ci "EGL_KHR_gl_texture_2D_image", 58e5c31af7Sopenharmony_ci "EGL_KHR_gl_texture_cubemap_image", 59e5c31af7Sopenharmony_ci "EGL_KHR_gl_renderbuffer_image", 60e5c31af7Sopenharmony_ci "EGL_KHR_gl_texture_3D_image", 61e5c31af7Sopenharmony_ci "EGL_EXT_create_context_robustness", 62e5c31af7Sopenharmony_ci "EGL_EXT_platform_base", 63e5c31af7Sopenharmony_ci "EGL_EXT_platform_x11", 64e5c31af7Sopenharmony_ci "EGL_KHR_platform_wayland", 65e5c31af7Sopenharmony_ci "EGL_ANDROID_image_native_buffer", 66e5c31af7Sopenharmony_ci "EGL_EXT_yuv_surface", 67e5c31af7Sopenharmony_ci "EGL_EXT_buffer_age", 68e5c31af7Sopenharmony_ci "EGL_KHR_partial_update", 69e5c31af7Sopenharmony_ci "EGL_KHR_swap_buffers_with_damage", 70e5c31af7Sopenharmony_ci "EGL_KHR_mutable_render_buffer", 71e5c31af7Sopenharmony_ci "EGL_EXT_pixel_format_float", 72e5c31af7Sopenharmony_ci "EGL_KHR_gl_colorspace", 73e5c31af7Sopenharmony_ci "EGL_EXT_gl_colorspace_bt2020_linear", 74e5c31af7Sopenharmony_ci "EGL_EXT_gl_colorspace_bt2020_pq", 75e5c31af7Sopenharmony_ci "EGL_EXT_gl_colorspace_bt2020_hlg", 76e5c31af7Sopenharmony_ci "EGL_EXT_gl_colorspace_display_p3", 77e5c31af7Sopenharmony_ci "EGL_EXT_gl_colorspace_display_p3_linear", 78e5c31af7Sopenharmony_ci "EGL_EXT_gl_colorspace_display_p3_passthrough", 79e5c31af7Sopenharmony_ci "EGL_EXT_gl_colorspace_scrgb", 80e5c31af7Sopenharmony_ci "EGL_EXT_gl_colorspace_scrgb_linear", 81e5c31af7Sopenharmony_ci "EGL_EXT_surface_SMPTE2086_metadata", 82e5c31af7Sopenharmony_ci "EGL_EXT_surface_CTA861_3_metadata", 83e5c31af7Sopenharmony_ci "EGL_ANDROID_recordable" 84e5c31af7Sopenharmony_ci] 85e5c31af7Sopenharmony_ciPROTECTS = [ 86e5c31af7Sopenharmony_ci "KHRONOS_SUPPORT_INT64" 87e5c31af7Sopenharmony_ci] 88e5c31af7Sopenharmony_ci 89e5c31af7Sopenharmony_cidef getEGLRegistry (): 90e5c31af7Sopenharmony_ci return khr_util.registry_cache.getRegistry(EGL_SOURCE) 91e5c31af7Sopenharmony_ci 92e5c31af7Sopenharmony_cidef getInterface (registry, api, version=None, profile=None, **kwargs): 93e5c31af7Sopenharmony_ci spec = khr_util.registry.spec(registry, api, version, profile, **kwargs) 94e5c31af7Sopenharmony_ci return khr_util.registry.createInterface(registry, spec, api) 95e5c31af7Sopenharmony_ci 96e5c31af7Sopenharmony_cidef getDefaultInterface (): 97e5c31af7Sopenharmony_ci return getInterface(getEGLRegistry(), 'egl', VERSION, extensionNames = EXTENSIONS, protects = PROTECTS) 98e5c31af7Sopenharmony_ci 99e5c31af7Sopenharmony_cidef getFunctionTypeName (funcName): 100e5c31af7Sopenharmony_ci return "%sFunc" % funcName 101e5c31af7Sopenharmony_ci 102e5c31af7Sopenharmony_cidef getFunctionMemberName (funcName): 103e5c31af7Sopenharmony_ci assert funcName[:3] == "egl" 104e5c31af7Sopenharmony_ci return "%c%s" % (funcName[3].lower(), funcName[4:]) 105e5c31af7Sopenharmony_ci 106e5c31af7Sopenharmony_cidef genCommandList (iface, renderCommand, directory, filename, align=False): 107e5c31af7Sopenharmony_ci lines = map(renderCommand, iface.commands) 108e5c31af7Sopenharmony_ci if align: 109e5c31af7Sopenharmony_ci lines = khr_util.format.indentLines(lines) 110e5c31af7Sopenharmony_ci writeInlFile(os.path.join(directory, filename), lines) 111e5c31af7Sopenharmony_ci 112e5c31af7Sopenharmony_cidef getVersionToken (version): 113e5c31af7Sopenharmony_ci return version.replace(".", "") 114e5c31af7Sopenharmony_ci 115e5c31af7Sopenharmony_cidef genCommandLists (registry, renderCommand, check, directory, filePattern, align=False): 116e5c31af7Sopenharmony_ci for eFeature in registry.features: 117e5c31af7Sopenharmony_ci api = eFeature.get('api') 118e5c31af7Sopenharmony_ci version = eFeature.get('number') 119e5c31af7Sopenharmony_ci profile = check(api, version) 120e5c31af7Sopenharmony_ci if profile is True: 121e5c31af7Sopenharmony_ci profile = None 122e5c31af7Sopenharmony_ci elif profile is False: 123e5c31af7Sopenharmony_ci continue 124e5c31af7Sopenharmony_ci iface = getInterface(registry, api, version=version, profile=profile) 125e5c31af7Sopenharmony_ci filename = filePattern % getVersionToken(version) 126e5c31af7Sopenharmony_ci genCommandList(iface, renderCommand, directory, filename, align) 127e5c31af7Sopenharmony_ci 128e5c31af7Sopenharmony_ciINL_HEADER = khr_util.format.genInlHeader("Khronos EGL API description (egl.xml)", EGL_SOURCE.getRevision()) 129e5c31af7Sopenharmony_ci 130e5c31af7Sopenharmony_cidef writeInlFile (filename, source): 131e5c31af7Sopenharmony_ci khr_util.format.writeInlFile(filename, INL_HEADER, source) 132