Support building GrGLInterface factory functions for both EGL and GLX.
Bug: skia:11293 Change-Id: Ie99c587fd8d466cb4260d8a78b9cff84a63315e2 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372200 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
90be6c154e
commit
be6de9b54e
15
BUILD.gn
15
BUILD.gn
@ -882,19 +882,28 @@ optional("gpu") {
|
||||
if (skia_use_gl) {
|
||||
public_defines += [ "SK_GL" ]
|
||||
if (is_android) {
|
||||
sources += [ "src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp" ]
|
||||
sources += [
|
||||
"src/gpu/gl/egl/GrGLMakeEGLInterface.cpp",
|
||||
"src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp",
|
||||
]
|
||||
|
||||
# this lib is required to link against AHardwareBuffer
|
||||
if (defined(ndk_api) && ndk_api >= 26) {
|
||||
libs += [ "android" ]
|
||||
}
|
||||
} else if (skia_use_egl) {
|
||||
sources += [ "src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp" ]
|
||||
sources += [
|
||||
"src/gpu/gl/egl/GrGLMakeEGLInterface.cpp",
|
||||
"src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp",
|
||||
]
|
||||
libs += [ "EGL" ]
|
||||
} else if (skia_use_webgl) {
|
||||
sources += [ "src/gpu/gl/webgl/GrGLMakeNativeInterface_webgl.cpp" ]
|
||||
} else if (is_linux && skia_use_x11) {
|
||||
sources += [ "src/gpu/gl/glx/GrGLMakeNativeInterface_glx.cpp" ]
|
||||
sources += [
|
||||
"src/gpu/gl/glx/GrGLMakeGLXInterface.cpp",
|
||||
"src/gpu/gl/glx/GrGLMakeNativeInterface_glx.cpp",
|
||||
]
|
||||
libs += [ "GL" ]
|
||||
} else if (is_mac) {
|
||||
sources += [ "src/gpu/gl/mac/GrGLMakeNativeInterface_mac.cpp" ]
|
||||
|
@ -904,8 +904,12 @@ skia_metal_sources = [
|
||||
]
|
||||
|
||||
skia_native_gpu_sources = [
|
||||
"$_include/gpu/gl/egl/GrGLMakeEGLInterface.h",
|
||||
"$_include/gpu/gl/glx/GrGLMakeGLXInterface.h",
|
||||
"$_src/gpu/gl/android/GrGLMakeNativeInterface_android.cpp",
|
||||
"$_src/gpu/gl/egl/GrGLMakeEGLInterface.cpp",
|
||||
"$_src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp",
|
||||
"$_src/gpu/gl/glx/GrGLMakeGLXInterface.cpp",
|
||||
"$_src/gpu/gl/glx/GrGLMakeNativeInterface_glx.cpp",
|
||||
"$_src/gpu/gl/iOS/GrGLMakeNativeInterface_iOS.cpp",
|
||||
"$_src/gpu/gl/mac/GrGLMakeNativeInterface_mac.cpp",
|
||||
|
14
include/gpu/gl/egl/GrGLMakeEGLInterface.h
Normal file
14
include/gpu/gl/egl/GrGLMakeEGLInterface.h
Normal file
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "include/gpu/GrTypes.h"
|
||||
|
||||
#include "include/core/SkRefCnt.h"
|
||||
|
||||
struct GrGLInterface;
|
||||
|
||||
sk_sp<const GrGLInterface> GrGLMakeEGLInterface();
|
14
include/gpu/gl/glx/GrGLMakeGLXInterface.h
Normal file
14
include/gpu/gl/glx/GrGLMakeGLXInterface.h
Normal file
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "include/gpu/GrTypes.h"
|
||||
|
||||
#include "include/core/SkRefCnt.h"
|
||||
|
||||
struct GrGLInterface;
|
||||
|
||||
sk_sp<const GrGLInterface> GrGLMakeGLXInterface();
|
@ -380,7 +380,7 @@ GL_SRCS_WASM = struct(
|
||||
include = [
|
||||
"src/gpu/gl/*",
|
||||
"src/gpu/gl/builders/*",
|
||||
"src/gpu/gl/GrGLMakeNativeInterface_egl.cpp",
|
||||
"src/gpu/gl/egl/GrGLMakeEGLInterface.cpp",
|
||||
"src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp",
|
||||
],
|
||||
exclude = [
|
||||
|
@ -4,4 +4,5 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "../egl/GrGLMakeEGLInterface.cpp"
|
||||
#include "../egl/GrGLMakeNativeInterface_egl.cpp"
|
||||
|
135
src/gpu/gl/egl/GrGLMakeEGLInterface.cpp
Normal file
135
src/gpu/gl/egl/GrGLMakeEGLInterface.cpp
Normal file
@ -0,0 +1,135 @@
|
||||
/*
|
||||
* 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 "include/gpu/gl/GrGLAssembleInterface.h"
|
||||
#include "include/gpu/gl/GrGLInterface.h"
|
||||
#include "src/gpu/gl/GrGLUtil.h"
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#ifndef GL_GLEXT_PROTOTYPES
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#endif
|
||||
#include <GLES2/gl2.h>
|
||||
|
||||
static GrGLFuncPtr egl_get_gl_proc(void* ctx, const char name[]) {
|
||||
SkASSERT(nullptr == ctx);
|
||||
// https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_get_all_proc_addresses.txt
|
||||
// eglGetProcAddress() is not guaranteed to support the querying of non-extension EGL functions.
|
||||
#define M(X) if (0 == strcmp(#X, name)) { return (GrGLFuncPtr) X; }
|
||||
M(eglGetCurrentDisplay)
|
||||
M(eglQueryString)
|
||||
M(glActiveTexture)
|
||||
M(glAttachShader)
|
||||
M(glBindAttribLocation)
|
||||
M(glBindBuffer)
|
||||
M(glBindFramebuffer)
|
||||
M(glBindRenderbuffer)
|
||||
M(glBindTexture)
|
||||
M(glBlendColor)
|
||||
M(glBlendEquation)
|
||||
M(glBlendFunc)
|
||||
M(glBufferData)
|
||||
M(glBufferSubData)
|
||||
M(glCheckFramebufferStatus)
|
||||
M(glClear)
|
||||
M(glClearColor)
|
||||
M(glClearStencil)
|
||||
M(glColorMask)
|
||||
M(glCompileShader)
|
||||
M(glCompressedTexImage2D)
|
||||
M(glCompressedTexSubImage2D)
|
||||
M(glCopyTexSubImage2D)
|
||||
M(glCreateProgram)
|
||||
M(glCreateShader)
|
||||
M(glCullFace)
|
||||
M(glDeleteBuffers)
|
||||
M(glDeleteFramebuffers)
|
||||
M(glDeleteProgram)
|
||||
M(glDeleteRenderbuffers)
|
||||
M(glDeleteShader)
|
||||
M(glDeleteTextures)
|
||||
M(glDepthMask)
|
||||
M(glDisable)
|
||||
M(glDisableVertexAttribArray)
|
||||
M(glDrawArrays)
|
||||
M(glDrawElements)
|
||||
M(glEnable)
|
||||
M(glEnableVertexAttribArray)
|
||||
M(glFinish)
|
||||
M(glFlush)
|
||||
M(glFramebufferRenderbuffer)
|
||||
M(glFramebufferTexture2D)
|
||||
M(glFrontFace)
|
||||
M(glGenBuffers)
|
||||
M(glGenFramebuffers)
|
||||
M(glGenRenderbuffers)
|
||||
M(glGenTextures)
|
||||
M(glGenerateMipmap)
|
||||
M(glGetBufferParameteriv)
|
||||
M(glGetError)
|
||||
M(glGetFramebufferAttachmentParameteriv)
|
||||
M(glGetIntegerv)
|
||||
M(glGetProgramInfoLog)
|
||||
M(glGetProgramiv)
|
||||
M(glGetRenderbufferParameteriv)
|
||||
M(glGetShaderInfoLog)
|
||||
M(glGetShaderPrecisionFormat)
|
||||
M(glGetShaderiv)
|
||||
M(glGetString)
|
||||
M(glGetUniformLocation)
|
||||
M(glIsTexture)
|
||||
M(glLineWidth)
|
||||
M(glLinkProgram)
|
||||
M(glPixelStorei)
|
||||
M(glReadPixels)
|
||||
M(glRenderbufferStorage)
|
||||
M(glScissor)
|
||||
M(glShaderSource)
|
||||
M(glStencilFunc)
|
||||
M(glStencilFuncSeparate)
|
||||
M(glStencilMask)
|
||||
M(glStencilMaskSeparate)
|
||||
M(glStencilOp)
|
||||
M(glStencilOpSeparate)
|
||||
M(glTexImage2D)
|
||||
M(glTexParameterf)
|
||||
M(glTexParameterfv)
|
||||
M(glTexParameteri)
|
||||
M(glTexParameteriv)
|
||||
M(glTexSubImage2D)
|
||||
M(glUniform1f)
|
||||
M(glUniform1fv)
|
||||
M(glUniform1i)
|
||||
M(glUniform1iv)
|
||||
M(glUniform2f)
|
||||
M(glUniform2fv)
|
||||
M(glUniform2i)
|
||||
M(glUniform2iv)
|
||||
M(glUniform3f)
|
||||
M(glUniform3fv)
|
||||
M(glUniform3i)
|
||||
M(glUniform3iv)
|
||||
M(glUniform4f)
|
||||
M(glUniform4fv)
|
||||
M(glUniform4i)
|
||||
M(glUniform4iv)
|
||||
M(glUniformMatrix2fv)
|
||||
M(glUniformMatrix3fv)
|
||||
M(glUniformMatrix4fv)
|
||||
M(glUseProgram)
|
||||
M(glVertexAttrib1f)
|
||||
M(glVertexAttrib2fv)
|
||||
M(glVertexAttrib3fv)
|
||||
M(glVertexAttrib4fv)
|
||||
M(glVertexAttribPointer)
|
||||
M(glViewport)
|
||||
#undef M
|
||||
return eglGetProcAddress(name);
|
||||
}
|
||||
|
||||
sk_sp<const GrGLInterface> GrGLMakeEGLInterface() {
|
||||
return GrGLMakeAssembledInterface(nullptr, egl_get_gl_proc);
|
||||
}
|
@ -1,137 +1,13 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "include/gpu/gl/GrGLAssembleInterface.h"
|
||||
|
||||
#include "include/gpu/gl/GrGLInterface.h"
|
||||
#include "src/gpu/gl/GrGLUtil.h"
|
||||
#include "include/gpu/gl/egl/GrGLMakeEGLInterface.h"
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#ifndef GL_GLEXT_PROTOTYPES
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#endif
|
||||
#include <GLES2/gl2.h>
|
||||
|
||||
static GrGLFuncPtr egl_get_gl_proc(void* ctx, const char name[]) {
|
||||
SkASSERT(nullptr == ctx);
|
||||
// https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_get_all_proc_addresses.txt
|
||||
// eglGetProcAddress() is not guaranteed to support the querying of non-extension EGL functions.
|
||||
#define M(X) if (0 == strcmp(#X, name)) { return (GrGLFuncPtr) X; }
|
||||
M(eglGetCurrentDisplay)
|
||||
M(eglQueryString)
|
||||
M(glActiveTexture)
|
||||
M(glAttachShader)
|
||||
M(glBindAttribLocation)
|
||||
M(glBindBuffer)
|
||||
M(glBindFramebuffer)
|
||||
M(glBindRenderbuffer)
|
||||
M(glBindTexture)
|
||||
M(glBlendColor)
|
||||
M(glBlendEquation)
|
||||
M(glBlendFunc)
|
||||
M(glBufferData)
|
||||
M(glBufferSubData)
|
||||
M(glCheckFramebufferStatus)
|
||||
M(glClear)
|
||||
M(glClearColor)
|
||||
M(glClearStencil)
|
||||
M(glColorMask)
|
||||
M(glCompileShader)
|
||||
M(glCompressedTexImage2D)
|
||||
M(glCompressedTexSubImage2D)
|
||||
M(glCopyTexSubImage2D)
|
||||
M(glCreateProgram)
|
||||
M(glCreateShader)
|
||||
M(glCullFace)
|
||||
M(glDeleteBuffers)
|
||||
M(glDeleteFramebuffers)
|
||||
M(glDeleteProgram)
|
||||
M(glDeleteRenderbuffers)
|
||||
M(glDeleteShader)
|
||||
M(glDeleteTextures)
|
||||
M(glDepthMask)
|
||||
M(glDisable)
|
||||
M(glDisableVertexAttribArray)
|
||||
M(glDrawArrays)
|
||||
M(glDrawElements)
|
||||
M(glEnable)
|
||||
M(glEnableVertexAttribArray)
|
||||
M(glFinish)
|
||||
M(glFlush)
|
||||
M(glFramebufferRenderbuffer)
|
||||
M(glFramebufferTexture2D)
|
||||
M(glFrontFace)
|
||||
M(glGenBuffers)
|
||||
M(glGenFramebuffers)
|
||||
M(glGenRenderbuffers)
|
||||
M(glGenTextures)
|
||||
M(glGenerateMipmap)
|
||||
M(glGetBufferParameteriv)
|
||||
M(glGetError)
|
||||
M(glGetFramebufferAttachmentParameteriv)
|
||||
M(glGetIntegerv)
|
||||
M(glGetProgramInfoLog)
|
||||
M(glGetProgramiv)
|
||||
M(glGetRenderbufferParameteriv)
|
||||
M(glGetShaderInfoLog)
|
||||
M(glGetShaderPrecisionFormat)
|
||||
M(glGetShaderiv)
|
||||
M(glGetString)
|
||||
M(glGetUniformLocation)
|
||||
M(glIsTexture)
|
||||
M(glLineWidth)
|
||||
M(glLinkProgram)
|
||||
M(glPixelStorei)
|
||||
M(glReadPixels)
|
||||
M(glRenderbufferStorage)
|
||||
M(glScissor)
|
||||
M(glShaderSource)
|
||||
M(glStencilFunc)
|
||||
M(glStencilFuncSeparate)
|
||||
M(glStencilMask)
|
||||
M(glStencilMaskSeparate)
|
||||
M(glStencilOp)
|
||||
M(glStencilOpSeparate)
|
||||
M(glTexImage2D)
|
||||
M(glTexParameterf)
|
||||
M(glTexParameterfv)
|
||||
M(glTexParameteri)
|
||||
M(glTexParameteriv)
|
||||
M(glTexSubImage2D)
|
||||
M(glUniform1f)
|
||||
M(glUniform1fv)
|
||||
M(glUniform1i)
|
||||
M(glUniform1iv)
|
||||
M(glUniform2f)
|
||||
M(glUniform2fv)
|
||||
M(glUniform2i)
|
||||
M(glUniform2iv)
|
||||
M(glUniform3f)
|
||||
M(glUniform3fv)
|
||||
M(glUniform3i)
|
||||
M(glUniform3iv)
|
||||
M(glUniform4f)
|
||||
M(glUniform4fv)
|
||||
M(glUniform4i)
|
||||
M(glUniform4iv)
|
||||
M(glUniformMatrix2fv)
|
||||
M(glUniformMatrix3fv)
|
||||
M(glUniformMatrix4fv)
|
||||
M(glUseProgram)
|
||||
M(glVertexAttrib1f)
|
||||
M(glVertexAttrib2fv)
|
||||
M(glVertexAttrib3fv)
|
||||
M(glVertexAttrib4fv)
|
||||
M(glVertexAttribPointer)
|
||||
M(glViewport)
|
||||
#undef M
|
||||
return eglGetProcAddress(name);
|
||||
}
|
||||
|
||||
sk_sp<const GrGLInterface> GrGLMakeNativeInterface() {
|
||||
return GrGLMakeAssembledInterface(nullptr, egl_get_gl_proc);
|
||||
}
|
||||
sk_sp<const GrGLInterface> GrGLMakeNativeInterface() { return GrGLMakeEGLInterface(); }
|
||||
|
||||
const GrGLInterface* GrGLCreateNativeInterface() { return GrGLMakeNativeInterface().release(); }
|
||||
|
34
src/gpu/gl/glx/GrGLMakeGLXInterface.cpp
Normal file
34
src/gpu/gl/glx/GrGLMakeGLXInterface.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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 "include/gpu/gl/GrGLAssembleInterface.h"
|
||||
#include "include/gpu/gl/GrGLInterface.h"
|
||||
#include "src/gpu/gl/GrGLUtil.h"
|
||||
|
||||
// Define this to get a prototype for glXGetProcAddress on some systems
|
||||
#define GLX_GLXEXT_PROTOTYPES 1
|
||||
#include <GL/glx.h>
|
||||
|
||||
static GrGLFuncPtr glx_get(void* ctx, const char name[]) {
|
||||
// Avoid calling glXGetProcAddress() for EGL procs.
|
||||
// We don't expect it to ever succeed, but somtimes it returns non-null anyway.
|
||||
if (0 == strncmp(name, "egl", 3)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SkASSERT(nullptr == ctx);
|
||||
SkASSERT(glXGetCurrentContext());
|
||||
return glXGetProcAddress(reinterpret_cast<const GLubyte*>(name));
|
||||
}
|
||||
|
||||
sk_sp<const GrGLInterface> GrGLMakeGLXInterface() {
|
||||
if (nullptr == glXGetCurrentContext()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return GrGLMakeAssembledInterface(nullptr, glx_get);
|
||||
}
|
@ -1,37 +1,13 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
#include "include/gpu/gl/GrGLAssembleInterface.h"
|
||||
#include "include/gpu/gl/GrGLInterface.h"
|
||||
#include "src/gpu/gl/GrGLUtil.h"
|
||||
#include "include/gpu/gl/glx/GrGLMakeGLXInterface.h"
|
||||
|
||||
// Define this to get a prototype for glXGetProcAddress on some systems
|
||||
#define GLX_GLXEXT_PROTOTYPES 1
|
||||
#include <GL/glx.h>
|
||||
|
||||
static GrGLFuncPtr glx_get(void* ctx, const char name[]) {
|
||||
// Avoid calling glXGetProcAddress() for EGL procs.
|
||||
// We don't expect it to ever succeed, but somtimes it returns non-null anyway.
|
||||
if (0 == strncmp(name, "egl", 3)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SkASSERT(nullptr == ctx);
|
||||
SkASSERT(glXGetCurrentContext());
|
||||
return glXGetProcAddress(reinterpret_cast<const GLubyte*>(name));
|
||||
}
|
||||
|
||||
sk_sp<const GrGLInterface> GrGLMakeNativeInterface() {
|
||||
if (nullptr == glXGetCurrentContext()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return GrGLMakeAssembledInterface(nullptr, glx_get);
|
||||
}
|
||||
sk_sp<const GrGLInterface> GrGLMakeNativeInterface() { return GrGLMakeGLXInterface(); }
|
||||
|
||||
const GrGLInterface* GrGLCreateNativeInterface() { return GrGLMakeNativeInterface().release(); }
|
||||
|
Loading…
Reference in New Issue
Block a user