| Index: src/gpu/gl/iOS/SkNativeGLContext_iOS.mm
|
| diff --git a/src/gpu/gl/iOS/SkNativeGLContext_iOS.mm b/src/gpu/gl/iOS/SkNativeGLContext_iOS.mm
|
| index 1bdaf70f1c37c60fb47caecda58ece76a8acbb04..1cc51e8a18f570a4575d84df9072f7bda6ebf351 100644
|
| --- a/src/gpu/gl/iOS/SkNativeGLContext_iOS.mm
|
| +++ b/src/gpu/gl/iOS/SkNativeGLContext_iOS.mm
|
| @@ -11,14 +11,32 @@
|
|
|
| #define EAGLCTX ((EAGLContext*)(fEAGLContext))
|
|
|
| -SkNativeGLContext::AutoContextRestore::AutoContextRestore() {
|
| +namespace {
|
| +
|
| +class SkNativeGLContextIOS : public SkNativeGLContext {
|
| +public:
|
| + SkNativeGLContextIOS();
|
| +
|
| + virtual ~SkNativeGLContextIOS();
|
| +
|
| + virtual void makeCurrent() const SK_OVERRIDE;
|
| + virtual void swapBuffers() const SK_OVERRIDE;
|
| +protected:
|
| + virtual const GrGLInterface* createGLContext(GrGLStandard forcedGpuAPI) SK_OVERRIDE;
|
| + virtual void destroyGLContext() SK_OVERRIDE;
|
| +
|
| +private:
|
| + void* fEAGLContext;
|
| +};
|
| +
|
| +SkNativeGLContextIOS::AutoContextRestore::AutoContextRestore() {
|
| fEAGLContext = [EAGLContext currentContext];
|
| if (EAGLCTX) {
|
| [EAGLCTX retain];
|
| }
|
| }
|
|
|
| -SkNativeGLContext::AutoContextRestore::~AutoContextRestore() {
|
| +SkNativeGLContextIOS::AutoContextRestore::~AutoContextRestore() {
|
| if (EAGLCTX) {
|
| [EAGLContext setCurrentContext:EAGLCTX];
|
| [EAGLCTX release];
|
| @@ -27,15 +45,15 @@ SkNativeGLContext::AutoContextRestore::~AutoContextRestore() {
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|
| -SkNativeGLContext::SkNativeGLContext()
|
| +SkNativeGLContextIOS::SkNativeGLContextIOS()
|
| : fEAGLContext(NULL) {
|
| }
|
|
|
| -SkNativeGLContext::~SkNativeGLContext() {
|
| +SkNativeGLContextIOS::~SkNativeGLContextIOS() {
|
| this->destroyGLContext();
|
| }
|
|
|
| -void SkNativeGLContext::destroyGLContext() {
|
| +void SkNativeGLContextIOS::destroyGLContext() {
|
| if (fEAGLContext) {
|
| if ([EAGLContext currentContext] == EAGLCTX) {
|
| [EAGLContext setCurrentContext:nil];
|
| @@ -45,7 +63,7 @@ void SkNativeGLContext::destroyGLContext() {
|
| }
|
| }
|
|
|
| -const GrGLInterface* SkNativeGLContext::createGLContext(GrGLStandard forcedGpuAPI) {
|
| +const GrGLInterface* SkNativeGLContextIOS::createGLContext(GrGLStandard forcedGpuAPI) {
|
| if (kGL_GrGLStandard == forcedGpuAPI) {
|
| return NULL;
|
| }
|
| @@ -62,10 +80,18 @@ const GrGLInterface* SkNativeGLContext::createGLContext(GrGLStandard forcedGpuAP
|
| return interface;
|
| }
|
|
|
| -void SkNativeGLContext::makeCurrent() const {
|
| +void SkNativeGLContextIOS::makeCurrent() const {
|
| if (![EAGLContext setCurrentContext:EAGLCTX]) {
|
| SkDebugf("Could not set the context.\n");
|
| }
|
| }
|
|
|
| -void SkNativeGLContext::swapBuffers() const { }
|
| +void SkNativeGLContextIOS::swapBuffers() const { }
|
| +
|
| +} // anonymous namespace
|
| +
|
| +
|
| +SkNativeGLContext* SkCreateGLContext() {
|
| + return SkNEW(SkNativeGLContextIOS);
|
| +}
|
| +
|
|
|