1e5c31af7Sopenharmony_ci# -*- coding: utf-8 -*- 2e5c31af7Sopenharmony_ci 3e5c31af7Sopenharmony_ci#------------------------------------------------------------------------- 4e5c31af7Sopenharmony_ci# drawElements Quality Program utilities 5e5c31af7Sopenharmony_ci# -------------------------------------- 6e5c31af7Sopenharmony_ci# 7e5c31af7Sopenharmony_ci# Copyright 2015 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 string 25e5c31af7Sopenharmony_ci 26e5c31af7Sopenharmony_cifrom egl.common import * 27e5c31af7Sopenharmony_cifrom khr_util.format import indentLines 28e5c31af7Sopenharmony_cifrom khr_util.gen_str_util import addValuePrefix, genStrUtilProtos, genStrUtilImpls 29e5c31af7Sopenharmony_ci 30e5c31af7Sopenharmony_ci# Bitfield mapping 31e5c31af7Sopenharmony_ciBITFIELD_GROUPS = [ 32e5c31af7Sopenharmony_ci ("APIBits", [ 33e5c31af7Sopenharmony_ci "OPENGL_BIT", 34e5c31af7Sopenharmony_ci "OPENGL_ES_BIT", 35e5c31af7Sopenharmony_ci "OPENGL_ES2_BIT", 36e5c31af7Sopenharmony_ci "OPENGL_ES3_BIT_KHR", 37e5c31af7Sopenharmony_ci "OPENVG_BIT" 38e5c31af7Sopenharmony_ci ]), 39e5c31af7Sopenharmony_ci ("SurfaceBits", [ 40e5c31af7Sopenharmony_ci "PBUFFER_BIT", 41e5c31af7Sopenharmony_ci "PIXMAP_BIT", 42e5c31af7Sopenharmony_ci "WINDOW_BIT", 43e5c31af7Sopenharmony_ci "MULTISAMPLE_RESOLVE_BOX_BIT", 44e5c31af7Sopenharmony_ci "SWAP_BEHAVIOR_PRESERVED_BIT", 45e5c31af7Sopenharmony_ci "VG_ALPHA_FORMAT_PRE_BIT", 46e5c31af7Sopenharmony_ci "VG_COLORSPACE_LINEAR_BIT", 47e5c31af7Sopenharmony_ci "LOCK_SURFACE_BIT_KHR", 48e5c31af7Sopenharmony_ci "OPTIMAL_FORMAT_BIT_KHR" 49e5c31af7Sopenharmony_ci ]) 50e5c31af7Sopenharmony_ci] 51e5c31af7Sopenharmony_ci 52e5c31af7Sopenharmony_ci# Enum mapping 53e5c31af7Sopenharmony_ciENUM_GROUPS = [ 54e5c31af7Sopenharmony_ci ("Boolean", ["TRUE", "FALSE"]), 55e5c31af7Sopenharmony_ci ("BoolDontCare", ["TRUE", "FALSE", "DONT_CARE"]), 56e5c31af7Sopenharmony_ci ("API", ["OPENGL_API", "OPENGL_ES_API", "OPENVG_API"]), 57e5c31af7Sopenharmony_ci ("Error", [ 58e5c31af7Sopenharmony_ci "SUCCESS", 59e5c31af7Sopenharmony_ci "NOT_INITIALIZED", 60e5c31af7Sopenharmony_ci "BAD_ACCESS", 61e5c31af7Sopenharmony_ci "BAD_ALLOC", 62e5c31af7Sopenharmony_ci "BAD_ATTRIBUTE", 63e5c31af7Sopenharmony_ci "BAD_CONFIG", 64e5c31af7Sopenharmony_ci "BAD_CONTEXT", 65e5c31af7Sopenharmony_ci "BAD_CURRENT_SURFACE", 66e5c31af7Sopenharmony_ci "BAD_DISPLAY", 67e5c31af7Sopenharmony_ci "BAD_MATCH", 68e5c31af7Sopenharmony_ci "BAD_NATIVE_PIXMAP", 69e5c31af7Sopenharmony_ci "BAD_NATIVE_WINDOW", 70e5c31af7Sopenharmony_ci "BAD_PARAMETER", 71e5c31af7Sopenharmony_ci "BAD_SURFACE", 72e5c31af7Sopenharmony_ci "CONTEXT_LOST" 73e5c31af7Sopenharmony_ci ]), 74e5c31af7Sopenharmony_ci ("ContextAttrib", [ 75e5c31af7Sopenharmony_ci "CONFIG_ID", 76e5c31af7Sopenharmony_ci "CONTEXT_CLIENT_TYPE", 77e5c31af7Sopenharmony_ci "CONTEXT_CLIENT_VERSION", 78e5c31af7Sopenharmony_ci "RENDER_BUFFER" 79e5c31af7Sopenharmony_ci ]), 80e5c31af7Sopenharmony_ci ("ConfigAttrib", [ 81e5c31af7Sopenharmony_ci "BUFFER_SIZE", 82e5c31af7Sopenharmony_ci "RED_SIZE", 83e5c31af7Sopenharmony_ci "GREEN_SIZE", 84e5c31af7Sopenharmony_ci "BLUE_SIZE", 85e5c31af7Sopenharmony_ci "LUMINANCE_SIZE", 86e5c31af7Sopenharmony_ci "ALPHA_SIZE", 87e5c31af7Sopenharmony_ci "ALPHA_MASK_SIZE", 88e5c31af7Sopenharmony_ci "BIND_TO_TEXTURE_RGB", 89e5c31af7Sopenharmony_ci "BIND_TO_TEXTURE_RGBA", 90e5c31af7Sopenharmony_ci "COLOR_BUFFER_TYPE", 91e5c31af7Sopenharmony_ci "CONFIG_CAVEAT", 92e5c31af7Sopenharmony_ci "CONFIG_ID", 93e5c31af7Sopenharmony_ci "CONFORMANT", 94e5c31af7Sopenharmony_ci "DEPTH_SIZE", 95e5c31af7Sopenharmony_ci "LEVEL", 96e5c31af7Sopenharmony_ci "MATCH_NATIVE_PIXMAP", 97e5c31af7Sopenharmony_ci "MAX_SWAP_INTERVAL", 98e5c31af7Sopenharmony_ci "MIN_SWAP_INTERVAL", 99e5c31af7Sopenharmony_ci "NATIVE_RENDERABLE", 100e5c31af7Sopenharmony_ci "NATIVE_VISUAL_TYPE", 101e5c31af7Sopenharmony_ci "RENDERABLE_TYPE", 102e5c31af7Sopenharmony_ci "SAMPLE_BUFFERS", 103e5c31af7Sopenharmony_ci "SAMPLES", 104e5c31af7Sopenharmony_ci "STENCIL_SIZE", 105e5c31af7Sopenharmony_ci "SURFACE_TYPE", 106e5c31af7Sopenharmony_ci "TRANSPARENT_TYPE", 107e5c31af7Sopenharmony_ci "TRANSPARENT_RED_VALUE", 108e5c31af7Sopenharmony_ci "TRANSPARENT_GREEN_VALUE", 109e5c31af7Sopenharmony_ci "TRANSPARENT_BLUE_VALUE", 110e5c31af7Sopenharmony_ci "COLOR_COMPONENT_TYPE_EXT", 111e5c31af7Sopenharmony_ci "RECORDABLE_ANDROID", 112e5c31af7Sopenharmony_ci ]), 113e5c31af7Sopenharmony_ci ("SurfaceAttrib", [ 114e5c31af7Sopenharmony_ci "CONFIG_ID", 115e5c31af7Sopenharmony_ci "WIDTH", 116e5c31af7Sopenharmony_ci "HEIGHT", 117e5c31af7Sopenharmony_ci "HORIZONTAL_RESOLUTION", 118e5c31af7Sopenharmony_ci "VERTICAL_RESOLUTION", 119e5c31af7Sopenharmony_ci "LARGEST_PBUFFER", 120e5c31af7Sopenharmony_ci "MIPMAP_TEXTURE", 121e5c31af7Sopenharmony_ci "MIPMAP_LEVEL", 122e5c31af7Sopenharmony_ci "MULTISAMPLE_RESOLVE", 123e5c31af7Sopenharmony_ci "PIXEL_ASPECT_RATIO", 124e5c31af7Sopenharmony_ci "RENDER_BUFFER", 125e5c31af7Sopenharmony_ci "SWAP_BEHAVIOR", 126e5c31af7Sopenharmony_ci "TEXTURE_FORMAT", 127e5c31af7Sopenharmony_ci "TEXTURE_TARGET", 128e5c31af7Sopenharmony_ci "ALPHA_FORMAT", 129e5c31af7Sopenharmony_ci "COLORSPACE" 130e5c31af7Sopenharmony_ci ]), 131e5c31af7Sopenharmony_ci ("YuvOrder", [ 132e5c31af7Sopenharmony_ci "NONE", 133e5c31af7Sopenharmony_ci "YUV_ORDER_YUV_EXT", 134e5c31af7Sopenharmony_ci "YUV_ORDER_YVU_EXT", 135e5c31af7Sopenharmony_ci "YUV_ORDER_YUYV_EXT", 136e5c31af7Sopenharmony_ci "YUV_ORDER_UYVY_EXT", 137e5c31af7Sopenharmony_ci "YUV_ORDER_YVYU_EXT", 138e5c31af7Sopenharmony_ci "YUV_ORDER_VYUY_EXT", 139e5c31af7Sopenharmony_ci "YUV_ORDER_AYUV_EXT", 140e5c31af7Sopenharmony_ci ]), 141e5c31af7Sopenharmony_ci ("YuvPlaneBpp", [ 142e5c31af7Sopenharmony_ci "YUV_PLANE_BPP_0_EXT", 143e5c31af7Sopenharmony_ci "YUV_PLANE_BPP_8_EXT", 144e5c31af7Sopenharmony_ci "YUV_PLANE_BPP_10_EXT", 145e5c31af7Sopenharmony_ci ]), 146e5c31af7Sopenharmony_ci ("ColorComponentType", ["COLOR_COMPONENT_TYPE_FIXED_EXT", "COLOR_COMPONENT_TYPE_FLOAT_EXT"]), 147e5c31af7Sopenharmony_ci ("SurfaceTarget", ["READ", "DRAW"]), 148e5c31af7Sopenharmony_ci 149e5c31af7Sopenharmony_ci # ConfigAttrib values 150e5c31af7Sopenharmony_ci ("ColorBufferType", ["RGB_BUFFER", "LUMINANCE_BUFFER"]), 151e5c31af7Sopenharmony_ci ("ConfigCaveat", ["NONE", "SLOW_CONFIG", "NON_CONFORMANT_CONFIG"]), 152e5c31af7Sopenharmony_ci ("TransparentType", ["NONE", "TRANSPARENT_RGB"]), 153e5c31af7Sopenharmony_ci 154e5c31af7Sopenharmony_ci # SurfaceAttrib values 155e5c31af7Sopenharmony_ci ("MultisampleResolve", ["MULTISAMPLE_RESOLVE_DEFAULT", "MULTISAMPLE_RESOLVE_BOX"]), 156e5c31af7Sopenharmony_ci ("RenderBuffer", ["SINGLE_BUFFER", "BACK_BUFFER"]), 157e5c31af7Sopenharmony_ci ("SwapBehavior", ["BUFFER_DESTROYED", "BUFFER_PRESERVED"]), 158e5c31af7Sopenharmony_ci ("TextureFormat", ["NO_TEXTURE", "TEXTURE_RGB", "TEXTURE_RGBA"]), 159e5c31af7Sopenharmony_ci ("TextureTarget", ["NO_TEXTURE", "TEXTURE_2D"]), 160e5c31af7Sopenharmony_ci ("AlphaFormat", ["ALPHA_FORMAT_NONPRE", "ALPHA_FORMAT_PRE"]), 161e5c31af7Sopenharmony_ci ("Colorspace", ["COLORSPACE_sRGB", "COLORSPACE_LINEAR"]) 162e5c31af7Sopenharmony_ci] 163e5c31af7Sopenharmony_ci 164e5c31af7Sopenharmony_cidef gen (iface): 165e5c31af7Sopenharmony_ci enumGroups = addValuePrefix(ENUM_GROUPS, "EGL_") 166e5c31af7Sopenharmony_ci bitfieldGroups = addValuePrefix(BITFIELD_GROUPS, "EGL_") 167e5c31af7Sopenharmony_ci prototypeFile = os.path.join(EGL_DIR, "egluStrUtilPrototypes.inl") 168e5c31af7Sopenharmony_ci implFile = os.path.join(EGL_DIR, "egluStrUtil.inl") 169e5c31af7Sopenharmony_ci 170e5c31af7Sopenharmony_ci writeInlFile(prototypeFile, indentLines(genStrUtilProtos(iface, enumGroups, bitfieldGroups))) 171e5c31af7Sopenharmony_ci writeInlFile(implFile, genStrUtilImpls(iface, enumGroups, bitfieldGroups)) 172