1*35238bceSAndroid Build Coastguard Worker# -*- coding: utf-8 -*- 2*35238bceSAndroid Build Coastguard Worker 3*35238bceSAndroid Build Coastguard Worker#------------------------------------------------------------------------- 4*35238bceSAndroid Build Coastguard Worker# drawElements Quality Program utilities 5*35238bceSAndroid Build Coastguard Worker# -------------------------------------- 6*35238bceSAndroid Build Coastguard Worker# 7*35238bceSAndroid Build Coastguard Worker# Copyright 2015 The Android Open Source Project 8*35238bceSAndroid Build Coastguard Worker# 9*35238bceSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); 10*35238bceSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License. 11*35238bceSAndroid Build Coastguard Worker# You may obtain a copy of the License at 12*35238bceSAndroid Build Coastguard Worker# 13*35238bceSAndroid Build Coastguard Worker# http://www.apache.org/licenses/LICENSE-2.0 14*35238bceSAndroid Build Coastguard Worker# 15*35238bceSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 16*35238bceSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, 17*35238bceSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18*35238bceSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and 19*35238bceSAndroid Build Coastguard Worker# limitations under the License. 20*35238bceSAndroid Build Coastguard Worker# 21*35238bceSAndroid Build Coastguard Worker#------------------------------------------------------------------------- 22*35238bceSAndroid Build Coastguard Worker 23*35238bceSAndroid Build Coastguard Workerfrom egl.common import * 24*35238bceSAndroid Build Coastguard Workerfrom khr_util.format import indentLines, commandParams, commandArgs 25*35238bceSAndroid Build Coastguard Workerimport khr_util.registry 26*35238bceSAndroid Build Coastguard Workerfrom itertools import chain 27*35238bceSAndroid Build Coastguard Worker 28*35238bceSAndroid Build Coastguard Workertry: 29*35238bceSAndroid Build Coastguard Worker from itertools import imap 30*35238bceSAndroid Build Coastguard Workerexcept ImportError: 31*35238bceSAndroid Build Coastguard Worker imap=map 32*35238bceSAndroid Build Coastguard Worker 33*35238bceSAndroid Build Coastguard Workerdef virtualMemberDecl (command): 34*35238bceSAndroid Build Coastguard Worker return "virtual %s\t%s\t(%s) const\t= 0;" % ( 35*35238bceSAndroid Build Coastguard Worker command.type, 36*35238bceSAndroid Build Coastguard Worker getFunctionMemberName(command.name), 37*35238bceSAndroid Build Coastguard Worker commandParams(command)) 38*35238bceSAndroid Build Coastguard Worker 39*35238bceSAndroid Build Coastguard Workerdef concreteMemberDecl (command): 40*35238bceSAndroid Build Coastguard Worker return "%s\t%s\t(%s) const;" % ( 41*35238bceSAndroid Build Coastguard Worker command.type, 42*35238bceSAndroid Build Coastguard Worker getFunctionMemberName(command.name), 43*35238bceSAndroid Build Coastguard Worker commandParams(command)) 44*35238bceSAndroid Build Coastguard Worker 45*35238bceSAndroid Build Coastguard Workerdef memberImpl (command): 46*35238bceSAndroid Build Coastguard Worker template = """ 47*35238bceSAndroid Build Coastguard Worker{returnType} FuncPtrLibrary::{memberName} ({paramDecls}) const 48*35238bceSAndroid Build Coastguard Worker{{ 49*35238bceSAndroid Build Coastguard Worker {maybeReturn}m_egl.{memberName}({arguments}); 50*35238bceSAndroid Build Coastguard Worker}}""" 51*35238bceSAndroid Build Coastguard Worker return template.format( 52*35238bceSAndroid Build Coastguard Worker returnType = command.type, 53*35238bceSAndroid Build Coastguard Worker mangledName = getFunctionMemberName(command.name), 54*35238bceSAndroid Build Coastguard Worker paramDecls = commandParams(command), 55*35238bceSAndroid Build Coastguard Worker maybeReturn = "return " if command.type != 'void' else "", 56*35238bceSAndroid Build Coastguard Worker memberName = getFunctionMemberName(command.name), 57*35238bceSAndroid Build Coastguard Worker arguments = commandArgs(command)) 58*35238bceSAndroid Build Coastguard Worker 59*35238bceSAndroid Build Coastguard Workerdef initFunctionEntry (command): 60*35238bceSAndroid Build Coastguard Worker return "dst->%s\t= (%sFunc)\tloader->get(\"%s\");" % ( 61*35238bceSAndroid Build Coastguard Worker getFunctionMemberName(command.name), 62*35238bceSAndroid Build Coastguard Worker command.name, 63*35238bceSAndroid Build Coastguard Worker command.name) 64*35238bceSAndroid Build Coastguard Worker 65*35238bceSAndroid Build Coastguard Workerdef getExtOnlyIface (registry, api, extensions): 66*35238bceSAndroid Build Coastguard Worker spec = khr_util.registry.InterfaceSpec() 67*35238bceSAndroid Build Coastguard Worker 68*35238bceSAndroid Build Coastguard Worker for extension in registry.extensions: 69*35238bceSAndroid Build Coastguard Worker if not khr_util.registry.getExtensionName(extension) in extensions: 70*35238bceSAndroid Build Coastguard Worker continue 71*35238bceSAndroid Build Coastguard Worker 72*35238bceSAndroid Build Coastguard Worker if not khr_util.registry.extensionSupports(extension, api): 73*35238bceSAndroid Build Coastguard Worker continue 74*35238bceSAndroid Build Coastguard Worker 75*35238bceSAndroid Build Coastguard Worker spec.addExtension(extension, api) 76*35238bceSAndroid Build Coastguard Worker 77*35238bceSAndroid Build Coastguard Worker return khr_util.registry.createInterface(registry, spec, api) 78*35238bceSAndroid Build Coastguard Worker 79*35238bceSAndroid Build Coastguard Workerdef commandLibraryEntry (command): 80*35238bceSAndroid Build Coastguard Worker return "\t{ \"%s\",\t(deFunctionPtr)%s }," % (command.name, command.name) 81*35238bceSAndroid Build Coastguard Worker 82*35238bceSAndroid Build Coastguard Workerdef genStaticLibrary (registry): 83*35238bceSAndroid Build Coastguard Worker genCommandLists(registry, commandLibraryEntry, 84*35238bceSAndroid Build Coastguard Worker check = lambda api, version: api == 'egl' and version in set(["1.4", "1.5"]), 85*35238bceSAndroid Build Coastguard Worker directory = EGL_WRAPPER_DIR, 86*35238bceSAndroid Build Coastguard Worker filePattern = "eglwStaticLibrary%s.inl", 87*35238bceSAndroid Build Coastguard Worker align = True) 88*35238bceSAndroid Build Coastguard Worker 89*35238bceSAndroid Build Coastguard Workerdef gen (registry): 90*35238bceSAndroid Build Coastguard Worker defaultIface = getDefaultInterface() 91*35238bceSAndroid Build Coastguard Worker noExtIface = getInterface(registry, 'egl', VERSION) 92*35238bceSAndroid Build Coastguard Worker extOnlyIface = getExtOnlyIface(registry, 'egl', EXTENSIONS) 93*35238bceSAndroid Build Coastguard Worker 94*35238bceSAndroid Build Coastguard Worker genCommandList(defaultIface, virtualMemberDecl, EGL_WRAPPER_DIR, "eglwLibrary.inl", True) 95*35238bceSAndroid Build Coastguard Worker genCommandList(defaultIface, concreteMemberDecl, EGL_WRAPPER_DIR, "eglwFuncPtrLibraryDecl.inl", True) 96*35238bceSAndroid Build Coastguard Worker genCommandList(defaultIface, memberImpl, EGL_WRAPPER_DIR, "eglwFuncPtrLibraryImpl.inl") 97*35238bceSAndroid Build Coastguard Worker 98*35238bceSAndroid Build Coastguard Worker genCommandList(noExtIface, initFunctionEntry, EGL_WRAPPER_DIR, "eglwInitCore.inl", True) 99*35238bceSAndroid Build Coastguard Worker genCommandList(extOnlyIface, initFunctionEntry, EGL_WRAPPER_DIR, "eglwInitExtensions.inl", True) 100*35238bceSAndroid Build Coastguard Worker 101*35238bceSAndroid Build Coastguard Worker genStaticLibrary(registry) 102