const GrGLInterface* GrGLCreateCommandBufferInterface() { LoadCommandBufferOnce(); if (!gfFunctionsLoadedSuccessfully) { return nullptr; } return GrGLAssembleGLESInterface(ghLibrary, command_buffer_get_gl_proc); }
void SkCommandBufferGLContext::initializeGLContext(void* nativeWindow, const int* configAttribs, const int* surfaceAttribs) { LoadCommandBufferOnce(); if (!gfFunctionsLoadedSuccessfully) { return; } fDisplay = gfGetDisplay(static_cast<EGLNativeDisplayType>(EGL_DEFAULT_DISPLAY)); if (EGL_NO_DISPLAY == fDisplay) { SkDebugf("Could not create EGL display!"); return; } EGLint majorVersion; EGLint minorVersion; gfInitialize(fDisplay, &majorVersion, &minorVersion); EGLConfig surfaceConfig = static_cast<EGLConfig>(fConfig); EGLint numConfigs; gfChooseConfig(fDisplay, configAttribs, &surfaceConfig, 1, &numConfigs); if (nativeWindow) { fSurface = gfCreateWindowSurface(fDisplay, surfaceConfig, (EGLNativeWindowType)nativeWindow, surfaceAttribs); } else { fSurface = gfCreatePbufferSurface(fDisplay, surfaceConfig, surfaceAttribs); } static const EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; fContext = gfCreateContext(fDisplay, surfaceConfig, nullptr, contextAttribs); gfMakeCurrent(fDisplay, fSurface, fSurface, fContext); SkAutoTUnref<const GrGLInterface> gl(GrGLCreateCommandBufferInterface()); if (nullptr == gl.get()) { SkDebugf("Could not create CommandBuffer GL interface!\n"); this->destroyGLContext(); return; } if (!gl->validate()) { SkDebugf("Could not validate CommandBuffer GL interface!\n"); this->destroyGLContext(); return; } this->init(gl.detach()); }
void SkCommandBufferGLContext::initializeGLContext(void* nativeWindow, const int* configAttribs, const int* surfaceAttribs) { LoadCommandBufferOnce(); if (!gfFunctionsLoadedSuccessfully) { SkDebugf("Command Buffer: Could not load EGL functions.\n"); return; } // Make sure CHROMIUM_path_rendering is enabled for NVPR support. sk_setenv("CHROME_COMMAND_BUFFER_GLES2_ARGS", "--enable-gl-path-rendering"); fDisplay = gfGetDisplay(EGL_DEFAULT_DISPLAY); if (EGL_NO_DISPLAY == fDisplay) { SkDebugf("Command Buffer: Could not create EGL display.\n"); return; } EGLint majorVersion; EGLint minorVersion; if (!gfInitialize(fDisplay, &majorVersion, &minorVersion)) { SkDebugf("Command Buffer: Could not initialize EGL display.\n"); this->destroyGLContext(); return; } EGLint 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, static_cast<EGLConfig>(fConfig), (EGLNativeWindowType)nativeWindow, surfaceAttribs); } else { 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, static_cast<EGLConfig>(fConfig), nullptr, contextAttribs); if (EGL_NO_CONTEXT == fContext) { SkDebugf("Command Buffer: Could not create EGL context.\n"); this->destroyGLContext(); return; } 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("Command Buffer: Could not create CommandBuffer GL interface.\n"); this->destroyGLContext(); return; } if (!gl->validate()) { SkDebugf("Command Buffer: Could not validate CommandBuffer GL interface.\n"); this->destroyGLContext(); return; } this->init(gl.release()); }