Add GrGLMakeNativeInterface factory that returns sk_sp<const GrGLInterface>.
Removes the concept of a configurable "default" interface and makes the default always be the "native" interface. Also removes unused functions: GrGLInterfaceAddTestDebugMarker and GrGLInterface::NewClone. Keeps around legacy GrGLCreateNativeInterface() until clients can be weened. Change-Id: I4a3bdafa8cf8c68ed13318393abd55686b045ccb Reviewed-on: https://skia-review.googlesource.com/83000 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
d67e518980
commit
3d6801eeee
23
BUILD.gn
23
BUILD.gn
@ -546,42 +546,37 @@ optional("gpu") {
|
||||
]
|
||||
public_defines = []
|
||||
|
||||
sources = skia_gpu_sources + skia_sksl_sources +
|
||||
[ "src/gpu/gl/GrGLDefaultInterface_native.cpp" ] +
|
||||
skia_gpu_processor_outputs
|
||||
sources = skia_gpu_sources + skia_sksl_sources + skia_gpu_processor_outputs
|
||||
|
||||
# These paths need to be absolute to match the ones produced by shared_sources.gni.
|
||||
sources -= get_path_info([
|
||||
"src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
|
||||
"src/gpu/gl/GrGLDefaultInterface_none.cpp",
|
||||
],
|
||||
sources -= get_path_info([ "src/gpu/gl/GrGLMakeNativeInterface_none.cpp" ],
|
||||
"abspath")
|
||||
libs = []
|
||||
if (is_android) {
|
||||
sources += [ "src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp" ]
|
||||
sources += [ "src/gpu/gl/android/GrGLMakeNativeInterface_android.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/GrGLCreateNativeInterface_egl.cpp" ]
|
||||
sources += [ "src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp" ]
|
||||
libs += [ "EGL" ]
|
||||
} else if (is_linux) {
|
||||
sources += [ "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp" ]
|
||||
sources += [ "src/gpu/gl/glx/GrGLMakeNativeInterface_glx.cpp" ]
|
||||
libs += [
|
||||
"GL",
|
||||
"GLU",
|
||||
]
|
||||
} else if (is_mac) {
|
||||
sources += [ "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp" ]
|
||||
sources += [ "src/gpu/gl/mac/GrGLMakeNativeInterface_mac.cpp" ]
|
||||
} else if (is_ios) {
|
||||
sources += [ "src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp" ]
|
||||
sources += [ "src/gpu/gl/iOS/GrGLMakeNativeInterface_iOS.cpp" ]
|
||||
} else if (is_win) {
|
||||
sources += [ "src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp" ]
|
||||
sources += [ "src/gpu/gl/win/GrGLMakeNativeInterface_win.cpp" ]
|
||||
libs += [ "OpenGL32.lib" ]
|
||||
} else {
|
||||
sources += [ "src/gpu/gl/GrGLCreateNativeInterface_none.cpp" ]
|
||||
sources += [ "src/gpu/gl/GrGLMakeNativeInterface_none.cpp" ]
|
||||
}
|
||||
|
||||
if (skia_use_vulkan) {
|
||||
|
@ -27,7 +27,7 @@ void SkGLWidget::setSampleCount(int sampleCount) {
|
||||
|
||||
void SkGLWidget::initializeGL() {
|
||||
if (!fCurIntf) {
|
||||
fCurIntf.reset(GrGLCreateNativeInterface());
|
||||
fCurIntf = GrGLMakeNativeInterface();
|
||||
}
|
||||
if (!fCurIntf) {
|
||||
return;
|
||||
|
@ -189,7 +189,7 @@ int main(int argc, char** argv) {
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
// setup GrContext
|
||||
sk_sp<const GrGLInterface> interface(GrGLCreateNativeInterface());
|
||||
auto interface = GrGLMakeNativeInterface();
|
||||
|
||||
// setup contexts
|
||||
sk_sp<GrContext> grContext(GrContext::MakeGL(interface));
|
||||
|
16
gn/gpu.gni
16
gn/gpu.gni
@ -407,9 +407,8 @@ skia_gpu_sources = [
|
||||
"$_src/gpu/gl/GrGLCaps.h",
|
||||
"$_src/gpu/gl/GrGLContext.cpp",
|
||||
"$_src/gpu/gl/GrGLContext.h",
|
||||
"$_src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
|
||||
"$_src/gpu/gl/GrGLMakeNativeInterface_none.cpp",
|
||||
"$_src/gpu/gl/GrGLCreateNullInterface.cpp",
|
||||
"$_src/gpu/gl/GrGLDefaultInterface_none.cpp",
|
||||
"$_src/gpu/gl/GrGLDefines.h",
|
||||
"$_src/gpu/gl/GrGLGLSL.cpp",
|
||||
"$_src/gpu/gl/GrGLGLSL.h",
|
||||
@ -611,13 +610,12 @@ skia_metal_sources = [
|
||||
]
|
||||
|
||||
skia_native_gpu_sources = [
|
||||
"$_src/gpu/gl/GrGLDefaultInterface_native.cpp",
|
||||
"$_src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp",
|
||||
"$_src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp",
|
||||
"$_src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp",
|
||||
"$_src/gpu/gl/egl/GrGLCreateNativeInterface_egl.cpp",
|
||||
"$_src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp",
|
||||
"$_src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp",
|
||||
"$_src/gpu/gl/mac/GrGLMakeNativeInterface_mac.cpp",
|
||||
"$_src/gpu/gl/win/GrGLMakeNativeInterface_win.cpp",
|
||||
"$_src/gpu/gl/glx/GrGLMakeNativeInterface_glx.cpp",
|
||||
"$_src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp",
|
||||
"$_src/gpu/gl/iOS/GrGLMakeNativeInterface_iOS.cpp",
|
||||
"$_src/gpu/gl/android/GrGLMakeNativeInterface_android.cpp",
|
||||
]
|
||||
|
||||
skia_atlas_text_sources = [
|
||||
|
@ -197,7 +197,7 @@ enum GrBackend {
|
||||
|
||||
/**
|
||||
* Backend-specific 3D context handle
|
||||
* OpenGL: const GrGLInterface*. If null will use the result of GrGLCreateNativeInterface().
|
||||
* OpenGL: const GrGLInterface*. If null will use the result of GrGLMakeNativeInterface().
|
||||
* Vulkan: GrVkBackendContext*.
|
||||
* Mock: const GrMockOptions* or null for default constructed GrMockContextOptions.
|
||||
*/
|
||||
|
@ -9,22 +9,21 @@
|
||||
|
||||
typedef GrGLFuncPtr (*GrGLGetProc)(void* ctx, const char name[]);
|
||||
|
||||
|
||||
/**
|
||||
* Generic function for creating a GrGLInterface for an either OpenGL or GLES. It calls
|
||||
* get() to get each function address. ctx is a generic ptr passed to and interpreted by get().
|
||||
*/
|
||||
SK_API const GrGLInterface* GrGLAssembleInterface(void* ctx, GrGLGetProc get);
|
||||
SK_API sk_sp<const GrGLInterface> GrGLAssembleInterface(void* ctx, GrGLGetProc get);
|
||||
|
||||
/**
|
||||
* Generic function for creating a GrGLInterface for an OpenGL (but not GLES) context. It calls
|
||||
* get() to get each function address. ctx is a generic ptr passed to and interpreted by get().
|
||||
*/
|
||||
SK_API const GrGLInterface* GrGLAssembleGLInterface(void* ctx, GrGLGetProc get);
|
||||
SK_API sk_sp<const GrGLInterface> GrGLAssembleGLInterface(void* ctx, GrGLGetProc get);
|
||||
|
||||
/**
|
||||
* Generic function for creating a GrGLInterface for an OpenGL ES (but not Open GL) context. It
|
||||
* calls get() to get each function address. ctx is a generic ptr passed to and interpreted by
|
||||
* get().
|
||||
*/
|
||||
SK_API const GrGLInterface* GrGLAssembleGLESInterface(void* ctx, GrGLGetProc get);
|
||||
SK_API sk_sp<const GrGLInterface> GrGLAssembleGLESInterface(void* ctx, GrGLGetProc get);
|
||||
|
@ -14,40 +14,26 @@
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef void(*GrGLFuncPtr)();
|
||||
struct GrGLInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Rather than depend on platform-specific GL headers and libraries, we require
|
||||
* the client to provide a struct of GL function pointers. This struct can be
|
||||
* specified per-GrContext as a parameter to GrContext::MakeGL. If NULL is
|
||||
* passed to MakeGL then a "default" GL interface is created. If the default is
|
||||
* passed to MakeGL then a "native" GL interface is created. If the native is
|
||||
* also NULL GrContext creation will fail.
|
||||
*
|
||||
* The default interface is returned by GrGLDefaultInterface. This function's
|
||||
* implementation is platform-specific. Several have been provided, along with
|
||||
* an implementation that simply returns NULL.
|
||||
*
|
||||
* By defining GR_GL_PER_GL_CALL_IFACE_CALLBACK to 1 the client can specify a
|
||||
* callback function that will be called prior to each GL function call. See
|
||||
* comments in GrGLConfig.h
|
||||
*/
|
||||
|
||||
typedef void(*GrGLFuncPtr)();
|
||||
|
||||
struct GrGLInterface;
|
||||
|
||||
const GrGLInterface* GrGLDefaultInterface();
|
||||
|
||||
/**
|
||||
* Creates a GrGLInterface for a "native" GL context (e.g. WGL on windows,
|
||||
* GLX on linux, AGL on Mac). The interface is only valid for the GL context
|
||||
* that is current when the interface is created.
|
||||
* The default interface is returned by GrGLMakeNativeInterface. This function's
|
||||
* implementation is platform-specific. Several have been provided
|
||||
* (for GLX, WGL, EGL, etc), along with an implementation that simply returns
|
||||
* NULL.
|
||||
*/
|
||||
SK_API sk_sp<const GrGLInterface> GrGLMakeNativeInterface();
|
||||
// Deprecated alternative to GrGLMakeNativeInterface().
|
||||
SK_API const GrGLInterface* GrGLCreateNativeInterface();
|
||||
|
||||
#if GR_GL_PER_GL_FUNC_CALLBACK
|
||||
typedef void (*GrGLInterfaceCallbackProc)(const GrGLInterface*);
|
||||
typedef intptr_t GrGLInterfaceCallbackData;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Creates a null GrGLInterface that doesn't draw anything. Used for measuring
|
||||
* CPU overhead. TODO: We would like to move this to tools/gpu/gl/null but currently
|
||||
@ -55,13 +41,6 @@ typedef intptr_t GrGLInterfaceCallbackData;
|
||||
*/
|
||||
const SK_API GrGLInterface* GrGLCreateNullInterface(bool enableNVPR = false);
|
||||
|
||||
/** Function that returns a new interface identical to "interface" but with support for
|
||||
test version of GL_EXT_debug_marker. */
|
||||
const GrGLInterface* GrGLInterfaceAddTestDebugMarker(const GrGLInterface*,
|
||||
GrGLInsertEventMarkerProc insertEventMarkerFn,
|
||||
GrGLPushGroupMarkerProc pushGroupMarkerFn,
|
||||
GrGLPopGroupMarkerProc popGroupMarkerFn);
|
||||
|
||||
/**
|
||||
* GrContext uses the following interface to make all calls into OpenGL. When a
|
||||
* GrContext is created it is given a GrGLInterface. The interface's function
|
||||
@ -80,8 +59,6 @@ private:
|
||||
public:
|
||||
GrGLInterface();
|
||||
|
||||
static GrGLInterface* NewClone(const GrGLInterface*);
|
||||
|
||||
// Validates that the GrGLInterface supports its advertised standard. This means the necessary
|
||||
// function pointers have been initialized for both the GL version and any advertised
|
||||
// extensions.
|
||||
|
@ -233,9 +233,7 @@ BASE_SRCS_ALL = struct(
|
||||
# Exclude multiple definitions.
|
||||
# TODO(mtklein): Move to opts?
|
||||
"src/pdf/SkDocument_PDF_None.cpp", # We use src/pdf/SkPDFDocument.cpp.
|
||||
"src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
|
||||
"src/gpu/gl/GrGLDefaultInterface_native.cpp",
|
||||
"src/gpu/gl/GrGLDefaultInterface_none.cpp",
|
||||
"src/gpu/gl/GrGLMakeNativeInterface_none.cpp",
|
||||
|
||||
# Exclude files that don't compile with the current DEFINES.
|
||||
"src/svg/**/*", # Depends on XML.
|
||||
@ -276,7 +274,6 @@ def codec_srcs(limited):
|
||||
# Platform-dependent SRCS for google3-default platform.
|
||||
BASE_SRCS_UNIX = struct(
|
||||
include = [
|
||||
"src/gpu/gl/GrGLDefaultInterface_none.cpp",
|
||||
"src/ports/**/*.cpp",
|
||||
"src/ports/**/*.h",
|
||||
],
|
||||
@ -304,7 +301,6 @@ BASE_SRCS_UNIX = struct(
|
||||
# Platform-dependent SRCS for google3-default Android.
|
||||
BASE_SRCS_ANDROID = struct(
|
||||
include = [
|
||||
"src/gpu/gl/GrGLDefaultInterface_none.cpp",
|
||||
# TODO(benjaminwagner): Figure out how to compile with EGL.
|
||||
"src/ports/**/*.cpp",
|
||||
"src/ports/**/*.h",
|
||||
@ -333,8 +329,7 @@ BASE_SRCS_ANDROID = struct(
|
||||
# Platform-dependent SRCS for google3-default iOS.
|
||||
BASE_SRCS_IOS = struct(
|
||||
include = [
|
||||
"src/gpu/gl/GrGLDefaultInterface_native.cpp",
|
||||
"src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp",
|
||||
"src/gpu/gl/iOS/GrGLMakeNativeInterface_iOS.cpp",
|
||||
"src/ports/**/*.cpp",
|
||||
"src/ports/**/*.h",
|
||||
"src/utils/mac/*.cpp",
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#define GET_EGL_PROC_SUFFIX(F, S) functions->fEGL ## F = (GrEGL ## F ## Proc) get(ctx, "egl" #F #S)
|
||||
|
||||
const GrGLInterface* GrGLAssembleInterface(void* ctx, GrGLGetProc get) {
|
||||
sk_sp<const GrGLInterface> GrGLAssembleInterface(void* ctx, GrGLGetProc get) {
|
||||
GET_PROC_LOCAL(GetString);
|
||||
if (nullptr == GetString) {
|
||||
return nullptr;
|
||||
@ -51,7 +51,7 @@ static void get_egl_query_and_display(GrEGLQueryStringProc* queryString, GrEGLDi
|
||||
}
|
||||
}
|
||||
|
||||
const GrGLInterface* GrGLAssembleGLInterface(void* ctx, GrGLGetProc get) {
|
||||
sk_sp<const GrGLInterface> GrGLAssembleGLInterface(void* ctx, GrGLGetProc get) {
|
||||
GET_PROC_LOCAL(GetString);
|
||||
GET_PROC_LOCAL(GetStringi);
|
||||
GET_PROC_LOCAL(GetIntegerv);
|
||||
@ -78,7 +78,7 @@ const GrGLInterface* GrGLAssembleGLInterface(void* ctx, GrGLGetProc get) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GrGLInterface* interface = new GrGLInterface();
|
||||
sk_sp<GrGLInterface> interface(new GrGLInterface());
|
||||
GrGLInterface::Functions* functions = &interface->fFunctions;
|
||||
|
||||
GET_PROC(ActiveTexture);
|
||||
@ -315,7 +315,6 @@ const GrGLInterface* GrGLAssembleGLInterface(void* ctx, GrGLGetProc get) {
|
||||
}
|
||||
} else {
|
||||
// we must have FBOs
|
||||
delete interface;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -547,7 +546,7 @@ const GrGLInterface* GrGLAssembleGLInterface(void* ctx, GrGLGetProc get) {
|
||||
return interface;
|
||||
}
|
||||
|
||||
const GrGLInterface* GrGLAssembleGLESInterface(void* ctx, GrGLGetProc get) {
|
||||
sk_sp<const GrGLInterface> GrGLAssembleGLESInterface(void* ctx, GrGLGetProc get) {
|
||||
GET_PROC_LOCAL(GetString);
|
||||
if (nullptr == GetString) {
|
||||
return nullptr;
|
||||
@ -571,7 +570,7 @@ const GrGLInterface* GrGLAssembleGLESInterface(void* ctx, GrGLGetProc get) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GrGLInterface* interface = new GrGLInterface;
|
||||
sk_sp<GrGLInterface> interface(new GrGLInterface);
|
||||
GrGLInterface::Functions* functions = &interface->fFunctions;
|
||||
|
||||
GET_PROC(ActiveTexture);
|
||||
|
@ -1,12 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011 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"
|
||||
|
||||
const GrGLInterface* GrGLDefaultInterface() {
|
||||
return GrGLCreateNativeInterface();
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011 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"
|
||||
|
||||
const GrGLInterface* GrGLDefaultInterface() {
|
||||
return nullptr;
|
||||
}
|
@ -184,7 +184,12 @@ sk_sp<GrGpu> GrGLGpu::Make(GrBackendContext backendContext, const GrContextOptio
|
||||
sk_sp<GrGpu> GrGLGpu::Make(sk_sp<const GrGLInterface> interface, const GrContextOptions& options,
|
||||
GrContext* context) {
|
||||
if (!interface) {
|
||||
interface.reset(GrGLDefaultInterface());
|
||||
interface = GrGLMakeNativeInterface();
|
||||
// For clients that have written their own GrGLCreateNativeInterface and haven't yet updated
|
||||
// to GrGLMakeNativeInterface.
|
||||
if (!interface) {
|
||||
interface = sk_ref_sp(GrGLCreateNativeInterface());
|
||||
}
|
||||
if (!interface) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -12,37 +12,10 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
const GrGLInterface* GrGLInterfaceAddTestDebugMarker(const GrGLInterface* interface,
|
||||
GrGLInsertEventMarkerProc insertEventMarkerFn,
|
||||
GrGLPushGroupMarkerProc pushGroupMarkerFn,
|
||||
GrGLPopGroupMarkerProc popGroupMarkerFn) {
|
||||
GrGLInterface* newInterface = GrGLInterface::NewClone(interface);
|
||||
|
||||
if (!newInterface->fExtensions.has("GL_EXT_debug_marker")) {
|
||||
newInterface->fExtensions.add("GL_EXT_debug_marker");
|
||||
}
|
||||
|
||||
newInterface->fFunctions.fInsertEventMarker = insertEventMarkerFn;
|
||||
newInterface->fFunctions.fPushGroupMarker = pushGroupMarkerFn;
|
||||
newInterface->fFunctions.fPopGroupMarker = popGroupMarkerFn;
|
||||
|
||||
return newInterface;
|
||||
}
|
||||
|
||||
GrGLInterface::GrGLInterface() {
|
||||
fStandard = kNone_GrGLStandard;
|
||||
}
|
||||
|
||||
GrGLInterface* GrGLInterface::NewClone(const GrGLInterface* interface) {
|
||||
SkASSERT(interface);
|
||||
|
||||
GrGLInterface* clone = new GrGLInterface;
|
||||
clone->fStandard = interface->fStandard;
|
||||
clone->fExtensions = interface->fExtensions;
|
||||
clone->fFunctions = interface->fFunctions;
|
||||
return clone;
|
||||
}
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
static int kIsDebug = 1;
|
||||
#else
|
||||
|
@ -7,6 +7,6 @@
|
||||
|
||||
#include "gl/GrGLInterface.h"
|
||||
|
||||
const GrGLInterface* GrGLCreateNativeInterface() {
|
||||
return nullptr;
|
||||
}
|
||||
sk_sp<const GrGLInterface> GrGLMakeNativeInterface() { return nullptr; }
|
||||
|
||||
const GrGLInterface* GrGLCreateNativeInterface() { return nullptr; }
|
@ -232,8 +232,10 @@ static GrGLFuncPtr android_get_gl_proc(void* ctx, const char name[]) {
|
||||
return eglGetProcAddress(name);
|
||||
}
|
||||
|
||||
const GrGLInterface* GrGLCreateNativeInterface() {
|
||||
sk_sp<const GrGLInterface> GrGLMakeNativeInterface() {
|
||||
return GrGLAssembleInterface(nullptr, android_get_gl_proc);
|
||||
}
|
||||
|
||||
const GrGLInterface* GrGLCreateNativeInterface() { return GrGLMakeNativeInterface().release(); }
|
||||
|
||||
#endif//defined(SK_BUILD_FOR_ANDROID)
|
@ -24,6 +24,8 @@ static GrGLFuncPtr egl_get_gl_proc(void* ctx, const char name[]) {
|
||||
return ptr;
|
||||
}
|
||||
|
||||
const GrGLInterface* GrGLCreateNativeInterface() {
|
||||
sk_sp<const GrGLInterface> GrGLMakeNativeInterface() {
|
||||
return GrGLAssembleInterface(nullptr, egl_get_gl_proc);
|
||||
}
|
||||
|
||||
const GrGLInterface* GrGLCreateNativeInterface() { return GrGLMakeNativeInterface().release(); }
|
@ -18,10 +18,12 @@ static GrGLFuncPtr glfw_get(void* ctx, const char name[]) {
|
||||
return glfwGetProcAddress(name);
|
||||
}
|
||||
|
||||
const GrGLInterface* GrGLCreateNativeInterface() {
|
||||
sk_sp<const GrGLInterface> GrGLMakeNativeInterface() {
|
||||
if (nullptr == glfwGetCurrentContext()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return GrGLAssembleInterface(nullptr, glfw_get);
|
||||
}
|
||||
|
||||
const GrGLInterface* GrGLCreateNativeInterface() { return GrGLMakeNativeInterface().release(); }
|
@ -26,10 +26,12 @@ static GrGLFuncPtr glx_get(void* ctx, const char name[]) {
|
||||
return glXGetProcAddress(reinterpret_cast<const GLubyte*>(name));
|
||||
}
|
||||
|
||||
const GrGLInterface* GrGLCreateNativeInterface() {
|
||||
sk_sp<const GrGLInterface> GrGLMakeNativeInterface() {
|
||||
if (nullptr == glXGetCurrentContext()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return GrGLAssembleInterface(nullptr, glx_get);
|
||||
}
|
||||
|
||||
const GrGLInterface* GrGLCreateNativeInterface() { return GrGLMakeNativeInterface().release(); }
|
@ -49,7 +49,9 @@ static GrGLFuncPtr ios_get_gl_proc(void* ctx, const char name[]) {
|
||||
return getter->getProc(name);
|
||||
}
|
||||
|
||||
const GrGLInterface* GrGLCreateNativeInterface() {
|
||||
sk_sp<const GrGLInterface> GrGLMakeNativeInterface() {
|
||||
GLProcGetter getter;
|
||||
return GrGLAssembleGLESInterface(&getter, ios_get_gl_proc);
|
||||
}
|
||||
|
||||
const GrGLInterface* GrGLCreateNativeInterface() { return GrGLMakeNativeInterface().release(); }
|
@ -53,9 +53,11 @@ static GrGLFuncPtr mac_get_gl_proc(void* ctx, const char name[]) {
|
||||
return getter->getProc(name);
|
||||
}
|
||||
|
||||
const GrGLInterface* GrGLCreateNativeInterface() {
|
||||
sk_sp<const GrGLInterface> GrGLMakeNativeInterface() {
|
||||
GLProcGetter getter;
|
||||
return GrGLAssembleGLInterface(&getter, mac_get_gl_proc);
|
||||
}
|
||||
|
||||
const GrGLInterface* GrGLCreateNativeInterface() { return GrGLMakeNativeInterface().release(); }
|
||||
|
||||
#endif//defined(SK_BUILD_FOR_MAC)
|
@ -62,7 +62,7 @@ static GrGLFuncPtr win_get_gl_proc(void* ctx, const char name[]) {
|
||||
* This implementation will only work if GR_GL_FUNCTION_TYPE is __stdcall.
|
||||
* Otherwise, a springboard would be needed that hides the calling convention.
|
||||
*/
|
||||
const GrGLInterface* GrGLCreateNativeInterface() {
|
||||
sk_sp<const GrGLInterface> GrGLMakeNativeInterface() {
|
||||
if (nullptr == wglGetCurrentContext()) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -87,4 +87,6 @@ const GrGLInterface* GrGLCreateNativeInterface() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const GrGLInterface* GrGLCreateNativeInterface() { return GrGLMakeNativeInterface().release(); }
|
||||
|
||||
#endif//defined(SK_BUILD_FOR_WIN32)
|
@ -71,7 +71,7 @@ sk_sp<GrContext> create_grcontext(std::ostringstream &driverinfo) {
|
||||
driverinfo << "GL Renderer: " << getString(GL_RENDERER) << "\n";
|
||||
driverinfo << "GL Extensions: " << getString(GL_EXTENSIONS) << "\n";
|
||||
|
||||
auto interface = GrGLCreateNativeInterface();
|
||||
auto interface = GrGLMakeNativeInterface();
|
||||
if (!interface) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -284,9 +284,8 @@ GLTestContext::~GLTestContext() {
|
||||
SkASSERT(nullptr == fGL.get());
|
||||
}
|
||||
|
||||
void GLTestContext::init(const GrGLInterface* gl, std::unique_ptr<FenceSync> fenceSync) {
|
||||
SkASSERT(!fGL.get());
|
||||
fGL.reset(gl);
|
||||
void GLTestContext::init(sk_sp<const GrGLInterface> gl, std::unique_ptr<FenceSync> fenceSync) {
|
||||
fGL = std::move(gl);
|
||||
fFenceSync = fenceSync ? std::move(fenceSync) : GLFenceSync::MakeIfSupported(this);
|
||||
fGpuTimer = GLGpuTimer::MakeIfSupported(this);
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ protected:
|
||||
/*
|
||||
* Methods that sublcasses must call from their constructors and destructors.
|
||||
*/
|
||||
void init(const GrGLInterface *, std::unique_ptr<FenceSync> = nullptr);
|
||||
void init(sk_sp<const GrGLInterface>, std::unique_ptr<FenceSync> = nullptr);
|
||||
|
||||
void teardown() override;
|
||||
|
||||
|
@ -232,7 +232,7 @@ ANGLEGLContext::ANGLEGLContext(ANGLEBackend type, ANGLEContextVersion version,
|
||||
return;
|
||||
}
|
||||
|
||||
sk_sp<const GrGLInterface> gl(sk_gpu_test::CreateANGLEGLInterface());
|
||||
sk_sp<const GrGLInterface> gl = sk_gpu_test::CreateANGLEGLInterface();
|
||||
if (nullptr == gl.get()) {
|
||||
SkDebugf("Could not create ANGLE GL interface!\n");
|
||||
this->destroyGLContext();
|
||||
@ -262,7 +262,7 @@ ANGLEGLContext::ANGLEGLContext(ANGLEBackend type, ANGLEContextVersion version,
|
||||
}
|
||||
#endif
|
||||
|
||||
this->init(gl.release());
|
||||
this->init(std::move(gl));
|
||||
}
|
||||
|
||||
ANGLEGLContext::~ANGLEGLContext() {
|
||||
@ -389,7 +389,7 @@ GrGLFuncPtr ANGLEGLContext::onPlatformGetProcAddress(const char* name) const {
|
||||
} // anonymous namespace
|
||||
|
||||
namespace sk_gpu_test {
|
||||
const GrGLInterface* CreateANGLEGLInterface() {
|
||||
sk_sp<const GrGLInterface> CreateANGLEGLInterface() {
|
||||
static Libs gLibs = { nullptr, nullptr };
|
||||
|
||||
if (nullptr == gLibs.fGLLib) {
|
||||
|
@ -16,7 +16,7 @@ namespace sk_gpu_test {
|
||||
* Creates a GrGLInterface for the current ANGLE GLES Context. Here current means bound in ANGLE's
|
||||
* implementation of EGL.
|
||||
*/
|
||||
const GrGLInterface* CreateANGLEGLInterface();
|
||||
sk_sp<const GrGLInterface> CreateANGLEGLInterface();
|
||||
|
||||
enum class ANGLEBackend {
|
||||
kD3D9,
|
||||
|
@ -130,7 +130,7 @@ static void load_command_buffer_once() {
|
||||
once(load_command_buffer_functions);
|
||||
}
|
||||
|
||||
static const GrGLInterface* create_command_buffer_interface() {
|
||||
static sk_sp<const GrGLInterface> create_command_buffer_interface() {
|
||||
load_command_buffer_once();
|
||||
if (!gfFunctionsLoadedSuccessfully) {
|
||||
return nullptr;
|
||||
@ -289,8 +289,8 @@ CommandBufferGLTestContext::CommandBufferGLTestContext(CommandBufferGLTestContex
|
||||
return;
|
||||
}
|
||||
|
||||
sk_sp<const GrGLInterface> gl(create_command_buffer_interface());
|
||||
if (nullptr == gl.get()) {
|
||||
auto gl = create_command_buffer_interface();
|
||||
if (!gl) {
|
||||
SkDebugf("Command Buffer: Could not create CommandBuffer GL interface.\n");
|
||||
this->destroyGLContext();
|
||||
return;
|
||||
@ -301,7 +301,7 @@ CommandBufferGLTestContext::CommandBufferGLTestContext(CommandBufferGLTestContex
|
||||
return;
|
||||
}
|
||||
|
||||
this->init(gl.release());
|
||||
this->init(std::move(gl));
|
||||
}
|
||||
|
||||
CommandBufferGLTestContext::~CommandBufferGLTestContext() {
|
||||
|
@ -1195,11 +1195,9 @@ const char* DebugInterface::kExtensions[] = {
|
||||
|
||||
class DebugGLContext : public sk_gpu_test::GLTestContext {
|
||||
public:
|
||||
DebugGLContext() {
|
||||
this->init(new DebugInterface());
|
||||
}
|
||||
DebugGLContext() { this->init(sk_make_sp<DebugInterface>()); }
|
||||
|
||||
~DebugGLContext() override { this->teardown(); }
|
||||
~DebugGLContext() override { this->teardown(); }
|
||||
|
||||
private:
|
||||
void onPlatformMakeCurrent() const override {}
|
||||
|
@ -186,8 +186,8 @@ EGLGLTestContext::EGLGLTestContext(GrGLStandard forcedGpuAPI, EGLGLTestContext*
|
||||
continue;
|
||||
}
|
||||
|
||||
gl.reset(GrGLCreateNativeInterface());
|
||||
if (nullptr == gl.get()) {
|
||||
gl = GrGLMakeNativeInterface();
|
||||
if (!gl) {
|
||||
SkDebugf("Failed to create gl interface.\n");
|
||||
this->destroyGLContext();
|
||||
continue;
|
||||
@ -199,7 +199,7 @@ EGLGLTestContext::EGLGLTestContext(GrGLStandard forcedGpuAPI, EGLGLTestContext*
|
||||
continue;
|
||||
}
|
||||
|
||||
this->init(gl.release(), EGLFenceSync::MakeIfSupported(fDisplay));
|
||||
this->init(std::move(gl), EGLFenceSync::MakeIfSupported(fDisplay));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -239,8 +239,8 @@ GLXGLTestContext::GLXGLTestContext(GrGLStandard forcedGpuAPI, GLXGLTestContext*
|
||||
return;
|
||||
}
|
||||
|
||||
sk_sp<const GrGLInterface> gl(GrGLCreateNativeInterface());
|
||||
if (nullptr == gl.get()) {
|
||||
auto gl = GrGLMakeNativeInterface();
|
||||
if (!gl) {
|
||||
SkDebugf("Failed to create gl interface");
|
||||
this->destroyGLContext();
|
||||
return;
|
||||
@ -252,7 +252,7 @@ GLXGLTestContext::GLXGLTestContext(GrGLStandard forcedGpuAPI, GLXGLTestContext*
|
||||
return;
|
||||
}
|
||||
|
||||
this->init(gl.release());
|
||||
this->init(std::move(gl));
|
||||
}
|
||||
|
||||
|
||||
|
@ -66,7 +66,7 @@ IOSGLTestContext::IOSGLTestContext(IOSGLTestContext* shareContext)
|
||||
"/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib",
|
||||
RTLD_LAZY);
|
||||
|
||||
this->init(gl.release());
|
||||
this->init(std::move(gl));
|
||||
}
|
||||
|
||||
IOSGLTestContext::~IOSGLTestContext() {
|
||||
|
@ -68,8 +68,8 @@ MacGLTestContext::MacGLTestContext(MacGLTestContext* shareContext)
|
||||
SkScopeExit restorer(context_restorer());
|
||||
CGLSetCurrentContext(fContext);
|
||||
|
||||
sk_sp<const GrGLInterface> gl(GrGLCreateNativeInterface());
|
||||
if (nullptr == gl.get()) {
|
||||
auto gl = GrGLMakeNativeInterface();
|
||||
if (!gl) {
|
||||
SkDebugf("Context could not create GL interface.\n");
|
||||
this->destroyGLContext();
|
||||
return;
|
||||
@ -84,7 +84,7 @@ MacGLTestContext::MacGLTestContext(MacGLTestContext* shareContext)
|
||||
"/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib",
|
||||
RTLD_LAZY);
|
||||
|
||||
this->init(gl.release());
|
||||
this->init(std::move(gl));
|
||||
}
|
||||
|
||||
MacGLTestContext::~MacGLTestContext() {
|
||||
|
@ -17,8 +17,10 @@
|
||||
namespace {
|
||||
class NullGLContext : public sk_gpu_test::GLTestContext {
|
||||
public:
|
||||
NullGLContext(bool enableNVPR) { this->init(GrGLCreateNullInterface(enableNVPR)); }
|
||||
~NullGLContext() override { this->teardown(); }
|
||||
NullGLContext(bool enableNVPR) {
|
||||
this->init(sk_sp<const GrGLInterface>(GrGLCreateNullInterface(enableNVPR)));
|
||||
}
|
||||
~NullGLContext() override { this->teardown(); }
|
||||
|
||||
private:
|
||||
void onPlatformMakeCurrent() const override {}
|
||||
|
@ -127,8 +127,8 @@ WinGLTestContext::WinGLTestContext(GrGLStandard forcedGpuAPI, WinGLTestContext*
|
||||
return;
|
||||
}
|
||||
|
||||
sk_sp<const GrGLInterface> gl(GrGLCreateNativeInterface());
|
||||
if (nullptr == gl.get()) {
|
||||
auto gl = GrGLMakeNativeInterface();
|
||||
if (!gl) {
|
||||
SkDebugf("Could not create GL interface.\n");
|
||||
this->destroyGLContext();
|
||||
return;
|
||||
@ -139,7 +139,7 @@ WinGLTestContext::WinGLTestContext(GrGLStandard forcedGpuAPI, WinGLTestContext*
|
||||
return;
|
||||
}
|
||||
|
||||
this->init(gl.release());
|
||||
this->init(std::move(gl));
|
||||
}
|
||||
|
||||
WinGLTestContext::~WinGLTestContext() {
|
||||
|
@ -121,7 +121,7 @@ sk_sp<const GrGLInterface> GLWindowContext_android::onInitializeContext() {
|
||||
SkASSERT(EGL_NO_SURFACE != fSurfaceAndroid);
|
||||
|
||||
SkAssertResult(eglMakeCurrent(fDisplay, fSurfaceAndroid, fSurfaceAndroid, fEGLContext));
|
||||
// GLWindowContext::initializeContext will call GrGLCreateNativeInterface so we
|
||||
// GLWindowContext::initializeContext will call GrGLMakeNativeInterface so we
|
||||
// won't call it here.
|
||||
|
||||
glClearStencil(0);
|
||||
@ -132,7 +132,7 @@ sk_sp<const GrGLInterface> GLWindowContext_android::onInitializeContext() {
|
||||
eglGetConfigAttrib(fDisplay, surfaceConfig, EGL_STENCIL_SIZE, &fStencilBits);
|
||||
eglGetConfigAttrib(fDisplay, surfaceConfig, EGL_SAMPLES, &fSampleCount);
|
||||
|
||||
return sk_sp<const GrGLInterface>(GrGLCreateNativeInterface());
|
||||
return GrGLMakeNativeInterface();
|
||||
}
|
||||
|
||||
void GLWindowContext_android::onDestroyContext() {
|
||||
|
@ -73,7 +73,7 @@ sk_sp<const GrGLInterface> GLWindowContext_ios::onInitializeContext() {
|
||||
} else {
|
||||
SkDebugf("MakeCurrent failed: %s\n", SDL_GetError());
|
||||
}
|
||||
return sk_sp<const GrGLInterface>(GrGLCreateNativeInterface());
|
||||
return GrGLMakeNativeInterface();
|
||||
}
|
||||
|
||||
void GLWindowContext_ios::onDestroyContext() {
|
||||
|
@ -90,7 +90,7 @@ sk_sp<const GrGLInterface> RasterWindowContext_ios::onInitializeContext() {
|
||||
SkImageInfo info = SkImageInfo::Make(fWidth, fHeight, fDisplayParams.fColorType,
|
||||
kPremul_SkAlphaType, fDisplayParams.fColorSpace);
|
||||
fBackbufferSurface = SkSurface::MakeRaster(info);
|
||||
return sk_sp<const GrGLInterface>(GrGLCreateNativeInterface());
|
||||
return GrGLMakeNativeInterface();
|
||||
}
|
||||
|
||||
void RasterWindowContext_ios::onDestroyContext() {
|
||||
|
@ -73,7 +73,7 @@ sk_sp<const GrGLInterface> GLWindowContext_mac::onInitializeContext() {
|
||||
} else {
|
||||
SkDebugf("MakeCurrent failed: %s\n", SDL_GetError());
|
||||
}
|
||||
return sk_sp<const GrGLInterface>(GrGLCreateNativeInterface());
|
||||
return GrGLMakeNativeInterface();
|
||||
}
|
||||
|
||||
void GLWindowContext_mac::onDestroyContext() {
|
||||
|
@ -90,7 +90,7 @@ sk_sp<const GrGLInterface> RasterWindowContext_mac::onInitializeContext() {
|
||||
SkImageInfo info = SkImageInfo::Make(fWidth, fHeight, fDisplayParams.fColorType,
|
||||
kPremul_SkAlphaType, fDisplayParams.fColorSpace);
|
||||
fBackbufferSurface = SkSurface::MakeRaster(info);
|
||||
return sk_sp<const GrGLInterface>(GrGLCreateNativeInterface());
|
||||
return GrGLMakeNativeInterface();
|
||||
}
|
||||
|
||||
void RasterWindowContext_mac::onDestroyContext() {
|
||||
|
@ -107,7 +107,7 @@ sk_sp<const GrGLInterface> GLWindowContext_xlib::onInitializeContext() {
|
||||
&border_width, &depth);
|
||||
glViewport(0, 0, fWidth, fHeight);
|
||||
|
||||
return sk_sp<const GrGLInterface>(GrGLCreateNativeInterface());
|
||||
return GrGLMakeNativeInterface();
|
||||
}
|
||||
|
||||
GLWindowContext_xlib::~GLWindowContext_xlib() {
|
||||
|
@ -61,9 +61,9 @@ sk_sp<const GrGLInterface> GLWindowContext_win::onInitializeContext() {
|
||||
|
||||
// Look to see if RenderDoc is attached. If so, re-create the context with a core profile
|
||||
if (wglMakeCurrent(dc, fHGLRC)) {
|
||||
const GrGLInterface* glInterface = GrGLCreateNativeInterface();
|
||||
bool renderDocAttached = glInterface->hasExtension("GL_EXT_debug_tool");
|
||||
SkSafeUnref(glInterface);
|
||||
auto interface = GrGLMakeNativeInterface();
|
||||
bool renderDocAttached = interface->hasExtension("GL_EXT_debug_tool");
|
||||
interface.reset(nullptr);
|
||||
if (renderDocAttached) {
|
||||
wglDeleteContext(fHGLRC);
|
||||
fHGLRC = SkCreateWGLContext(dc, fDisplayParams.fMSAASampleCount, false /* deepColor */,
|
||||
@ -106,7 +106,7 @@ sk_sp<const GrGLInterface> GLWindowContext_win::onInitializeContext() {
|
||||
fHeight = rect.bottom - rect.top;
|
||||
glViewport(0, 0, fWidth, fHeight);
|
||||
}
|
||||
return sk_sp<const GrGLInterface>(GrGLCreateNativeInterface());
|
||||
return GrGLMakeNativeInterface();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user