aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/angle
diff options
context:
space:
mode:
authorGravatar kkinnunen <kkinnunen@nvidia.com>2014-10-15 23:03:54 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-15 23:03:54 -0700
commit30bc88ccd524c0372fd2f8f79190ea4b81685beb (patch)
treebc506a76edaa98c6285f6e2496c83585d1ada1cc /src/gpu/gl/angle
parentde258cd6b402c4da78b66e88191ad02162d87916 (diff)
Refactor SkGLContext to be actually extendable
Refactor SkGLContext to be actually extendable. Before, non-trivial subclass would need to destroy the GL connection upon running the destructor. However, the base class would run GL commands in its own destructor (with destroyed GL connection) Refactor so that SkGLContext subclass object creation is completely done by the factory function. If the factory function returns a non-NULL ptr, it means the context is usable. The destruction is done with the destructor instead of virtual function called upon destruction. Make the destructors not to call virtual functions, for clarity. Remove custom 1x1 FBO setup code from the base class. It appears not to be used anymore. BUG=skia:2992 Review URL: https://codereview.chromium.org/640283004
Diffstat (limited to 'src/gpu/gl/angle')
-rw-r--r--src/gpu/gl/angle/SkANGLEGLContext.cpp65
1 files changed, 31 insertions, 34 deletions
diff --git a/src/gpu/gl/angle/SkANGLEGLContext.cpp b/src/gpu/gl/angle/SkANGLEGLContext.cpp
index 4914ba5533..232c866423 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 {