From 2aa4a82499d4becd2284cdb482213d541b8804dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 16:29:10 +0200 Subject: Adding upstream version 86.0.1. Signed-off-by: Daniel Baumann --- gfx/gl/GLLibraryLoader.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 gfx/gl/GLLibraryLoader.h (limited to 'gfx/gl/GLLibraryLoader.h') diff --git a/gfx/gl/GLLibraryLoader.h b/gfx/gl/GLLibraryLoader.h new file mode 100644 index 0000000000..e44e862f03 --- /dev/null +++ b/gfx/gl/GLLibraryLoader.h @@ -0,0 +1,52 @@ +/* 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_ + +#include +#include + +#include "GLDefs.h" +#include "nscore.h" +#include "mozilla/Assertions.h" +#include "mozilla/SharedLibrary.h" + +namespace mozilla { +namespace gl { + +struct SymLoadStruct final { + PRFuncPtr* symPointer; + std::array symNames; +}; + +void ClearSymbols(const SymLoadStruct* firstStruct); + +class SymbolLoader final { + public: + typedef PRFuncPtr(GLAPIENTRY* GetProcAddressT)(const char*); + + GetProcAddressT mPfn = nullptr; // Try this first, if not null. + PRLibrary* mLib = nullptr; + + explicit SymbolLoader(void*(GLAPIENTRY* pfn)(const char*)) + : mPfn(GetProcAddressT(pfn)) { + MOZ_ASSERT(mPfn); + } + + explicit SymbolLoader(const GetProcAddressT pfn) : mPfn(pfn) { + MOZ_ASSERT(mPfn); + } + + explicit SymbolLoader(PRLibrary& lib) : mLib(&lib) { MOZ_ASSERT(mLib); } + + PRFuncPtr GetProcAddress(const char*) const; + bool LoadSymbols(const SymLoadStruct* firstStruct, + bool warnOnFailures = true) const; +}; + +} // namespace gl +} // namespace mozilla + +#endif // GLLIBRARYLOADER_H_ -- cgit v1.2.3