| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #include "gl/GrGLInterface.h" | 10 #include "gl/GrGLInterface.h" |
| 11 #include "gl/GrGLAssembleInterface.h" | 11 #include "gl/GrGLAssembleInterface.h" |
| 12 | 12 |
| 13 #if defined _WIN32 |
| 13 #define WIN32_LEAN_AND_MEAN | 14 #define WIN32_LEAN_AND_MEAN |
| 14 #include <windows.h> | 15 #include <windows.h> |
| 16 #else |
| 17 #include <dlfcn.h> |
| 18 #endif // defined _WIN32 |
| 19 |
| 15 #include <EGL/egl.h> | 20 #include <EGL/egl.h> |
| 16 | 21 |
| 17 static GrGLFuncPtr angle_get_gl_proc(void* ctx, const char name[]) { | 22 static GrGLFuncPtr angle_get_gl_proc(void* ctx, const char name[]) { |
| 23 #if defined _WIN32 |
| 18 GrGLFuncPtr proc = (GrGLFuncPtr) GetProcAddress((HMODULE)ctx, name); | 24 GrGLFuncPtr proc = (GrGLFuncPtr) GetProcAddress((HMODULE)ctx, name); |
| 25 #else |
| 26 GrGLFuncPtr proc = (GrGLFuncPtr) dlsym(ctx, name); |
| 27 #endif // defined _WIN32 |
| 19 if (proc) { | 28 if (proc) { |
| 20 return proc; | 29 return proc; |
| 21 } | 30 } |
| 22 return eglGetProcAddress(name); | 31 return eglGetProcAddress(name); |
| 23 } | 32 } |
| 24 | 33 |
| 25 const GrGLInterface* GrGLCreateANGLEInterface() { | 34 const GrGLInterface* GrGLCreateANGLEInterface() { |
| 35 static void* gANGLELib = nullptr; |
| 26 | 36 |
| 27 static HMODULE ghANGLELib = nullptr; | 37 if (nullptr == gANGLELib) { |
| 38 // We load the ANGLE library and never let it go |
| 39 #if defined _WIN32 |
| 40 gANGLELib = LoadLibrary("libGLESv2.dll"); |
| 41 #else |
| 42 gANGLELib = dlopen("libGLESv2.so", RTLD_LAZY); |
| 43 #endif // defined _WIN32 |
| 44 } |
| 28 | 45 |
| 29 if (nullptr == ghANGLELib) { | 46 if (nullptr == gANGLELib) { |
| 30 // We load the ANGLE library and never let it go | 47 // We can't setup the interface correctly w/o the so |
| 31 ghANGLELib = LoadLibrary("libGLESv2.dll"); | |
| 32 } | |
| 33 if (nullptr == ghANGLELib) { | |
| 34 // We can't setup the interface correctly w/o the DLL | |
| 35 return nullptr; | 48 return nullptr; |
| 36 } | 49 } |
| 37 | 50 |
| 38 return GrGLAssembleGLESInterface(ghANGLELib, angle_get_gl_proc); | 51 return GrGLAssembleGLESInterface(gANGLELib, angle_get_gl_proc); |
| 39 } | 52 } |
| OLD | NEW |