Bug 1876177 [wpt PR 44153] - [FedCM] Add a WPT test for authz, a=testonly
[gecko.git] / gfx / gl / GLLibraryLoader.h
blobe44e862f0331b2de68f852dbcd84ec96b09bb897
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_
8 #include <array>
9 #include <stdio.h>
11 #include "GLDefs.h"
12 #include "nscore.h"
13 #include "mozilla/Assertions.h"
14 #include "mozilla/SharedLibrary.h"
16 namespace mozilla {
17 namespace gl {
19 struct SymLoadStruct final {
20 PRFuncPtr* symPointer;
21 std::array<const char*, 6> symNames;
24 void ClearSymbols(const SymLoadStruct* firstStruct);
26 class SymbolLoader final {
27 public:
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)) {
35 MOZ_ASSERT(mPfn);
38 explicit SymbolLoader(const GetProcAddressT pfn) : mPfn(pfn) {
39 MOZ_ASSERT(mPfn);
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;
49 } // namespace gl
50 } // namespace mozilla
52 #endif // GLLIBRARYLOADER_H_