From 1cea736c3280b6f0553e3eaa598e41370b305b57 Mon Sep 17 00:00:00 2001 From: derekf Date: Tue, 23 Sep 2014 15:17:36 -0700 Subject: [PATCH] Add support for EGL on linux Allow setting skia_egl=1 to build skia against EGL instead of GLX on unix R=bsalomon@google.com, djsollen@google.com Author: derekf@osg.samsung.com Review URL: https://codereview.chromium.org/543363004 --- gyp/common_variables.gypi | 7 ++++++ gyp/gpu.gyp | 24 +++++++++++++++++++ gyp/gpu.gypi | 3 ++- include/gpu/gl/SkNativeGLContext.h | 6 ++--- .../gl/egl/GrGLCreateNativeInterface_egl.cpp | 22 +++++++++++++++++ .../SkNativeGLContext_egl.cpp} | 0 6 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 src/gpu/gl/egl/GrGLCreateNativeInterface_egl.cpp rename src/gpu/gl/{android/SkNativeGLContext_android.cpp => egl/SkNativeGLContext_egl.cpp} (100%) diff --git a/gyp/common_variables.gypi b/gyp/common_variables.gypi index 6d791c9152..b13b475267 100644 --- a/gyp/common_variables.gypi +++ b/gyp/common_variables.gypi @@ -50,6 +50,7 @@ 'skia_arch_type%': 'x86', 'arm_version%': 0, 'arm_neon%': 0, + 'skia_egl%': 0, }, # Re-define all variables defined within the level-3 'variables' dict, @@ -59,6 +60,7 @@ 'skia_arch_type%': '<(skia_arch_type)', 'arm_version%': '<(arm_version)', 'arm_neon%': '<(arm_neon)', + 'skia_egl%': '<(skia_egl)', 'conditions': [ [ 'skia_android_framework == 1', { @@ -87,6 +89,7 @@ }], [ 'skia_os == "android"', { 'skia_static_initializers%': 0, + 'skia_egl%': 1, }, { 'skia_static_initializers%': 1, }], @@ -95,6 +98,9 @@ 'arm_version%': 7, 'arm_neon%': 0, # neon asm files known not to work with the ios build }], + [ 'skia_os in "nacl"', { + 'skia_egl%': 1, + }], [ 'skia_os in ["android", "nacl"] and not skia_android_framework', # skia_freetype_static - on OS variants that normally would # dynamically link the system FreeType library, don't do @@ -233,6 +239,7 @@ 'skia_disable_inlining%': 0, 'skia_moz2d%': 0, 'skia_is_bot%': ' -#elif defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_NACL) +#elif defined(SK_EGL) #include #include #elif defined(SK_BUILD_FOR_UNIX) @@ -64,7 +64,7 @@ public: private: #if defined(SK_BUILD_FOR_MAC) CGLContextObj fOldCGLContext; - #elif defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_NACL) + #elif defined(SK_EGL) EGLContext fOldEGLContext; EGLDisplay fOldDisplay; EGLSurface fOldSurface; @@ -88,7 +88,7 @@ protected: private: #if defined(SK_BUILD_FOR_MAC) CGLContextObj fContext; -#elif defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_NACL) +#elif defined(SK_EGL) EGLContext fContext; EGLDisplay fDisplay; EGLSurface fSurface; diff --git a/src/gpu/gl/egl/GrGLCreateNativeInterface_egl.cpp b/src/gpu/gl/egl/GrGLCreateNativeInterface_egl.cpp new file mode 100644 index 0000000000..ddc9e693a4 --- /dev/null +++ b/src/gpu/gl/egl/GrGLCreateNativeInterface_egl.cpp @@ -0,0 +1,22 @@ + +/* + * Copyright 2014 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#include "gl/GrGLInterface.h" +#include "gl/GrGLAssembleInterface.h" +#include "gl/GrGLUtil.h" + +#include +#include + +static GrGLFuncPtr egl_get_gl_proc(void* ctx, const char name[]) { + SkASSERT(NULL == ctx); + return eglGetProcAddress(name); +} + +const GrGLInterface* GrGLCreateNativeInterface() { + return GrGLAssembleInterface(NULL, egl_get_gl_proc); +} diff --git a/src/gpu/gl/android/SkNativeGLContext_android.cpp b/src/gpu/gl/egl/SkNativeGLContext_egl.cpp similarity index 100% rename from src/gpu/gl/android/SkNativeGLContext_android.cpp rename to src/gpu/gl/egl/SkNativeGLContext_egl.cpp