aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar hendrikw <hendrikw@chromium.org>2015-10-27 10:04:34 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-10-27 10:04:34 -0700
commit855dc9395f3b13e1087aae3351a2a368fb89c11e (patch)
treef0c32b2ab534f081e81af3d0976793cd190f29db
parent423e337782f65b6861a45a4ecff84192994ced1d (diff)
skia: Fix command buffer support on the mac
The extension on the mac is .dylib, updated the name. EGL.h isn't available on mac (unless we include skia_angle.h). I've got a somewhat bad hack of defining the types that I need to get this running. GetProcedureAddress was somehow successfully grabbing gl functions from another lib. Removed this call, I copied it from ANGLE impl, but it isn't required. lib load path works differently, fixed in GYP BUG=skia:2992 Review URL: https://codereview.chromium.org/1403153002
-rw-r--r--gyp/common_conditions.gypi8
-rw-r--r--src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp54
2 files changed, 52 insertions, 10 deletions
diff --git a/gyp/common_conditions.gypi b/gyp/common_conditions.gypi
index bbe716b9de..02113c3f8a 100644
--- a/gyp/common_conditions.gypi
+++ b/gyp/common_conditions.gypi
@@ -617,12 +617,18 @@
],
}],
- [ 'skia_command_buffer', {
+ [ 'skia_command_buffer and skia_os == "linux"', {
'ldflags': [
'-Wl,-rpath,\$$ORIGIN/lib',
],
}],
+ [ 'skia_command_buffer and skia_os == "mac"', {
+ 'xcode_settings': {
+ 'LD_RUNPATH_SEARCH_PATHS': ['@executable_path/.'],
+ },
+ }],
+
], # end 'conditions'
# The Xcode SYMROOT must be at the root. See build/common.gypi in chromium for more details
'xcode_settings': {
diff --git a/src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp b/src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp
index bb1908651f..585f1d079e 100644
--- a/src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp
+++ b/src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp
@@ -5,14 +5,52 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include <EGL/egl.h>
-
#include "SkOnce.h"
#include "gl/GrGLInterface.h"
#include "gl/GrGLAssembleInterface.h"
#include "gl/command_buffer/SkCommandBufferGLContext.h"
#include "../ports/SkOSLibrary.h"
+#if defined SK_BUILD_FOR_MAC
+
+// EGL doesn't exist on the mac, so expose what we need to get the command buffer's EGL running.
+typedef void *EGLDisplay;
+typedef unsigned int EGLBoolean;
+typedef void *EGLConfig;
+typedef void *EGLSurface;
+typedef void *EGLContext;
+typedef int32_t EGLint;
+typedef void* EGLNativeDisplayType;
+typedef void* EGLNativeWindowType;
+typedef void (*__eglMustCastToProperFunctionPointerType)(void);
+#define EGL_FALSE 0
+#define EGL_OPENGL_ES2_BIT 0x0004
+#define EGL_CONTEXT_CLIENT_VERSION 0x3098
+#define EGL_NO_SURFACE ((EGLSurface)0)
+#define EGL_NO_DISPLAY ((EGLDisplay)0)
+#define EGL_NO_CONTEXT ((EGLContext)0)
+#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0)
+#define EGL_SURFACE_TYPE 0x3033
+#define EGL_PBUFFER_BIT 0x0001
+#define EGL_RENDERABLE_TYPE 0x3040
+#define EGL_RED_SIZE 0x3024
+#define EGL_GREEN_SIZE 0x3023
+#define EGL_BLUE_SIZE 0x3022
+#define EGL_ALPHA_SIZE 0x3021
+#define EGL_DEPTH_SIZE 0x3025
+#define EGL_STENCIL_SIZE 0x3025
+#define EGL_SAMPLES 0x3031
+#define EGL_SAMPLE_BUFFERS 0x3032
+#define EGL_NONE 0x3038
+#define EGL_WIDTH 0x3057
+#define EGL_HEIGHT 0x3056
+
+#else
+
+#include <EGL/egl.h>
+
+#endif
+
typedef EGLDisplay (*GetDisplayProc)(EGLNativeDisplayType display_id);
typedef EGLBoolean (*InitializeProc)(EGLDisplay dpy, EGLint *major, EGLint *minor);
typedef EGLBoolean (*TerminateProc)(EGLDisplay dpy);
@@ -48,6 +86,8 @@ static void load_command_buffer_functions() {
if (!gLibrary) {
#if defined _WIN32
gLibrary = DynamicLoadLibrary("command_buffer_gles2.dll");
+#elif defined SK_BUILD_FOR_MAC
+ gLibrary = DynamicLoadLibrary("libcommand_buffer_gles2.dylib");
#else
gLibrary = DynamicLoadLibrary("libcommand_buffer_gles2.so");
#endif // defined _WIN32
@@ -72,15 +112,11 @@ static void load_command_buffer_functions() {
gfCreateContext && gfDestroyContext && gfMakeCurrent &&
gfSwapBuffers && gfGetProcAddress;
- }
- }
+ }
+ }
}
static GrGLFuncPtr command_buffer_get_gl_proc(void* ctx, const char name[]) {
- GrGLFuncPtr proc = (GrGLFuncPtr) GetProcedureAddress(ctx, name);
- if (proc) {
- return proc;
- }
if (!gfFunctionsLoadedSuccessfully) {
return nullptr;
}
@@ -167,7 +203,7 @@ void SkCommandBufferGLContext::initializeGLContext(void* nativeWindow, const int
gfChooseConfig(fDisplay, configAttribs, &surfaceConfig, 1, &numConfigs);
if (nativeWindow) {
- fSurface = gfCreateWindowSurface(fDisplay, surfaceConfig,
+ fSurface = gfCreateWindowSurface(fDisplay, surfaceConfig,
(EGLNativeWindowType)nativeWindow, surfaceAttribs);
} else {
fSurface = gfCreatePbufferSurface(fDisplay, surfaceConfig, surfaceAttribs);