diff options
author | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-02-14 15:10:59 +0000 |
---|---|---|
committer | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-02-14 15:10:59 +0000 |
commit | 682e1f92455e398804f413d4c223d1d05c4ea2a1 (patch) | |
tree | 3fcb7fb60973355a3b8e03b20927f5b2c2e71a6f /src | |
parent | f4eeeabcdce5ff4475db26be8aa7e872242d833a (diff) |
Use CGL rather than AGL on the Mac.
Review URL: https://codereview.appspot.com/7307106
git-svn-id: http://skia.googlecode.com/svn/trunk@7736 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/gl/mac/SkNativeGLContext_mac.cpp | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/src/gpu/gl/mac/SkNativeGLContext_mac.cpp b/src/gpu/gl/mac/SkNativeGLContext_mac.cpp index f0cb2b6dd0..bcdc7ab9f2 100644 --- a/src/gpu/gl/mac/SkNativeGLContext_mac.cpp +++ b/src/gpu/gl/mac/SkNativeGLContext_mac.cpp @@ -8,11 +8,11 @@ #include "gl/SkNativeGLContext.h" SkNativeGLContext::AutoContextRestore::AutoContextRestore() { - fOldAGLContext = aglGetCurrentContext(); + fOldCGLContext = CGLGetCurrentContext(); } SkNativeGLContext::AutoContextRestore::~AutoContextRestore() { - aglSetCurrentContext(fOldAGLContext); + CGLSetCurrentContext(fOldCGLContext); } /////////////////////////////////////////////////////////////////////////////// @@ -26,38 +26,39 @@ SkNativeGLContext::~SkNativeGLContext() { } void SkNativeGLContext::destroyGLContext() { - if (fContext) { - aglDestroyContext(fContext); + if (NULL != fContext) { + CGLReleaseContext(fContext); } } const GrGLInterface* SkNativeGLContext::createGLContext() { - GLint major, minor; - // AGLContext ctx; - - aglGetVersion(&major, &minor); - //SkDebugf("---- agl version %d %d\n", major, minor); - - const GLint pixelAttrs[] = { - AGL_RGBA, - AGL_ACCELERATED, - AGL_NONE + SkASSERT(NULL == fContext); + + CGLPixelFormatAttribute attributes[] = { +#if 0 + kCGLPFAOpenGLProfile, kCGLOGLPVersion_3_2_Core, +#endif + (CGLPixelFormatAttribute)0 }; - AGLPixelFormat format = aglChoosePixelFormat(NULL, 0, pixelAttrs); - if (NULL == format) { - SkDebugf("Format could not be found.\n"); - this->destroyGLContext(); + CGLPixelFormatObj pixFormat; + GLint npix; + + CGLChoosePixelFormat(attributes, &pixFormat, &npix); + + if (NULL == pixFormat) { + SkDebugf("CGLChoosePixelFormat failed."); return NULL; } - fContext = aglCreateContext(format, NULL); + + CGLCreateContext(pixFormat, NULL, &fContext); + CGLReleasePixelFormat(pixFormat); + if (NULL == fContext) { - SkDebugf("Context could not be created.\n"); - this->destroyGLContext(); + SkDebugf("CGLCreateContext failed."); return NULL; } - aglDestroyPixelFormat(format); - - aglSetCurrentContext(fContext); + + CGLSetCurrentContext(fContext); const GrGLInterface* interface = GrGLCreateNativeInterface(); if (NULL == interface) { @@ -70,5 +71,5 @@ const GrGLInterface* SkNativeGLContext::createGLContext() { } void SkNativeGLContext::makeCurrent() const { - aglSetCurrentContext(fContext); + CGLSetCurrentContext(fContext); } |