diff options
Diffstat (limited to 'src/gpu/gl/command_buffer')
-rw-r--r-- | src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp | 61 |
1 files changed, 43 insertions, 18 deletions
diff --git a/src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp b/src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp index 585f1d079e..61eab4bebf 100644 --- a/src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp +++ b/src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp @@ -185,46 +185,73 @@ void SkCommandBufferGLContext::initializeGLContext(void* nativeWindow, const int const int* surfaceAttribs) { LoadCommandBufferOnce(); if (!gfFunctionsLoadedSuccessfully) { + SkDebugf("Command Buffer: Could not load EGL functions.\n"); return; } - fDisplay = gfGetDisplay(static_cast<EGLNativeDisplayType>(EGL_DEFAULT_DISPLAY)); + fDisplay = gfGetDisplay(EGL_DEFAULT_DISPLAY); if (EGL_NO_DISPLAY == fDisplay) { - SkDebugf("Could not create EGL display!"); + SkDebugf("Command Buffer: Could not create EGL display.\n"); return; } EGLint majorVersion; EGLint minorVersion; - gfInitialize(fDisplay, &majorVersion, &minorVersion); + if (!gfInitialize(fDisplay, &majorVersion, &minorVersion)) { + SkDebugf("Command Buffer: Could not initialize EGL display.\n"); + this->destroyGLContext(); + return; + } - EGLConfig surfaceConfig = static_cast<EGLConfig>(fConfig); EGLint numConfigs; - gfChooseConfig(fDisplay, configAttribs, &surfaceConfig, 1, &numConfigs); + if (!gfChooseConfig(fDisplay, configAttribs, static_cast<EGLConfig*>(&fConfig), 1, + &numConfigs) || numConfigs != 1) { + SkDebugf("Command Buffer: Could not choose EGL config.\n"); + this->destroyGLContext(); + return; + } if (nativeWindow) { - fSurface = gfCreateWindowSurface(fDisplay, surfaceConfig, - (EGLNativeWindowType)nativeWindow, surfaceAttribs); + fSurface = gfCreateWindowSurface(fDisplay, + static_cast<EGLConfig>(fConfig), + (EGLNativeWindowType)nativeWindow, + surfaceAttribs); } else { - fSurface = gfCreatePbufferSurface(fDisplay, surfaceConfig, surfaceAttribs); + fSurface = gfCreatePbufferSurface(fDisplay, + static_cast<EGLConfig>(fConfig), + surfaceAttribs); + } + if (EGL_NO_SURFACE == fSurface) { + SkDebugf("Command Buffer: Could not create EGL surface.\n"); + this->destroyGLContext(); + return; } static const EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; - fContext = gfCreateContext(fDisplay, surfaceConfig, nullptr, contextAttribs); + fContext = gfCreateContext(fDisplay, static_cast<EGLConfig>(fConfig), nullptr, contextAttribs); + if (EGL_NO_CONTEXT == fContext) { + SkDebugf("Command Buffer: Could not create EGL context.\n"); + this->destroyGLContext(); + return; + } - gfMakeCurrent(fDisplay, fSurface, fSurface, fContext); + if (!gfMakeCurrent(fDisplay, fSurface, fSurface, fContext)) { + SkDebugf("Command Buffer: Could not make EGL context current.\n"); + this->destroyGLContext(); + return; + } SkAutoTUnref<const GrGLInterface> gl(GrGLCreateCommandBufferInterface()); if (nullptr == gl.get()) { - SkDebugf("Could not create CommandBuffer GL interface!\n"); + SkDebugf("Command Buffer: Could not create CommandBuffer GL interface.\n"); this->destroyGLContext(); return; } if (!gl->validate()) { - SkDebugf("Could not validate CommandBuffer GL interface!\n"); + SkDebugf("Command Buffer: Could not validate CommandBuffer GL interface.\n"); this->destroyGLContext(); return; } @@ -264,7 +291,7 @@ void SkCommandBufferGLContext::onPlatformMakeCurrent() const { return; } if (!gfMakeCurrent(fDisplay, fSurface, fSurface, fContext)) { - SkDebugf("Could not set the context.\n"); + SkDebugf("Command Buffer: Could not make EGL context current.\n"); } } @@ -273,7 +300,7 @@ void SkCommandBufferGLContext::onPlatformSwapBuffers() const { return; } if (!gfSwapBuffers(fDisplay, fSurface)) { - SkDebugf("Could not complete gfSwapBuffers.\n"); + SkDebugf("Command Buffer: Could not complete gfSwapBuffers.\n"); } } @@ -298,14 +325,12 @@ bool SkCommandBufferGLContext::makeCurrent() { int SkCommandBufferGLContext::getStencilBits() { EGLint result = 0; - EGLConfig surfaceConfig = static_cast<EGLConfig>(fConfig); - gfGetConfigAttrib(fDisplay, surfaceConfig, EGL_STENCIL_SIZE, &result); + gfGetConfigAttrib(fDisplay, static_cast<EGLConfig>(fConfig), EGL_STENCIL_SIZE, &result); return result; } int SkCommandBufferGLContext::getSampleCount() { EGLint result = 0; - EGLConfig surfaceConfig = static_cast<EGLConfig>(fConfig); - gfGetConfigAttrib(fDisplay, surfaceConfig, EGL_SAMPLES, &result); + gfGetConfigAttrib(fDisplay, static_cast<EGLConfig>(fConfig), EGL_SAMPLES, &result); return result; } |