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 <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Brian Salomon 2018-04-06 09:18:00 -04:00 committed by Skia Commit-Bot
parent 9ca3065ca5
commit c1b9c1005f
3 changed files with 21 additions and 8 deletions

View File

@ -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<GrContext> MakeGL(sk_sp<const GrGLInterface>, const GrContextOptions&);
static sk_sp<GrContext> MakeGL(sk_sp<const GrGLInterface>);
static sk_sp<GrContext> MakeGL(const GrContextOptions&);
static sk_sp<GrContext> MakeGL();
// Deprecated
static sk_sp<GrContext> MakeGL(const GrGLInterface*);
static sk_sp<GrContext> MakeGL(const GrGLInterface*, const GrContextOptions&);

View File

@ -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<const GrGLInterface> GrGLMakeNativeInterface();
// Deprecated alternative to GrGLMakeNativeInterface().

View File

@ -100,6 +100,15 @@ sk_sp<GrContext> GrContext::MakeGL(sk_sp<const GrGLInterface> interface) {
return MakeGL(std::move(interface), defaultOptions);
}
sk_sp<GrContext> GrContext::MakeGL(const GrContextOptions& options) {
return MakeGL(nullptr, options);
}
sk_sp<GrContext> GrContext::MakeGL() {
GrContextOptions defaultOptions;
return MakeGL(nullptr, defaultOptions);
}
sk_sp<GrContext> GrContext::MakeGL(const GrGLInterface* interface) {
return MakeGL(sk_ref_sp(interface));
}