| 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 | |
| 10 #include "gl/GrGLInterface.h" | 9 #include "gl/GrGLInterface.h" |
| 11 #include "gl/GrGLAssembleInterface.h" | 10 #include "gl/GrGLAssembleInterface.h" |
| 12 | 11 #include "../ports/SkOSLibrary.h" |
| 13 #if defined _WIN32 | |
| 14 #define WIN32_LEAN_AND_MEAN | |
| 15 #include <windows.h> | |
| 16 #else | |
| 17 #include <dlfcn.h> | |
| 18 #endif // defined _WIN32 | |
| 19 | 12 |
| 20 #include <EGL/egl.h> | 13 #include <EGL/egl.h> |
| 21 | 14 |
| 22 static GrGLFuncPtr angle_get_gl_proc(void* ctx, const char name[]) { | 15 static GrGLFuncPtr angle_get_gl_proc(void* ctx, const char name[]) { |
| 23 #if defined _WIN32 | 16 GrGLFuncPtr proc = (GrGLFuncPtr) GetProcedureAddress(ctx, name); |
| 24 GrGLFuncPtr proc = (GrGLFuncPtr) GetProcAddress((HMODULE)ctx, name); | |
| 25 #else | |
| 26 GrGLFuncPtr proc = (GrGLFuncPtr) dlsym(ctx, name); | |
| 27 #endif // defined _WIN32 | |
| 28 if (proc) { | 17 if (proc) { |
| 29 return proc; | 18 return proc; |
| 30 } | 19 } |
| 31 return eglGetProcAddress(name); | 20 return eglGetProcAddress(name); |
| 32 } | 21 } |
| 33 | 22 |
| 34 const GrGLInterface* GrGLCreateANGLEInterface() { | 23 const GrGLInterface* GrGLCreateANGLEInterface() { |
| 35 static void* gANGLELib = nullptr; | 24 static void* gANGLELib = nullptr; |
| 36 | 25 |
| 37 if (nullptr == gANGLELib) { | 26 if (nullptr == gANGLELib) { |
| 38 // We load the ANGLE library and never let it go | 27 // We load the ANGLE library and never let it go |
| 39 #if defined _WIN32 | 28 #if defined _WIN32 |
| 40 gANGLELib = LoadLibrary("libGLESv2.dll"); | 29 gANGLELib = DynamicLoadLibrary("libGLESv2.dll"); |
| 41 #else | 30 #else |
| 42 gANGLELib = dlopen("libGLESv2.so", RTLD_LAZY); | 31 gANGLELib = DynamicLoadLibrary("libGLESv2.so"); |
| 43 #endif // defined _WIN32 | 32 #endif // defined _WIN32 |
| 44 } | 33 } |
| 45 | 34 |
| 46 if (nullptr == gANGLELib) { | 35 if (nullptr == gANGLELib) { |
| 47 // We can't setup the interface correctly w/o the so | 36 // We can't setup the interface correctly w/o the so |
| 48 return nullptr; | 37 return nullptr; |
| 49 } | 38 } |
| 50 | 39 |
| 51 return GrGLAssembleGLESInterface(gANGLELib, angle_get_gl_proc); | 40 return GrGLAssembleGLESInterface(gANGLELib, angle_get_gl_proc); |
| 52 } | 41 } |
| OLD | NEW |