Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Unified Diff: src/gpu/gl/mac/SkCreatePlatformGLContext_mac.cpp

Issue 1194783003: Implement SkGLContext swapBuffers with fence syncs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: windows build Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/iOS/SkCreatePlatformGLContext_iOS.mm ('k') | src/gpu/gl/mesa/SkMesaGLContext.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « src/gpu/gl/iOS/SkCreatePlatformGLContext_iOS.mm ('k') | src/gpu/gl/mesa/SkMesaGLContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698