From 6f0fdac9e7248c4e82ba2c9f6331694db0174bb2 Mon Sep 17 00:00:00 2001 From: hendrikw Date: Wed, 23 Sep 2015 11:35:55 -0700 Subject: [PATCH] skia: Add support for ANGLE on linux This will allow the ANGLE guys to test the ANGLE gl backend with nanobench and DM Review URL: https://codereview.chromium.org/1343193005 --- gyp/common.gypi | 4 +-- gyp/common_conditions.gypi | 11 ++++++++ gyp/common_variables.gypi | 12 ++++++++- include/views/SkOSWindow_Unix.h | 3 +++ src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp | 27 ++++++++++++++----- 5 files changed, 47 insertions(+), 10 deletions(-) diff --git a/gyp/common.gypi b/gyp/common.gypi index a3ce66e362..46ae9f37e7 100644 --- a/gyp/common.gypi +++ b/gyp/common.gypi @@ -30,8 +30,8 @@ [ 'skia_mesa and skia_os not in ["mac", "linux"]', { 'error': ' +#else +#include +#endif // defined _WIN32 + #include static GrGLFuncPtr angle_get_gl_proc(void* ctx, const char name[]) { +#if defined _WIN32 GrGLFuncPtr proc = (GrGLFuncPtr) GetProcAddress((HMODULE)ctx, name); +#else + GrGLFuncPtr proc = (GrGLFuncPtr) dlsym(ctx, name); +#endif // defined _WIN32 if (proc) { return proc; } @@ -23,17 +32,21 @@ static GrGLFuncPtr angle_get_gl_proc(void* ctx, const char name[]) { } const GrGLInterface* GrGLCreateANGLEInterface() { + static void* gANGLELib = nullptr; - static HMODULE ghANGLELib = nullptr; - - if (nullptr == ghANGLELib) { + if (nullptr == gANGLELib) { // We load the ANGLE library and never let it go - ghANGLELib = LoadLibrary("libGLESv2.dll"); +#if defined _WIN32 + gANGLELib = LoadLibrary("libGLESv2.dll"); +#else + gANGLELib = dlopen("libGLESv2.so", RTLD_LAZY); +#endif // defined _WIN32 } - if (nullptr == ghANGLELib) { - // We can't setup the interface correctly w/o the DLL + + if (nullptr == gANGLELib) { + // We can't setup the interface correctly w/o the so return nullptr; } - return GrGLAssembleGLESInterface(ghANGLELib, angle_get_gl_proc); + return GrGLAssembleGLESInterface(gANGLELib, angle_get_gl_proc); } -- 2.34.1