| Index: src/gpu/gl/iOS/SkCreatePlatformGLContext_iOS.mm | 
| diff --git a/src/gpu/gl/iOS/SkCreatePlatformGLContext_iOS.mm b/src/gpu/gl/iOS/SkCreatePlatformGLContext_iOS.mm | 
| index 9989957ac9ea684fdebb2539dc2c9f99df6c9edf..423ef8cbddfc0efaa9532a72544c9d8d9f1182f3 100644 | 
| --- a/src/gpu/gl/iOS/SkCreatePlatformGLContext_iOS.mm | 
| +++ b/src/gpu/gl/iOS/SkCreatePlatformGLContext_iOS.mm | 
| @@ -16,21 +16,33 @@ namespace { | 
| class IOSGLContext : public SkGLContext { | 
| public: | 
| IOSGLContext(); | 
| - | 
| -    virtual ~IOSGLContext(); | 
| - | 
| +    virtual ~IOSGLContext() SK_OVERRIDE; | 
| 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 destroyGLContext(); | 
| + | 
| void* fEAGLContext; | 
| }; | 
|  | 
| IOSGLContext::IOSGLContext() | 
| : fEAGLContext(NULL) { | 
| + | 
| +    fEAGLContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; | 
| +    [EAGLContext setCurrentContext:EAGLCTX]; | 
| + | 
| +    fGL.reset(GrGLCreateNativeInterface()); | 
| +    if (NULL == fGL.get()) { | 
| +        SkDebugf("Failed to create gl interface"); | 
| +        this->destroyGLContext(); | 
| +        return; | 
| +    } | 
| +    if (!fGL->validate()) { | 
| +        SkDebugf("Failed to validate gl interface"); | 
| +        this->destroyGLContext(); | 
| +        return; | 
| +    } | 
| } | 
|  | 
| IOSGLContext::~IOSGLContext() { | 
| @@ -38,6 +50,7 @@ IOSGLContext::~IOSGLContext() { | 
| } | 
|  | 
| void IOSGLContext::destroyGLContext() { | 
| +    fGL.reset(NULL); | 
| if (fEAGLContext) { | 
| if ([EAGLContext currentContext] == EAGLCTX) { | 
| [EAGLContext setCurrentContext:nil]; | 
| @@ -47,22 +60,6 @@ void IOSGLContext::destroyGLContext() { | 
| } | 
| } | 
|  | 
| -const GrGLInterface* IOSGLContext::createGLContext(GrGLStandard forcedGpuAPI) { | 
| -    if (kGL_GrGLStandard == forcedGpuAPI) { | 
| -        return NULL; | 
| -    } | 
| - | 
| -    fEAGLContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; | 
| -    [EAGLContext setCurrentContext:EAGLCTX]; | 
| - | 
| -    const GrGLInterface* interface = GrGLCreateNativeInterface(); | 
| -    if (!interface) { | 
| -        SkDebugf("Failed to create gl interface"); | 
| -        this->destroyGLContext(); | 
| -        return NULL; | 
| -    } | 
| -    return interface; | 
| -} | 
|  | 
| void IOSGLContext::makeCurrent() const { | 
| if (![EAGLContext setCurrentContext:EAGLCTX]) { | 
| @@ -74,8 +71,15 @@ void IOSGLContext::swapBuffers() const { } | 
|  | 
| } // anonymous namespace | 
|  | 
| - | 
| -SkGLContext* SkCreatePlatformGLContext() { | 
| -    return SkNEW(IOSGLContext); | 
| +SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI) { | 
| +    if (kGL_GrGLStandard == forcedGpuAPI) { | 
| +        return NULL; | 
| +    } | 
| +    IOSGLContext* ctx = SkNEW(IOSGLContext); | 
| +    if (!ctx->isValid()) { | 
| +        SkDELETE(ctx); | 
| +        return NULL; | 
| +    } | 
| +    return ctx; | 
| } | 
|  | 
|  |