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
This commit is contained in:
parent
9442ab8a40
commit
b1ac52fb0f
@ -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': {
|
||||
|
@ -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,
|
||||
|
@ -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',
|
||||
|
@ -24,6 +24,9 @@ public:
|
||||
#if SK_SUPPORT_GPU
|
||||
kNativeGL_BackEndType,
|
||||
#endif
|
||||
#if SK_COMMAND_BUFFER
|
||||
kCommandBuffer_BackEndType,
|
||||
#endif // SK_COMMAND_BUFFER
|
||||
};
|
||||
|
||||
void detach();
|
||||
|
@ -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*);
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
|
16
src/ports/SkOSLibrary.h
Normal file
16
src/ports/SkOSLibrary.h
Normal file
@ -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
|
||||
|
18
src/ports/SkOSLibrary_posix.cpp
Normal file
18
src/ports/SkOSLibrary_posix.cpp
Normal file
@ -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);
|
||||
}
|
17
src/ports/SkOSLibrary_win.cpp
Normal file
17
src/ports/SkOSLibrary_win.cpp
Normal file
@ -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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user