Index: src/gpu/gl/mac/SkCreatePlatformGLContext_mac.cpp |
diff --git a/src/gpu/gl/mac/SkCreatePlatformGLContext_mac.cpp b/src/gpu/gl/mac/SkCreatePlatformGLContext_mac.cpp |
index 436c53f0bb2fea88e9a9ead8bbc97acd7185cd5f..d2d8569938665b8689d112a503707a0e391c8b72 100644 |
--- a/src/gpu/gl/mac/SkCreatePlatformGLContext_mac.cpp |
+++ b/src/gpu/gl/mac/SkCreatePlatformGLContext_mac.cpp |
@@ -9,23 +9,28 @@ |
#include "AvailabilityMacros.h" |
#include <OpenGL/OpenGL.h> |
+#include <dlfcn.h> |
namespace { |
class MacGLContext : public SkGLContext { |
public: |
MacGLContext(); |
~MacGLContext() override; |
- void makeCurrent() const override; |
- void swapBuffers() const override; |
private: |
void destroyGLContext(); |
+ void onPlatformMakeCurrent() const override; |
+ void onPlatformSwapBuffers() const override; |
+ GrGLFuncPtr onPlatformGetProcAddress(const char*) const override; |
+ |
CGLContextObj fContext; |
+ void* fGLLibrary; |
}; |
MacGLContext::MacGLContext() |
- : fContext(NULL) { |
+ : fContext(NULL) |
+ , fGLLibrary(RTLD_DEFAULT) { |
CGLPixelFormatAttribute attributes[] = { |
#if MAC_OS_X_VERSION_10_7 |
kCGLPFAOpenGLProfile, (CGLPixelFormatAttribute) kCGLOGLPVersion_3_2_Core, |
@@ -53,39 +58,52 @@ MacGLContext::MacGLContext() |
CGLSetCurrentContext(fContext); |
- fGL.reset(GrGLCreateNativeInterface()); |
- if (NULL == fGL.get()) { |
+ SkAutoTUnref<const GrGLInterface> gl(GrGLCreateNativeInterface()); |
+ if (NULL == gl.get()) { |
SkDebugf("Context could not create GL interface.\n"); |
this->destroyGLContext(); |
return; |
} |
- if (!fGL->validate()) { |
+ if (!gl->validate()) { |
SkDebugf("Context could not validate GL interface.\n"); |
this->destroyGLContext(); |
return; |
} |
+ |
+ fGLLibrary = dlopen( |
+ "/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib", |
+ RTLD_LAZY); |
+ |
+ this->init(gl.detach()); |
} |
MacGLContext::~MacGLContext() { |
+ this->teardown(); |
this->destroyGLContext(); |
} |
void MacGLContext::destroyGLContext() { |
- fGL.reset(NULL); |
if (fContext) { |
CGLReleaseContext(fContext); |
fContext = NULL; |
} |
+ if (RTLD_DEFAULT != fGLLibrary) { |
+ dlclose(fGLLibrary); |
+ } |
} |
-void MacGLContext::makeCurrent() const { |
+void MacGLContext::onPlatformMakeCurrent() const { |
CGLSetCurrentContext(fContext); |
} |
-void MacGLContext::swapBuffers() const { |
+void MacGLContext::onPlatformSwapBuffers() const { |
CGLFlushDrawable(fContext); |
} |
+GrGLFuncPtr MacGLContext::onPlatformGetProcAddress(const char* procName) const { |
+ return reinterpret_cast<GrGLFuncPtr>(dlsym(fGLLibrary, procName)); |
+} |
+ |
} // anonymous namespace |
SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI) { |