diff options
author | kkinnunen <kkinnunen@nvidia.com> | 2016-05-17 06:01:40 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-17 06:01:40 -0700 |
commit | aac0cb07ca44b116f9cd0c5b78cbcb795a6dec97 (patch) | |
tree | beca833605699bbbff0a237fff5dd6d97a97f1b1 /tools/gpu/gl | |
parent | 4933d0baadae6786ad5636e2c4fdf7e2591d09e1 (diff) |
Remove workarounds initializing command buffer EGL
The eglDisplay() of command buffer EGL implementation now does not
allocate a new EGL display per call, rather just returns the global.
The EGL implementation is fixed as part of bug 581634.
Removes eglTerminate call, as it's should not be used in Skia at the
moment. The call will terminate all of EGL, which is not intendend. The
previous usage was only due to incorrect implementation of the API. Not
added back to anywhere else, leaking EGL globals is as
designed. Discussed in https://chromiumcodereview.appspot.com/1733323002.
BUG=581634, 603223
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1978733003
Review-Url: https://codereview.chromium.org/1978733003
Diffstat (limited to 'tools/gpu/gl')
-rw-r--r-- | tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp | 75 |
1 files changed, 23 insertions, 52 deletions
diff --git a/tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp b/tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp index 850adaaf25..05a2a2b1f7 100644 --- a/tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp +++ b/tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp @@ -140,41 +140,6 @@ static const GrGLInterface* create_command_buffer_interface() { return GrGLAssembleGLESInterface(gLibrary, command_buffer_get_gl_proc); } -// We use a poor man's garbage collector of EGLDisplays. They are only -// terminated when there are no more EGLDisplays in use. See crbug.com/603223 -SK_DECLARE_STATIC_MUTEX(gDisplayMutex); -static int gActiveDisplayCnt; -SkTArray<EGLDisplay> gRetiredDisplays; - -static EGLDisplay get_and_init_display() { - SkAutoMutexAcquire am(gDisplayMutex); - EGLDisplay dsp = gfGetDisplay(EGL_DEFAULT_DISPLAY); - if (dsp == EGL_NO_DISPLAY) { - return EGL_NO_DISPLAY; - } - EGLint major, minor; - if (!gfInitialize(dsp, &major, &minor)) { - gRetiredDisplays.push_back(dsp); - return EGL_NO_DISPLAY; - } - ++gActiveDisplayCnt; - return dsp; -} - -static void retire_display(EGLDisplay dsp) { - if (dsp == EGL_NO_DISPLAY) { - return; - } - SkAutoMutexAcquire am(gDisplayMutex); - gRetiredDisplays.push_back(dsp); - --gActiveDisplayCnt; - if (!gActiveDisplayCnt) { - for (EGLDisplay d : gRetiredDisplays) { - gfTerminate(d); - } - gRetiredDisplays.reset(); - } -} } // anonymous namespace namespace sk_gpu_test { @@ -232,12 +197,16 @@ void CommandBufferGLTestContext::initializeGLContext(void *nativeWindow, const i // Make sure CHROMIUM_path_rendering is enabled for NVPR support. sk_setenv("CHROME_COMMAND_BUFFER_GLES2_ARGS", "--enable-gl-path-rendering"); - fDisplay = get_and_init_display(); + fDisplay = gfGetDisplay(EGL_DEFAULT_DISPLAY); if (EGL_NO_DISPLAY == fDisplay) { SkDebugf("Command Buffer: Could not create EGL display.\n"); return; } - + if (!gfInitialize(fDisplay, nullptr, nullptr)) { + 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) { @@ -303,22 +272,24 @@ void CommandBufferGLTestContext::destroyGLContext() { if (!gfFunctionsLoadedSuccessfully) { return; } - if (fDisplay) { - gfMakeCurrent(fDisplay, 0, 0, 0); - - if (fContext) { - gfDestroyContext(fDisplay, fContext); - fContext = EGL_NO_CONTEXT; - } - - if (fSurface) { - gfDestroySurface(fDisplay, fSurface); - fSurface = EGL_NO_SURFACE; - } - - retire_display(fDisplay); - fDisplay = EGL_NO_DISPLAY; + if (EGL_NO_DISPLAY == fDisplay) { + return; + } + if (EGL_NO_CONTEXT != fContext) { + gfDestroyContext(fDisplay, fContext); + fContext = EGL_NO_CONTEXT; + } + // Call MakeCurrent after destroying the context, so that the EGL implementation knows that + // the context is not used anymore after it is released from being current. This way + // command buffer does not need to abandon the context before destruction, and no + // client-side errors are printed. + gfMakeCurrent(fDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + + if (EGL_NO_SURFACE != fSurface) { + gfDestroySurface(fDisplay, fSurface); + fSurface = EGL_NO_SURFACE; } + fDisplay = EGL_NO_DISPLAY; } void CommandBufferGLTestContext::onPlatformMakeCurrent() const { |