Line data Source code
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/. */
4 :
5 : #ifndef GLLIBRARYLOADER_H_
6 : #define GLLIBRARYLOADER_H_
7 :
8 : #include <stdio.h>
9 :
10 : #include "GLDefs.h"
11 : #include "nscore.h"
12 : #include "prlink.h"
13 :
14 : namespace mozilla {
15 : namespace gl {
16 :
17 : class GLLibraryLoader
18 : {
19 : public:
20 : bool OpenLibrary(const char* library);
21 :
22 : typedef PRFuncPtr (GLAPIENTRY * PlatformLookupFunction) (const char*);
23 :
24 : enum {
25 : MAX_SYMBOL_NAMES = 6,
26 : MAX_SYMBOL_LENGTH = 128
27 : };
28 :
29 : typedef struct {
30 : PRFuncPtr* symPointer;
31 : const char* symNames[MAX_SYMBOL_NAMES];
32 : } SymLoadStruct;
33 :
34 : bool LoadSymbols(const SymLoadStruct* firstStruct,
35 : bool tryplatform = false,
36 : const char* prefix = nullptr,
37 : bool warnOnFailure = true);
38 :
39 : static void ClearSymbols(const SymLoadStruct* firstStruct);
40 :
41 : PRFuncPtr LookupSymbol(const char* symname);
42 :
43 : /*
44 : * Static version of the functions in this class
45 : */
46 : static PRFuncPtr LookupSymbol(PRLibrary* lib,
47 : const char* symname,
48 : PlatformLookupFunction lookupFunction = nullptr);
49 : static bool LoadSymbols(PRLibrary* lib,
50 : const SymLoadStruct* firstStruct,
51 : PlatformLookupFunction lookupFunction = nullptr,
52 : const char* prefix = nullptr,
53 : bool warnOnFailure = true);
54 : protected:
55 0 : GLLibraryLoader() {
56 0 : mLibrary = nullptr;
57 0 : mLookupFunc = nullptr;
58 0 : }
59 :
60 : PRLibrary* mLibrary;
61 : PlatformLookupFunction mLookupFunc;
62 : };
63 :
64 : } /* namespace gl */
65 : } /* namespace mozilla */
66 :
67 : #endif /* GLLIBRARYLOADER_H_ */
|