| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 #include "gl/SkNativeGLContext.h" | 8 #include "gl/SkNativeGLContext.h" |
| 9 #include "AvailabilityMacros.h" |
| 9 | 10 |
| 10 SkNativeGLContext::AutoContextRestore::AutoContextRestore() { | 11 SkNativeGLContext::AutoContextRestore::AutoContextRestore() { |
| 11 fOldCGLContext = CGLGetCurrentContext(); | 12 fOldCGLContext = CGLGetCurrentContext(); |
| 12 } | 13 } |
| 13 | 14 |
| 14 SkNativeGLContext::AutoContextRestore::~AutoContextRestore() { | 15 SkNativeGLContext::AutoContextRestore::~AutoContextRestore() { |
| 15 CGLSetCurrentContext(fOldCGLContext); | 16 CGLSetCurrentContext(fOldCGLContext); |
| 16 } | 17 } |
| 17 | 18 |
| 18 /////////////////////////////////////////////////////////////////////////////// | 19 /////////////////////////////////////////////////////////////////////////////// |
| 19 | 20 |
| 20 SkNativeGLContext::SkNativeGLContext() | 21 SkNativeGLContext::SkNativeGLContext() |
| 21 : fContext(NULL) { | 22 : fContext(NULL) { |
| 22 } | 23 } |
| 23 | 24 |
| 24 SkNativeGLContext::~SkNativeGLContext() { | 25 SkNativeGLContext::~SkNativeGLContext() { |
| 25 this->destroyGLContext(); | 26 this->destroyGLContext(); |
| 26 } | 27 } |
| 27 | 28 |
| 28 void SkNativeGLContext::destroyGLContext() { | 29 void SkNativeGLContext::destroyGLContext() { |
| 29 if (NULL != fContext) { | 30 if (NULL != fContext) { |
| 30 CGLReleaseContext(fContext); | 31 CGLReleaseContext(fContext); |
| 31 } | 32 } |
| 32 } | 33 } |
| 33 | 34 |
| 34 const GrGLInterface* SkNativeGLContext::createGLContext() { | 35 const GrGLInterface* SkNativeGLContext::createGLContext() { |
| 35 SkASSERT(NULL == fContext); | 36 SkASSERT(NULL == fContext); |
| 36 | 37 |
| 37 CGLPixelFormatAttribute attributes[] = { | 38 CGLPixelFormatAttribute attributes[] = { |
| 38 #if 0 | 39 #if MAC_OS_X_VERSION_10_7 |
| 39 kCGLPFAOpenGLProfile, (CGLPixelFormatAttribute) kCGLOGLPVersion_3_2_Core
, | 40 kCGLPFAOpenGLProfile, (CGLPixelFormatAttribute) kCGLOGLPVersion_3_2_Core
, |
| 40 #endif | 41 #endif |
| 41 (CGLPixelFormatAttribute)0 | 42 (CGLPixelFormatAttribute)0 |
| 42 }; | 43 }; |
| 43 CGLPixelFormatObj pixFormat; | 44 CGLPixelFormatObj pixFormat; |
| 44 GLint npix; | 45 GLint npix; |
| 45 | 46 |
| 46 CGLChoosePixelFormat(attributes, &pixFormat, &npix); | 47 CGLChoosePixelFormat(attributes, &pixFormat, &npix); |
| 47 | 48 |
| 48 if (NULL == pixFormat) { | 49 if (NULL == pixFormat) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 66 this->destroyGLContext(); | 67 this->destroyGLContext(); |
| 67 return NULL; | 68 return NULL; |
| 68 } | 69 } |
| 69 | 70 |
| 70 return interface; | 71 return interface; |
| 71 } | 72 } |
| 72 | 73 |
| 73 void SkNativeGLContext::makeCurrent() const { | 74 void SkNativeGLContext::makeCurrent() const { |
| 74 CGLSetCurrentContext(fContext); | 75 CGLSetCurrentContext(fContext); |
| 75 } | 76 } |
| OLD | NEW |