diff options
author | Brian Salomon <bsalomon@google.com> | 2017-12-11 10:06:31 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-12-11 17:54:38 +0000 |
commit | 3d6801eeee6b036de9f8d09e2ae8fa99df5a397c (patch) | |
tree | cbdcd23fe4924fbe25afae209d01bb6527244abf /src/gpu/gl/iOS/GrGLMakeNativeInterface_iOS.cpp | |
parent | d67e5189802e89e74217244b36cc7263883d5dba (diff) |
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>
Diffstat (limited to 'src/gpu/gl/iOS/GrGLMakeNativeInterface_iOS.cpp')
-rw-r--r-- | src/gpu/gl/iOS/GrGLMakeNativeInterface_iOS.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/gpu/gl/iOS/GrGLMakeNativeInterface_iOS.cpp b/src/gpu/gl/iOS/GrGLMakeNativeInterface_iOS.cpp new file mode 100644 index 0000000000..a0a6ac6615 --- /dev/null +++ b/src/gpu/gl/iOS/GrGLMakeNativeInterface_iOS.cpp @@ -0,0 +1,57 @@ +/* + * 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 "gl/GrGLInterface.h" +#include "gl/GrGLAssembleInterface.h" +#include <dlfcn.h> + +class GLLoader { +public: + GLLoader() { + fLibrary = dlopen( + "/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib", + RTLD_LAZY); + } + + ~GLLoader() { + if (fLibrary) { + dlclose(fLibrary); + } + } + + void* handle() const { + return nullptr == fLibrary ? RTLD_DEFAULT : fLibrary; + } + +private: + void* fLibrary; +}; + +class GLProcGetter { +public: + GLProcGetter() {} + + GrGLFuncPtr getProc(const char name[]) const { + return (GrGLFuncPtr) dlsym(fLoader.handle(), name); + } + +private: + GLLoader fLoader; +}; + +static GrGLFuncPtr ios_get_gl_proc(void* ctx, const char name[]) { + SkASSERT(ctx); + const GLProcGetter* getter = (const GLProcGetter*) ctx; + return getter->getProc(name); +} + +sk_sp<const GrGLInterface> GrGLMakeNativeInterface() { + GLProcGetter getter; + return GrGLAssembleGLESInterface(&getter, ios_get_gl_proc); +} + +const GrGLInterface* GrGLCreateNativeInterface() { return GrGLMakeNativeInterface().release(); } |