1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program EGL Utilities
3 * ------------------------------------------
5 * Copyright 2014 The Android Open Source Project
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief EGL API Library.
22 *//*--------------------------------------------------------------------*/
24 #include "eglwLibrary.hpp"
25 #include "tcuFunctionLibrary.hpp"
26 #include "deDynamicLibrary.hpp"
28 #if !defined(DEQP_EGL_RUNTIME_LOAD)
35 FuncPtrLibrary::FuncPtrLibrary (void)
39 FuncPtrLibrary::~FuncPtrLibrary (void)
43 #include "eglwFuncPtrLibraryImpl.inl"
48 tcu::FunctionLibrary* createStaticLibrary (void)
50 #if !defined(DEQP_EGL_RUNTIME_LOAD)
51 static tcu::StaticFunctionLibrary::Entry s_staticEntries[] =
53 # if defined(EGL_VERSION_1_5)
54 # include "eglwStaticLibrary15.inl"
55 # elif defined(EGL_VERSION_1_4)
56 # include "eglwStaticLibrary14.inl"
59 return new tcu::StaticFunctionLibrary(s_staticEntries, DE_LENGTH_OF_ARRAY(s_staticEntries));
61 return new tcu::StaticFunctionLibrary(DE_NULL, 0);
65 class CoreLoader : public FunctionLoader
68 CoreLoader (const de::DynamicLibrary* dynLib)
69 : m_staticLib (createStaticLibrary())
71 , m_getProcAddress (DE_NULL)
73 // Try to obtain eglGetProcAddress
74 m_getProcAddress = (eglGetProcAddressFunc)m_staticLib->getFunction("eglGetProcAddress");
76 if (!m_getProcAddress && m_dynLib)
77 m_getProcAddress = (eglGetProcAddressFunc)m_dynLib->getFunction("eglGetProcAddress");
85 GenericFuncType get (const char* name) const
87 GenericFuncType res = (GenericFuncType)DE_NULL;
89 res = (GenericFuncType)m_staticLib->getFunction(name);
92 res = (GenericFuncType)m_dynLib->getFunction(name);
94 if (!res && m_getProcAddress)
95 res = (GenericFuncType)m_getProcAddress(name);
101 tcu::FunctionLibrary* const m_staticLib;
102 const de::DynamicLibrary* m_dynLib;
103 eglGetProcAddressFunc m_getProcAddress;
106 class ExtLoader : public FunctionLoader
109 ExtLoader (const eglGetProcAddressFunc getProcAddress)
110 : m_getProcAddress(getProcAddress)
114 GenericFuncType get (const char* name) const
116 return (GenericFuncType)m_getProcAddress(name);
120 const eglGetProcAddressFunc m_getProcAddress;
125 DefaultLibrary::DefaultLibrary (const char* dynamicLibraryName)
128 if (dynamicLibraryName)
129 m_dynLib = new de::DynamicLibrary(dynamicLibraryName);
132 const CoreLoader loader(m_dynLib);
133 initCore(&m_egl, &loader);
136 if (m_egl.getProcAddress)
138 const ExtLoader loader(m_egl.getProcAddress);
139 initExtensions(&m_egl, &loader);
143 DefaultLibrary::~DefaultLibrary (void)
148 const char* DefaultLibrary::getLibraryFileName (void)
150 #if (DE_OS == DE_OS_ANDROID) || (DE_OS == DE_OS_UNIX)
152 #elif (DE_OS == DE_OS_WIN32)