diff options
author | hendrikw <hendrikw@chromium.org> | 2015-10-01 18:29:34 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-01 18:29:34 -0700 |
commit | b1ac52fb0f8c5f03844ef3bbb198ba32427194b5 (patch) | |
tree | 0069759ea9576ba179656c7a5c7224bb6b56f538 | |
parent | 9442ab8a40dd0effde253e3b2d166bcf47222e92 (diff) |
Skia: Add Command Buffer support to Linux/Mac
Code added to load libcommand_buffer_gles2.so on linux or
mac.
Review URL: https://codereview.chromium.org/1346423002
-rw-r--r-- | gyp/common_conditions.gypi | 6 | ||||
-rw-r--r-- | gyp/common_variables.gypi | 2 | ||||
-rw-r--r-- | gyp/ports.gyp | 5 | ||||
-rw-r--r-- | include/views/SkOSWindow_Mac.h | 3 | ||||
-rw-r--r-- | include/views/SkOSWindow_Unix.h | 3 | ||||
-rw-r--r-- | src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp | 19 | ||||
-rw-r--r-- | src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp | 44 | ||||
-rw-r--r-- | src/ports/SkOSLibrary.h | 16 | ||||
-rw-r--r-- | src/ports/SkOSLibrary_posix.cpp | 18 | ||||
-rw-r--r-- | src/ports/SkOSLibrary_win.cpp | 17 |
10 files changed, 97 insertions, 36 deletions
diff --git a/gyp/common_conditions.gypi b/gyp/common_conditions.gypi index 54fa54345e..a06fcb77c1 100644 --- a/gyp/common_conditions.gypi +++ b/gyp/common_conditions.gypi @@ -618,6 +618,12 @@ ], }], + [ 'skia_command_buffer', { + 'ldflags': [ + '-Wl,-rpath,\$$ORIGIN/lib', + ], + }], + ], # end 'conditions' # The Xcode SYMROOT must be at the root. See build/common.gypi in chromium for more details 'xcode_settings': { diff --git a/gyp/common_variables.gypi b/gyp/common_variables.gypi index e8a835541c..57fad1d890 100644 --- a/gyp/common_variables.gypi +++ b/gyp/common_variables.gypi @@ -181,7 +181,7 @@ 'skia_clang_build%': 0, 'skia_keep_frame_pointer%': 0, }], - [ 'skia_shared_lib or skia_sanitizer or skia_os == "android" or (skia_os == "linux" and skia_angle == 1)', { + [ 'skia_shared_lib or skia_sanitizer or skia_os == "android" or (skia_os == "linux" and (skia_angle == 1 or skia_command_buffer == 1))', { 'skia_pic%' : 1, }, { 'skia_pic%' : 0, diff --git a/gyp/ports.gyp b/gyp/ports.gyp index f111650113..c227a803a8 100644 --- a/gyp/ports.gyp +++ b/gyp/ports.gyp @@ -51,6 +51,9 @@ '../src/ports/SkOSFile_posix.cpp', '../src/ports/SkOSFile_stdio.cpp', '../src/ports/SkOSFile_win.cpp', + '../src/ports/SkOSLibrary.h', + '../src/ports/SkOSLibrary_posix.cpp', + '../src/ports/SkOSLibrary_win.cpp', '../src/ports/SkDiscardableMemory_none.cpp', '../src/ports/SkTime_Unix.cpp', '../src/ports/SkTime_win.cpp', @@ -171,6 +174,7 @@ 'sources!': [ # these are used everywhere but windows '../src/ports/SkDebug_stdio.cpp', '../src/ports/SkOSFile_posix.cpp', + '../src/ports/SkOSLibrary_posix.cpp', '../src/ports/SkTime_Unix.cpp', '../src/ports/SkTLS_pthread.cpp', ], @@ -188,6 +192,7 @@ '../src/ports/SkFontHost_win.cpp', '../src/ports/SkFontMgr_win_dw.cpp', '../src/ports/SkOSFile_win.cpp', + '../src/ports/SkOSLibrary_win.cpp', '../src/ports/SkRemotableFontMgr_win_dw.cpp', '../src/ports/SkTime_win.cpp', '../src/ports/SkTLS_win.cpp', diff --git a/include/views/SkOSWindow_Mac.h b/include/views/SkOSWindow_Mac.h index e4c090abf3..5063c74e6d 100644 --- a/include/views/SkOSWindow_Mac.h +++ b/include/views/SkOSWindow_Mac.h @@ -24,6 +24,9 @@ public: #if SK_SUPPORT_GPU kNativeGL_BackEndType, #endif +#if SK_COMMAND_BUFFER + kCommandBuffer_BackEndType, +#endif // SK_COMMAND_BUFFER }; void detach(); diff --git a/include/views/SkOSWindow_Unix.h b/include/views/SkOSWindow_Unix.h index d7fcf6e392..ecd0a14521 100644 --- a/include/views/SkOSWindow_Unix.h +++ b/include/views/SkOSWindow_Unix.h @@ -39,6 +39,9 @@ public: #if SK_ANGLE kANGLE_BackEndType, #endif // SK_ANGLE +#if SK_COMMAND_BUFFER + kCommandBuffer_BackEndType, +#endif // SK_COMMAND_BUFFER }; bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*); diff --git a/src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp b/src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp index 9a4dffb4b1..1ebd376288 100644 --- a/src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp +++ b/src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp @@ -6,25 +6,14 @@ * found in the LICENSE file. */ - #include "gl/GrGLInterface.h" #include "gl/GrGLAssembleInterface.h" - -#if defined _WIN32 -#define WIN32_LEAN_AND_MEAN -#include <windows.h> -#else -#include <dlfcn.h> -#endif // defined _WIN32 +#include "../ports/SkOSLibrary.h" #include <EGL/egl.h> 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 + GrGLFuncPtr proc = (GrGLFuncPtr) GetProcedureAddress(ctx, name); if (proc) { return proc; } @@ -37,9 +26,9 @@ const GrGLInterface* GrGLCreateANGLEInterface() { if (nullptr == gANGLELib) { // We load the ANGLE library and never let it go #if defined _WIN32 - gANGLELib = LoadLibrary("libGLESv2.dll"); + gANGLELib = DynamicLoadLibrary("libGLESv2.dll"); #else - gANGLELib = dlopen("libGLESv2.so", RTLD_LAZY); + gANGLELib = DynamicLoadLibrary("libGLESv2.so"); #endif // defined _WIN32 } diff --git a/src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp b/src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp index 11a8444853..bb1908651f 100644 --- a/src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp +++ b/src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp @@ -11,6 +11,7 @@ #include "gl/GrGLInterface.h" #include "gl/GrGLAssembleInterface.h" #include "gl/command_buffer/SkCommandBufferGLContext.h" +#include "../ports/SkOSLibrary.h" typedef EGLDisplay (*GetDisplayProc)(EGLNativeDisplayType display_id); typedef EGLBoolean (*InitializeProc)(EGLDisplay dpy, EGLint *major, EGLint *minor); @@ -40,27 +41,30 @@ static MakeCurrentProc gfMakeCurrent = nullptr; static SwapBuffersProc gfSwapBuffers = nullptr; static GetProcAddressProc gfGetProcAddress = nullptr; -static HMODULE ghLibrary = nullptr; +static void* gLibrary = nullptr; static bool gfFunctionsLoadedSuccessfully = false; static void load_command_buffer_functions() { - if (!ghLibrary) { - ghLibrary = LoadLibrary("command_buffer_gles2.dll"); - - if (ghLibrary) { - gfGetDisplay = (GetDisplayProc)::GetProcAddress(ghLibrary, "eglGetDisplay"); - gfInitialize = (InitializeProc)::GetProcAddress(ghLibrary, "eglInitialize"); - gfTerminate = (TerminateProc)::GetProcAddress(ghLibrary, "eglTerminate"); - gfChooseConfig = (ChooseConfigProc)::GetProcAddress(ghLibrary, "eglChooseConfig"); - gfGetConfigAttrib = (GetConfigAttrib)::GetProcAddress(ghLibrary, "eglGetConfigAttrib"); - gfCreateWindowSurface = (CreateWindowSurfaceProc)::GetProcAddress(ghLibrary, "eglCreateWindowSurface"); - gfCreatePbufferSurface = (CreatePbufferSurfaceProc)::GetProcAddress(ghLibrary, "eglCreatePbufferSurface"); - gfDestroySurface = (DestroySurfaceProc)::GetProcAddress(ghLibrary, "eglDestroySurface"); - gfCreateContext = (CreateContextProc)::GetProcAddress(ghLibrary, "eglCreateContext"); - gfDestroyContext = (DestroyContextProc)::GetProcAddress(ghLibrary, "eglDestroyContext"); - gfMakeCurrent = (MakeCurrentProc)::GetProcAddress(ghLibrary, "eglMakeCurrent"); - gfSwapBuffers = (SwapBuffersProc)::GetProcAddress(ghLibrary, "eglSwapBuffers"); - gfGetProcAddress = (GetProcAddressProc)::GetProcAddress(ghLibrary, "eglGetProcAddress"); + if (!gLibrary) { +#if defined _WIN32 + gLibrary = DynamicLoadLibrary("command_buffer_gles2.dll"); +#else + gLibrary = DynamicLoadLibrary("libcommand_buffer_gles2.so"); +#endif // defined _WIN32 + if (gLibrary) { + gfGetDisplay = (GetDisplayProc)GetProcedureAddress(gLibrary, "eglGetDisplay"); + gfInitialize = (InitializeProc)GetProcedureAddress(gLibrary, "eglInitialize"); + gfTerminate = (TerminateProc)GetProcedureAddress(gLibrary, "eglTerminate"); + gfChooseConfig = (ChooseConfigProc)GetProcedureAddress(gLibrary, "eglChooseConfig"); + gfGetConfigAttrib = (GetConfigAttrib)GetProcedureAddress(gLibrary, "eglGetConfigAttrib"); + gfCreateWindowSurface = (CreateWindowSurfaceProc)GetProcedureAddress(gLibrary, "eglCreateWindowSurface"); + gfCreatePbufferSurface = (CreatePbufferSurfaceProc)GetProcedureAddress(gLibrary, "eglCreatePbufferSurface"); + gfDestroySurface = (DestroySurfaceProc)GetProcedureAddress(gLibrary, "eglDestroySurface"); + gfCreateContext = (CreateContextProc)GetProcedureAddress(gLibrary, "eglCreateContext"); + gfDestroyContext = (DestroyContextProc)GetProcedureAddress(gLibrary, "eglDestroyContext"); + gfMakeCurrent = (MakeCurrentProc)GetProcedureAddress(gLibrary, "eglMakeCurrent"); + gfSwapBuffers = (SwapBuffersProc)GetProcedureAddress(gLibrary, "eglSwapBuffers"); + gfGetProcAddress = (GetProcAddressProc)GetProcedureAddress(gLibrary, "eglGetProcAddress"); gfFunctionsLoadedSuccessfully = gfGetDisplay && gfInitialize && gfTerminate && gfChooseConfig && gfCreateWindowSurface && @@ -73,7 +77,7 @@ static void load_command_buffer_functions() { } static GrGLFuncPtr command_buffer_get_gl_proc(void* ctx, const char name[]) { - GrGLFuncPtr proc = (GrGLFuncPtr) GetProcAddress((HMODULE)ctx, name); + GrGLFuncPtr proc = (GrGLFuncPtr) GetProcedureAddress(ctx, name); if (proc) { return proc; } @@ -93,7 +97,7 @@ const GrGLInterface* GrGLCreateCommandBufferInterface() { if (!gfFunctionsLoadedSuccessfully) { return nullptr; } - return GrGLAssembleGLESInterface(ghLibrary, command_buffer_get_gl_proc); + return GrGLAssembleGLESInterface(gLibrary, command_buffer_get_gl_proc); } SkCommandBufferGLContext::SkCommandBufferGLContext() diff --git a/src/ports/SkOSLibrary.h b/src/ports/SkOSLibrary.h new file mode 100644 index 0000000000..7de2b902e3 --- /dev/null +++ b/src/ports/SkOSLibrary.h @@ -0,0 +1,16 @@ + +/* + * Copyright 2015 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef SkOSLibrary_DEFINED +#define SkOSLibrary_DEFINED + +void* DynamicLoadLibrary(const char* libraryName); +void* GetProcedureAddress(void* library, const char* functionName); + +#endif + diff --git a/src/ports/SkOSLibrary_posix.cpp b/src/ports/SkOSLibrary_posix.cpp new file mode 100644 index 0000000000..cca55f16a1 --- /dev/null +++ b/src/ports/SkOSLibrary_posix.cpp @@ -0,0 +1,18 @@ + +/* + * Copyright 2015 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#include "SkOSLibrary.h" + +#include <dlfcn.h> + +void* DynamicLoadLibrary(const char* libraryName) { + return dlopen(libraryName, RTLD_LAZY); +} + +void* GetProcedureAddress(void* library, const char* functionName) { + return dlsym(library, functionName); +} diff --git a/src/ports/SkOSLibrary_win.cpp b/src/ports/SkOSLibrary_win.cpp new file mode 100644 index 0000000000..ca80415391 --- /dev/null +++ b/src/ports/SkOSLibrary_win.cpp @@ -0,0 +1,17 @@ + +/* + * Copyright 2015 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#include "SkOSLibrary.h" +#include <windows.h> + +void* DynamicLoadLibrary(const char* libraryName) { + return LoadLibrary(libraryName); +} + +void* GetProcedureAddress(void* library, const char* functionName) { + return ::GetProcAddress((HMODULE)library, functionName); +} |