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

Unified Diff: src/gpu/gl/angle/SkANGLEGLContext.cpp

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/SkNullGLContext.cpp ('k') | src/gpu/gl/debug/SkDebugGLContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/angle/SkANGLEGLContext.cpp
diff --git a/src/gpu/gl/angle/SkANGLEGLContext.cpp b/src/gpu/gl/angle/SkANGLEGLContext.cpp
index 4914ba55333d70df73ccac437b940ac0db7b6085..232c8664239c505a7bbbb42d7dd8c3563269e371 100644
--- a/src/gpu/gl/angle/SkANGLEGLContext.cpp
+++ b/src/gpu/gl/angle/SkANGLEGLContext.cpp
@@ -12,36 +12,6 @@ SkANGLEGLContext::SkANGLEGLContext()
: fContext(EGL_NO_CONTEXT)
, fDisplay(EGL_NO_DISPLAY)
, fSurface(EGL_NO_SURFACE) {
-}
-
-SkANGLEGLContext::~SkANGLEGLContext() {
- this->destroyGLContext();
-}
-
-void SkANGLEGLContext::destroyGLContext() {
- if (fDisplay) {
- eglMakeCurrent(fDisplay, 0, 0, 0);
-
- if (fContext) {
- eglDestroyContext(fDisplay, fContext);
- fContext = EGL_NO_CONTEXT;
- }
-
- if (fSurface) {
- eglDestroySurface(fDisplay, fSurface);
- fSurface = EGL_NO_SURFACE;
- }
-
- //TODO should we close the display?
- fDisplay = EGL_NO_DISPLAY;
- }
-}
-
-const GrGLInterface* SkANGLEGLContext::createGLContext(GrGLStandard forcedGpuAPI) {
- if (kGL_GrGLStandard == forcedGpuAPI) {
- return NULL;
- }
-
fDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
EGLint majorVersion;
@@ -78,14 +48,41 @@ const GrGLInterface* SkANGLEGLContext::createGLContext(GrGLStandard forcedGpuAPI
eglMakeCurrent(fDisplay, fSurface, fSurface, fContext);
- const GrGLInterface* interface = GrGLCreateANGLEInterface();
- if (NULL == interface) {
+ fGL.reset(GrGLCreateANGLEInterface());
+ if (NULL == fGL.get()) {
SkDebugf("Could not create ANGLE GL interface!\n");
this->destroyGLContext();
- return NULL;
+ return;
+ }
+ if (!fGL->validate()) {
+ SkDebugf("Could not validate ANGLE GL interface!\n");
+ this->destroyGLContext();
+ return;
}
+}
- return interface;
+SkANGLEGLContext::~SkANGLEGLContext() {
+ this->destroyGLContext();
+}
+
+void SkANGLEGLContext::destroyGLContext() {
+ fGL.reset(NULL);
+ if (fDisplay) {
+ eglMakeCurrent(fDisplay, 0, 0, 0);
+
+ if (fContext) {
+ eglDestroyContext(fDisplay, fContext);
+ fContext = EGL_NO_CONTEXT;
+ }
+
+ if (fSurface) {
+ eglDestroySurface(fDisplay, fSurface);
+ fSurface = EGL_NO_SURFACE;
+ }
+
+ //TODO should we close the display?
+ fDisplay = EGL_NO_DISPLAY;
+ }
}
void SkANGLEGLContext::makeCurrent() const {
« no previous file with comments | « src/gpu/gl/SkNullGLContext.cpp ('k') | src/gpu/gl/debug/SkDebugGLContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698