1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/gl/GLLibraryLoader.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,67 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#ifndef GLLIBRARYLOADER_H_ 1.9 +#define GLLIBRARYLOADER_H_ 1.10 + 1.11 +#include <stdio.h> 1.12 + 1.13 +#ifdef WIN32 1.14 +#include <windows.h> 1.15 +#endif 1.16 + 1.17 +#include "GLDefs.h" 1.18 +#include "nscore.h" 1.19 +#include "prlink.h" 1.20 + 1.21 +namespace mozilla { 1.22 +namespace gl { 1.23 + 1.24 +class GLLibraryLoader 1.25 +{ 1.26 +public: 1.27 + bool OpenLibrary(const char *library); 1.28 + 1.29 + typedef PRFuncPtr (GLAPIENTRY * PlatformLookupFunction) (const char *); 1.30 + 1.31 + enum { 1.32 + MAX_SYMBOL_NAMES = 6, 1.33 + MAX_SYMBOL_LENGTH = 128 1.34 + }; 1.35 + 1.36 + typedef struct { 1.37 + PRFuncPtr *symPointer; 1.38 + const char *symNames[MAX_SYMBOL_NAMES]; 1.39 + } SymLoadStruct; 1.40 + 1.41 + bool LoadSymbols(SymLoadStruct *firstStruct, 1.42 + bool tryplatform = false, 1.43 + const char *prefix = nullptr, 1.44 + bool warnOnFailure = true); 1.45 + 1.46 + /* 1.47 + * Static version of the functions in this class 1.48 + */ 1.49 + static PRFuncPtr LookupSymbol(PRLibrary *lib, 1.50 + const char *symname, 1.51 + PlatformLookupFunction lookupFunction = nullptr); 1.52 + static bool LoadSymbols(PRLibrary *lib, 1.53 + SymLoadStruct *firstStruct, 1.54 + PlatformLookupFunction lookupFunction = nullptr, 1.55 + const char *prefix = nullptr, 1.56 + bool warnOnFailure = true); 1.57 +protected: 1.58 + GLLibraryLoader() { 1.59 + mLibrary = nullptr; 1.60 + mLookupFunc = nullptr; 1.61 + } 1.62 + 1.63 + PRLibrary *mLibrary; 1.64 + PlatformLookupFunction mLookupFunc; 1.65 +}; 1.66 + 1.67 +} /* namespace gl */ 1.68 +} /* namespace mozilla */ 1.69 + 1.70 +#endif /* GLLIBRARYLOADER_H_ */