1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef GLLIBRARYLOADER_H_
6 #define GLLIBRARYLOADER_H_
13 #include "mozilla/Assertions.h"
14 #include "mozilla/SharedLibrary.h"
19 struct SymLoadStruct final
{
20 PRFuncPtr
* symPointer
;
21 std::array
<const char*, 6> symNames
;
24 void ClearSymbols(const SymLoadStruct
* firstStruct
);
26 class SymbolLoader final
{
28 typedef PRFuncPtr(GLAPIENTRY
* GetProcAddressT
)(const char*);
30 GetProcAddressT mPfn
= nullptr; // Try this first, if not null.
31 PRLibrary
* mLib
= nullptr;
33 explicit SymbolLoader(void*(GLAPIENTRY
* pfn
)(const char*))
34 : mPfn(GetProcAddressT(pfn
)) {
38 explicit SymbolLoader(const GetProcAddressT pfn
) : mPfn(pfn
) {
42 explicit SymbolLoader(PRLibrary
& lib
) : mLib(&lib
) { MOZ_ASSERT(mLib
); }
44 PRFuncPtr
GetProcAddress(const char*) const;
45 bool LoadSymbols(const SymLoadStruct
* firstStruct
,
46 bool warnOnFailures
= true) const;
50 } // namespace mozilla
52 #endif // GLLIBRARYLOADER_H_