OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2012 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #include "gl/GrGLInterface.h" |
| 9 #include "gl/GrGLAssembleInterface.h" |
| 10 #include "../ports/SkOSLibrary.h" |
| 11 |
| 12 #include <EGL/egl.h> |
| 13 |
| 14 namespace { |
| 15 struct Libs { |
| 16 void* fGLLib; |
| 17 void* fEGLLib; |
| 18 }; |
| 19 } |
| 20 |
| 21 static GrGLFuncPtr angle_get_gl_proc(void* ctx, const char name[]) { |
| 22 const Libs* libs = reinterpret_cast<const Libs*>(ctx); |
| 23 GrGLFuncPtr proc = (GrGLFuncPtr) GetProcedureAddress(libs->fGLLib, name); |
| 24 if (proc) { |
| 25 return proc; |
| 26 } |
| 27 proc = (GrGLFuncPtr) GetProcedureAddress(libs->fEGLLib, name); |
| 28 if (proc) { |
| 29 return proc; |
| 30 } |
| 31 return eglGetProcAddress(name); |
| 32 } |
| 33 |
| 34 const GrGLInterface* GrGLCreateANGLEInterface() { |
| 35 static Libs gLibs = { nullptr, nullptr }; |
| 36 |
| 37 if (nullptr == gLibs.fGLLib) { |
| 38 // We load the ANGLE library and never let it go |
| 39 #if defined _WIN32 |
| 40 gLibs.fGLLib = DynamicLoadLibrary("libGLESv2.dll"); |
| 41 gLibs.fEGLLib = DynamicLoadLibrary("libEGL.dll"); |
| 42 #elif defined SK_BUILD_FOR_MAC |
| 43 gLibs.fGLLib = DynamicLoadLibrary("libGLESv2.dylib"); |
| 44 gLibs.fEGLLib = DynamicLoadLibrary("libEGL.dylib"); |
| 45 #else |
| 46 gLibs.fGLLib = DynamicLoadLibrary("libGLESv2.so"); |
| 47 gLibs.fEGLLib = DynamicLoadLibrary("libEGL.so"); |
| 48 #endif |
| 49 } |
| 50 |
| 51 if (nullptr == gLibs.fGLLib || nullptr == gLibs.fEGLLib) { |
| 52 // We can't setup the interface correctly w/o the so |
| 53 return nullptr; |
| 54 } |
| 55 |
| 56 return GrGLAssembleGLESInterface(&gLibs, angle_get_gl_proc); |
| 57 } |
OLD | NEW |