From 1b2707bbf9bfe5d9f8210fb1d8511a4f32e591c9 Mon Sep 17 00:00:00 2001 From: "apatrick@chromium.org" Date: Wed, 6 Oct 2010 19:37:16 +0000 Subject: Load libGLESv2.dll before libEGL.dll. EGL is dependent on GLESv2 so load the latter first in case there is another version somewhere in the DLL search path. TEST=try BUG=58064 Review URL: http://codereview.chromium.org/3609011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61690 0039d316-1c4b-4281-b951-d872f2087c98 --- app/gfx/gl/gl_implementation_linux.cc | 26 +++++++++++++++++++++----- app/gfx/gl/gl_implementation_mac.cc | 5 +++++ app/gfx/gl/gl_implementation_win.cc | 29 ++++++++++++++++++++++++----- 3 files changed, 50 insertions(+), 10 deletions(-) (limited to 'app/gfx') diff --git a/app/gfx/gl/gl_implementation_linux.cc b/app/gfx/gl/gl_implementation_linux.cc index ddcecd8..2637f75 100644 --- a/app/gfx/gl/gl_implementation_linux.cc +++ b/app/gfx/gl/gl_implementation_linux.cc @@ -56,6 +56,11 @@ bool InitializeGLBindings(GLImplementation implementation) { reinterpret_cast( base::GetFunctionPointerFromNativeLibrary( library, "OSMesaGetProcAddress")); + if (!get_proc_address) { + DLOG(ERROR) << "OSMesaGetProcAddress not found."; + base::UnloadNativeLibrary(library); + return false; + } SetGLGetProcAddressProc(get_proc_address); AddGLNativeLibrary(library); @@ -77,6 +82,11 @@ bool InitializeGLBindings(GLImplementation implementation) { reinterpret_cast( base::GetFunctionPointerFromNativeLibrary( library, "glXGetProcAddress")); + if (!get_proc_address) { + LOG(ERROR) << "glxGetProcAddress not found."; + base::UnloadNativeLibrary(library); + return false; + } SetGLGetProcAddressProc(get_proc_address); AddGLNativeLibrary(library); @@ -87,10 +97,18 @@ bool InitializeGLBindings(GLImplementation implementation) { break; } case kGLImplementationEGLGLES2: { + base::NativeLibrary gles_library = base::LoadNativeLibrary( + FilePath("libGLESv2.so")); + if (!gles_library) { + DLOG(ERROR) << "libGLESv2.so not found"; + return false; + } + base::NativeLibrary egl_library = base::LoadNativeLibrary( FilePath("libEGL.so")); if (!egl_library) { DLOG(ERROR) << "libEGL.so not found"; + base::UnloadNativeLibrary(gles_library); return false; } @@ -98,12 +116,10 @@ bool InitializeGLBindings(GLImplementation implementation) { reinterpret_cast( base::GetFunctionPointerFromNativeLibrary( egl_library, "eglGetProcAddress")); - - base::NativeLibrary gles_library = base::LoadNativeLibrary( - FilePath("libGLESv2.so")); - if (!gles_library) { + if (!get_proc_address) { + LOG(ERROR) << "eglGetProcAddress not found."; base::UnloadNativeLibrary(egl_library); - DLOG(ERROR) << "libGLESv2.so not found"; + base::UnloadNativeLibrary(gles_library); return false; } diff --git a/app/gfx/gl/gl_implementation_mac.cc b/app/gfx/gl/gl_implementation_mac.cc index 877ca38..73f8462 100644 --- a/app/gfx/gl/gl_implementation_mac.cc +++ b/app/gfx/gl/gl_implementation_mac.cc @@ -43,6 +43,11 @@ bool InitializeGLBindings(GLImplementation implementation) { reinterpret_cast( base::GetFunctionPointerFromNativeLibrary( library, "OSMesaGetProcAddress")); + if (!get_proc_address) { + LOG(ERROR) << "OSMesaGetProcAddress not found."; + base::UnloadNativeLibrary(library); + return false; + } SetGLGetProcAddressProc(get_proc_address); AddGLNativeLibrary(library); diff --git a/app/gfx/gl/gl_implementation_win.cc b/app/gfx/gl/gl_implementation_win.cc index ccc671c..ed4178a 100644 --- a/app/gfx/gl/gl_implementation_win.cc +++ b/app/gfx/gl/gl_implementation_win.cc @@ -53,6 +53,11 @@ bool InitializeGLBindings(GLImplementation implementation) { reinterpret_cast( base::GetFunctionPointerFromNativeLibrary( library, "OSMesaGetProcAddress")); + if (!get_proc_address) { + DLOG(ERROR) << "OSMesaGetProcAddress not found."; + base::UnloadNativeLibrary(library); + return false; + } SetGLGetProcAddressProc(get_proc_address); AddGLNativeLibrary(library); @@ -67,12 +72,23 @@ bool InitializeGLBindings(GLImplementation implementation) { if (!PathService::Get(base::DIR_MODULE, &module_path)) return false; + // Load libglesv2.dll before libegl.dll because the latter is dependent on + // the former and if there is another version of libglesv2.dll in the dll + // search path, it will get loaded. + base::NativeLibrary gles_library = base::LoadNativeLibrary( + module_path.Append(L"libglesv2.dll")); + if (!gles_library) { + LOG(ERROR) << "libglesv2.dll not found"; + return false; + } + // When using EGL, first try eglGetProcAddress and then Windows // GetProcAddress on both the EGL and GLES2 DLLs. base::NativeLibrary egl_library = base::LoadNativeLibrary( module_path.Append(L"libegl.dll")); if (!egl_library) { LOG(ERROR) << "libegl.dll not found."; + base::UnloadNativeLibrary(gles_library); return false; } @@ -80,12 +96,10 @@ bool InitializeGLBindings(GLImplementation implementation) { reinterpret_cast( base::GetFunctionPointerFromNativeLibrary( egl_library, "eglGetProcAddress")); - - base::NativeLibrary gles_library = base::LoadNativeLibrary( - module_path.Append(L"libglesv2.dll")); - if (!gles_library) { + if (!get_proc_address) { + LOG(ERROR) << "eglGetProcAddress not found."; base::UnloadNativeLibrary(egl_library); - LOG(ERROR) << "libglesv2.dll not found"; + base::UnloadNativeLibrary(gles_library); return false; } @@ -117,6 +131,11 @@ bool InitializeGLBindings(GLImplementation implementation) { reinterpret_cast( base::GetFunctionPointerFromNativeLibrary( library, "wglGetProcAddress")); + if (!get_proc_address) { + LOG(ERROR) << "wglGetProcAddress not found."; + base::UnloadNativeLibrary(library); + return false; + } SetGLGetProcAddressProc(get_proc_address); AddGLNativeLibrary(library); -- cgit v1.1