mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1442275 - Stop using PR_LoadLibrary in gfx/. r=jgilbert
MozReview-Commit-ID: LNZtr4NVFYj --HG-- extra : rebase_source : 2f064f5662b02a3c2e76774908f4a15e7580720d extra : source : ad866775710347c330907a315d88784e56dec00e
This commit is contained in:
parent
154c9d2855
commit
c7c5848511
@ -83,14 +83,15 @@ WGLLibrary::EnsureInitialized()
|
||||
|
||||
mozilla::ScopedGfxFeatureReporter reporter("WGL");
|
||||
|
||||
std::string libGLFilename = "Opengl32.dll";
|
||||
std::wstring libGLFilename = L"Opengl32.dll";
|
||||
// SU_SPIES_DIRECTORY is for AMD CodeXL/gDEBugger
|
||||
if (PR_GetEnv("SU_SPIES_DIRECTORY")) {
|
||||
libGLFilename = std::string(PR_GetEnv("SU_SPIES_DIRECTORY")) + "\\opengl32.dll";
|
||||
if (_wgetenv(L"SU_SPIES_DIRECTORY")) {
|
||||
libGLFilename = std::wstring(_wgetenv(L"SU_SPIES_DIRECTORY")) +
|
||||
L"\\opengl32.dll";
|
||||
}
|
||||
|
||||
if (!mOGLLibrary) {
|
||||
mOGLLibrary = PR_LoadLibrary(libGLFilename.c_str());
|
||||
mOGLLibrary = LoadLibraryWithFlags(libGLFilename.c_str());
|
||||
if (!mOGLLibrary) {
|
||||
NS_WARNING("Couldn't load OpenGL library.");
|
||||
return false;
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#include "GLDefs.h"
|
||||
#include "nscore.h"
|
||||
#include "prlink.h"
|
||||
#include "mozilla/SharedLibrary.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gl {
|
||||
|
@ -6,11 +6,11 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "prlink.h"
|
||||
#include "prenv.h"
|
||||
#include "gfxPrefs.h"
|
||||
#include "nsString.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/SharedLibrary.h"
|
||||
|
||||
#include "mozilla/gfx/Quaternion.h"
|
||||
|
||||
@ -117,22 +117,28 @@ LoadOSVRRuntime()
|
||||
static PRLibrary* osvrClientKitLib = nullptr;
|
||||
//this looks up the path in the about:config setting, from greprefs.js or modules\libpref\init\all.js
|
||||
//we need all the libs to be valid
|
||||
#ifdef XP_WIN
|
||||
constexpr static auto* pfnGetPathStringPref = mozilla::Preferences::GetString;
|
||||
nsAutoString osvrUtilPath, osvrCommonPath, osvrClientPath, osvrClientKitPath;
|
||||
#else
|
||||
constexpr static auto* pfnGetPathStringPref = mozilla::Preferences::GetCString;
|
||||
nsAutoCString osvrUtilPath, osvrCommonPath, osvrClientPath, osvrClientKitPath;
|
||||
if (NS_FAILED(mozilla::Preferences::GetCString("gfx.vr.osvr.utilLibPath",
|
||||
osvrUtilPath)) ||
|
||||
NS_FAILED(mozilla::Preferences::GetCString("gfx.vr.osvr.commonLibPath",
|
||||
osvrCommonPath)) ||
|
||||
NS_FAILED(mozilla::Preferences::GetCString("gfx.vr.osvr.clientLibPath",
|
||||
osvrClientPath)) ||
|
||||
NS_FAILED(mozilla::Preferences::GetCString("gfx.vr.osvr.clientKitLibPath",
|
||||
osvrClientKitPath))) {
|
||||
#endif
|
||||
if (NS_FAILED(pfnGetPathStringPref("gfx.vr.osvr.utilLibPath",
|
||||
osvrUtilPath, PrefValueKind::User)) ||
|
||||
NS_FAILED(pfnGetPathStringPref("gfx.vr.osvr.commonLibPath",
|
||||
osvrCommonPath, PrefValueKind::User)) ||
|
||||
NS_FAILED(pfnGetPathStringPref("gfx.vr.osvr.clientLibPath",
|
||||
osvrClientPath, PrefValueKind::User)) ||
|
||||
NS_FAILED(pfnGetPathStringPref("gfx.vr.osvr.clientKitLibPath",
|
||||
osvrClientKitPath, PrefValueKind::User))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
osvrUtilLib = PR_LoadLibrary(osvrUtilPath.BeginReading());
|
||||
osvrCommonLib = PR_LoadLibrary(osvrCommonPath.BeginReading());
|
||||
osvrClientLib = PR_LoadLibrary(osvrClientPath.BeginReading());
|
||||
osvrClientKitLib = PR_LoadLibrary(osvrClientKitPath.BeginReading());
|
||||
osvrUtilLib = LoadLibraryWithFlags(osvrUtilPath.get());
|
||||
osvrCommonLib = LoadLibraryWithFlags(osvrCommonPath.get());
|
||||
osvrClientLib = LoadLibraryWithFlags(osvrClientPath.get());
|
||||
osvrClientKitLib = LoadLibraryWithFlags(osvrClientKitPath.get());
|
||||
|
||||
if (!osvrUtilLib) {
|
||||
printf_stderr("[OSVR] Failed to load OSVR Util library!\n");
|
||||
|
@ -11,12 +11,12 @@
|
||||
#include <math.h>
|
||||
|
||||
|
||||
#include "prlink.h"
|
||||
#include "prenv.h"
|
||||
#include "gfxPrefs.h"
|
||||
#include "nsString.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/SharedLibrary.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/gfx/DeviceManagerDx.h"
|
||||
#include "mozilla/layers/CompositorThread.h"
|
||||
@ -620,51 +620,52 @@ VROculusSession::LoadOvrLib()
|
||||
// Already loaded, early exit
|
||||
return true;
|
||||
}
|
||||
nsTArray<nsCString> libSearchPaths;
|
||||
nsCString libName;
|
||||
nsCString searchPath;
|
||||
|
||||
#if defined(_WIN32)
|
||||
nsTArray<nsString> libSearchPaths;
|
||||
nsString libName;
|
||||
nsString searchPath;
|
||||
|
||||
static const char dirSep = '\\';
|
||||
static const int pathLen = 260;
|
||||
searchPath.SetCapacity(pathLen);
|
||||
int realLen = ::GetSystemDirectoryA(searchPath.BeginWriting(), pathLen);
|
||||
int realLen = ::GetSystemDirectoryW(char16ptr_t(searchPath.BeginWriting()),
|
||||
pathLen);
|
||||
if (realLen != 0 && realLen < pathLen) {
|
||||
searchPath.SetLength(realLen);
|
||||
libSearchPaths.AppendElement(searchPath);
|
||||
}
|
||||
libName.AppendPrintf("LibOVRRT%d_%d.dll", BUILD_BITS, OVR_PRODUCT_VERSION);
|
||||
#else
|
||||
#error "Unsupported platform!"
|
||||
#endif
|
||||
|
||||
// search the path/module dir
|
||||
libSearchPaths.InsertElementsAt(0, 1, nsCString());
|
||||
libSearchPaths.InsertElementsAt(0, 1, EmptyString());
|
||||
|
||||
// If the env var is present, we override libName
|
||||
if (PR_GetEnv("OVR_LIB_PATH")) {
|
||||
searchPath = PR_GetEnv("OVR_LIB_PATH");
|
||||
if (_wgetenv(L"OVR_LIB_PATH")) {
|
||||
searchPath = _wgetenv(L"OVR_LIB_PATH");
|
||||
libSearchPaths.InsertElementsAt(0, 1, searchPath);
|
||||
}
|
||||
|
||||
if (PR_GetEnv("OVR_LIB_NAME")) {
|
||||
libName = PR_GetEnv("OVR_LIB_NAME");
|
||||
if (_wgetenv(L"OVR_LIB_NAME")) {
|
||||
libName = _wgetenv(L"OVR_LIB_NAME");
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < libSearchPaths.Length(); ++i) {
|
||||
nsCString& libPath = libSearchPaths[i];
|
||||
nsCString fullName;
|
||||
nsString& libPath = libSearchPaths[i];
|
||||
nsString fullName;
|
||||
if (libPath.Length() == 0) {
|
||||
fullName.Assign(libName);
|
||||
} else {
|
||||
fullName.AppendPrintf("%s%c%s", libPath.BeginReading(), dirSep, libName.BeginReading());
|
||||
fullName.AppendPrintf("%s%c%s", libPath.get(), dirSep, libName.get());
|
||||
}
|
||||
|
||||
mOvrLib = PR_LoadLibrary(fullName.BeginReading());
|
||||
mOvrLib = LoadLibraryWithFlags(fullName.get());
|
||||
if (mOvrLib) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
#error "Unsupported platform!"
|
||||
#endif
|
||||
|
||||
if (!mOvrLib) {
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user