Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1227)

Unified Diff: src/gpu/gl/iOS/SkCreatePlatformGLContext_iOS.mm

Issue 640283004: Refactor SkGLContext to be actually extendable (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: win compile fix. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/glx/SkCreatePlatformGLContext_glx.cpp ('k') | src/gpu/gl/mac/SkCreatePlatformGLContext_mac.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « src/gpu/gl/glx/SkCreatePlatformGLContext_glx.cpp ('k') | src/gpu/gl/mac/SkCreatePlatformGLContext_mac.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698