| 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 #include "AvailabilityMacros.h" |
| 10 | 10 |
| 11 SkNativeGLContext::AutoContextRestore::AutoContextRestore() { | 11 SkNativeGLContext::AutoContextRestore::AutoContextRestore() { |
| 12 fOldCGLContext = CGLGetCurrentContext(); | 12 fOldCGLContext = CGLGetCurrentContext(); |
| 13 } | 13 } |
| 14 | 14 |
| 15 SkNativeGLContext::AutoContextRestore::~AutoContextRestore() { | 15 SkNativeGLContext::AutoContextRestore::~AutoContextRestore() { |
| 16 CGLSetCurrentContext(fOldCGLContext); | 16 CGLSetCurrentContext(fOldCGLContext); |
| 17 } | 17 } |
| 18 | 18 |
| 19 /////////////////////////////////////////////////////////////////////////////// | 19 /////////////////////////////////////////////////////////////////////////////// |
| 20 | 20 |
| 21 SkNativeGLContext::SkNativeGLContext() | 21 SkNativeGLContext::SkNativeGLContext() |
| 22 : fContext(NULL) { | 22 : fContext(NULL) { |
| 23 } | 23 } |
| 24 | 24 |
| 25 SkNativeGLContext::~SkNativeGLContext() { | 25 SkNativeGLContext::~SkNativeGLContext() { |
| 26 this->destroyGLContext(); | 26 this->destroyGLContext(); |
| 27 } | 27 } |
| 28 | 28 |
| 29 void SkNativeGLContext::destroyGLContext() { | 29 void SkNativeGLContext::destroyGLContext() { |
| 30 if (NULL != fContext) { | 30 if (fContext) { |
| 31 CGLReleaseContext(fContext); | 31 CGLReleaseContext(fContext); |
| 32 } | 32 } |
| 33 } | 33 } |
| 34 | 34 |
| 35 const GrGLInterface* SkNativeGLContext::createGLContext(GrGLStandard forcedGpuAP
I) { | 35 const GrGLInterface* SkNativeGLContext::createGLContext(GrGLStandard forcedGpuAP
I) { |
| 36 SkASSERT(NULL == fContext); | 36 SkASSERT(NULL == fContext); |
| 37 if (kGLES_GrGLStandard == forcedGpuAPI) { | 37 if (kGLES_GrGLStandard == forcedGpuAPI) { |
| 38 return NULL; | 38 return NULL; |
| 39 } | 39 } |
| 40 | 40 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 return interface; | 75 return interface; |
| 76 } | 76 } |
| 77 | 77 |
| 78 void SkNativeGLContext::makeCurrent() const { | 78 void SkNativeGLContext::makeCurrent() const { |
| 79 CGLSetCurrentContext(fContext); | 79 CGLSetCurrentContext(fContext); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void SkNativeGLContext::swapBuffers() const { | 82 void SkNativeGLContext::swapBuffers() const { |
| 83 CGLFlushDrawable(fContext); | 83 CGLFlushDrawable(fContext); |
| 84 } | 84 } |
| OLD | NEW |