From c1b9c1005f1e07558c0d32cf8f80d022b312719e Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Fri, 6 Apr 2018 09:18:00 -0400 Subject: [PATCH] Add versions of MakeGL() that don't require include GrGLInterface.h in order to use the GrGLMakeNativeInterface Change-Id: I77bd3c683c284aecc50a3552bbf1fb901f1bcc44 Reviewed-on: https://skia-review.googlesource.com/119002 Reviewed-by: Robert Phillips Commit-Queue: Brian Salomon --- include/gpu/GrContext.h | 6 +++++- include/gpu/gl/GrGLInterface.h | 14 +++++++------- src/gpu/GrDirectContext.cpp | 9 +++++++++ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h index 0ebfd7c979..21fd2e6376 100644 --- a/include/gpu/GrContext.h +++ b/include/gpu/GrContext.h @@ -55,10 +55,14 @@ class SkTraceMemoryDump; class SK_API GrContext : public SkRefCnt { public: /** - * Creates a GrContext for a backend context. + * Creates a GrContext for a backend context. If no GrGLInterface is provided then the result of + * GrGLMakeNativeInterface() is used if it succeeds. */ static sk_sp MakeGL(sk_sp, const GrContextOptions&); static sk_sp MakeGL(sk_sp); + static sk_sp MakeGL(const GrContextOptions&); + static sk_sp MakeGL(); + // Deprecated static sk_sp MakeGL(const GrGLInterface*); static sk_sp MakeGL(const GrGLInterface*, const GrContextOptions&); diff --git a/include/gpu/gl/GrGLInterface.h b/include/gpu/gl/GrGLInterface.h index 64d0cfbfbe..bf2685eb1c 100644 --- a/include/gpu/gl/GrGLInterface.h +++ b/include/gpu/gl/GrGLInterface.h @@ -21,14 +21,14 @@ 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 "native" GL interface is created. If the native is - * also NULL GrContext creation will fail. + * specified per-GrContext as a parameter to GrContext::MakeGL. If no interface is + * passed to MakeGL then a default GL interface is created using GrGLMakeNativeInterface(). + * If this returns nullptr then GrContext::MakeGL() will fail. * - * 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. + * The implementation of GrGLMakeNativeInterface is platform-specific. Several + * implementations have been provided (for GLX, WGL, EGL, etc), along with an + * implementation that simply returns nullptr. Clients should select the most + * appropriate one to build. */ SK_API sk_sp GrGLMakeNativeInterface(); // Deprecated alternative to GrGLMakeNativeInterface(). diff --git a/src/gpu/GrDirectContext.cpp b/src/gpu/GrDirectContext.cpp index 204d676686..9407a7d08e 100644 --- a/src/gpu/GrDirectContext.cpp +++ b/src/gpu/GrDirectContext.cpp @@ -100,6 +100,15 @@ sk_sp GrContext::MakeGL(sk_sp interface) { return MakeGL(std::move(interface), defaultOptions); } +sk_sp GrContext::MakeGL(const GrContextOptions& options) { + return MakeGL(nullptr, options); +} + +sk_sp GrContext::MakeGL() { + GrContextOptions defaultOptions; + return MakeGL(nullptr, defaultOptions); +} + sk_sp GrContext::MakeGL(const GrGLInterface* interface) { return MakeGL(sk_ref_sp(interface)); }