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_
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "GLDefs.h"
|
|
|
|
#include "nscore.h"
|
|
|
|
#include "prlink.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gl {
|
|
|
|
|
|
|
|
class GLLibraryLoader
|
|
|
|
{
|
|
|
|
public:
|
2016-06-11 04:37:07 +03:00
|
|
|
bool OpenLibrary(const char* library);
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2016-06-11 04:37:07 +03:00
|
|
|
typedef PRFuncPtr (GLAPIENTRY * PlatformLookupFunction) (const char*);
|
2012-03-17 02:24:12 +04:00
|
|
|
|
|
|
|
enum {
|
2013-07-26 04:38:58 +04:00
|
|
|
MAX_SYMBOL_NAMES = 6,
|
2012-03-17 02:24:12 +04:00
|
|
|
MAX_SYMBOL_LENGTH = 128
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct {
|
2016-06-11 04:37:07 +03:00
|
|
|
PRFuncPtr* symPointer;
|
|
|
|
const char* symNames[MAX_SYMBOL_NAMES];
|
2012-03-17 02:24:12 +04:00
|
|
|
} SymLoadStruct;
|
|
|
|
|
2016-06-11 04:37:07 +03:00
|
|
|
bool LoadSymbols(const SymLoadStruct* firstStruct,
|
2012-12-19 11:16:02 +04:00
|
|
|
bool tryplatform = false,
|
2016-06-11 04:37:07 +03:00
|
|
|
const char* prefix = nullptr,
|
2012-12-19 11:16:02 +04:00
|
|
|
bool warnOnFailure = true);
|
2012-03-17 02:24:12 +04:00
|
|
|
|
2017-03-04 03:49:49 +03:00
|
|
|
static void ClearSymbols(const SymLoadStruct* firstStruct);
|
|
|
|
|
2016-12-21 07:22:04 +03:00
|
|
|
PRFuncPtr LookupSymbol(const char* symname);
|
|
|
|
|
2012-03-17 02:24:12 +04:00
|
|
|
/*
|
|
|
|
* Static version of the functions in this class
|
|
|
|
*/
|
2016-06-11 04:37:07 +03:00
|
|
|
static PRFuncPtr LookupSymbol(PRLibrary* lib,
|
|
|
|
const char* symname,
|
2012-07-30 18:20:58 +04:00
|
|
|
PlatformLookupFunction lookupFunction = nullptr);
|
2016-06-11 04:37:07 +03:00
|
|
|
static bool LoadSymbols(PRLibrary* lib,
|
|
|
|
const SymLoadStruct* firstStruct,
|
2012-12-19 11:16:02 +04:00
|
|
|
PlatformLookupFunction lookupFunction = nullptr,
|
2016-06-11 04:37:07 +03:00
|
|
|
const char* prefix = nullptr,
|
2012-12-19 11:16:02 +04:00
|
|
|
bool warnOnFailure = true);
|
2012-03-17 02:24:12 +04:00
|
|
|
protected:
|
|
|
|
GLLibraryLoader() {
|
2012-07-30 18:20:58 +04:00
|
|
|
mLibrary = nullptr;
|
|
|
|
mLookupFunc = nullptr;
|
2012-03-17 02:24:12 +04:00
|
|
|
}
|
|
|
|
|
2016-06-11 04:37:07 +03:00
|
|
|
PRLibrary* mLibrary;
|
2012-03-17 02:24:12 +04:00
|
|
|
PlatformLookupFunction mLookupFunc;
|
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace gl */
|
|
|
|
} /* namespace mozilla */
|
|
|
|
|
|
|
|
#endif /* GLLIBRARYLOADER_H_ */
|