2012-03-17 02:24:12 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef GLLIBRARYLOADER_H_
|
|
|
|
#define GLLIBRARYLOADER_H_
|
|
|
|
|
2019-02-23 00:17:28 +03:00
|
|
|
#include <array>
|
2012-03-17 02:24:12 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "GLDefs.h"
|
|
|
|
#include "nscore.h"
|
2020-04-05 06:50:33 +03:00
|
|
|
#include "mozilla/Assertions.h"
|
2018-02-24 19:33:57 +03:00
|
|
|
#include "mozilla/SharedLibrary.h"
|
2012-03-17 02:24:12 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gl {
|
|
|
|
|
2019-02-23 00:17:28 +03:00
|
|
|
struct SymLoadStruct final {
|
|
|
|
PRFuncPtr* symPointer;
|
|
|
|
std::array<const char*, 6> symNames;
|
|
|
|
};
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2019-02-23 00:17:28 +03:00
|
|
|
void ClearSymbols(const SymLoadStruct* firstStruct);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2019-02-23 00:17:28 +03:00
|
|
|
class SymbolLoader final {
|
|
|
|
public:
|
|
|
|
typedef PRFuncPtr(GLAPIENTRY* GetProcAddressT)(const char*);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2019-02-23 00:17:28 +03:00
|
|
|
GetProcAddressT mPfn = nullptr; // Try this first, if not null.
|
|
|
|
PRLibrary* mLib = nullptr;
|
2019-02-21 05:39:09 +03:00
|
|
|
|
2019-02-23 00:17:28 +03:00
|
|
|
explicit SymbolLoader(void*(GLAPIENTRY* pfn)(const char*))
|
|
|
|
: mPfn(GetProcAddressT(pfn)) {
|
|
|
|
MOZ_ASSERT(mPfn);
|
|
|
|
}
|
2019-02-21 05:39:09 +03:00
|
|
|
|
2019-02-23 00:17:28 +03:00
|
|
|
explicit SymbolLoader(const GetProcAddressT pfn) : mPfn(pfn) {
|
|
|
|
MOZ_ASSERT(mPfn);
|
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2019-02-23 00:17:28 +03:00
|
|
|
explicit SymbolLoader(PRLibrary& lib) : mLib(&lib) { MOZ_ASSERT(mLib); }
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2019-02-23 00:17:28 +03:00
|
|
|
PRFuncPtr GetProcAddress(const char*) const;
|
|
|
|
bool LoadSymbols(const SymLoadStruct* firstStruct,
|
|
|
|
bool warnOnFailures = true) const;
|
2012-03-17 02:24:12 +04:00
|
|
|
};
|
|
|
|
|
2019-02-23 00:17:28 +03:00
|
|
|
} // namespace gl
|
|
|
|
} // namespace mozilla
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2019-02-23 00:17:28 +03:00
|
|
|
#endif // GLLIBRARYLOADER_H_
|