Bug 1548499 - Set EGL context before call to eglSwapInterval. r=sotaro

The EGL context must be set before the call to eglSwapInterval to ensure that it will operate on the correct context.

Differential Revision: https://phabricator.services.mozilla.com/D30282

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kenny Levinsen 2019-05-24 06:06:12 +00:00
Родитель 374f6c917e
Коммит ed7d5b2663
1 изменённых файлов: 17 добавлений и 8 удалений

Просмотреть файл

@ -59,16 +59,13 @@ RenderCompositorEGL::~RenderCompositorEGL() { DestroyEGLSurface(); }
bool RenderCompositorEGL::BeginFrame() {
#ifdef MOZ_WAYLAND
if (mWidget->AsX11() &&
mWidget->AsX11()->WaylandRequestsUpdatingEGLSurface()) {
// Destroy EGLSurface if it exists.
bool newSurface =
mWidget->AsX11() && mWidget->AsX11()->WaylandRequestsUpdatingEGLSurface();
if (newSurface) {
// Destroy EGLSurface if it exists and create a new one. We will set the
// swap interval after MakeCurrent() has been called.
DestroyEGLSurface();
mEGLSurface = CreateEGLSurface();
if (mEGLSurface) {
const auto* egl = gl::GLLibraryEGL::Get();
// Make eglSwapBuffers() non-blocking on wayland
egl->fSwapInterval(gl::EGL_DISPLAY(), 0);
}
}
#endif
if (!MakeCurrent()) {
@ -76,6 +73,18 @@ bool RenderCompositorEGL::BeginFrame() {
return false;
}
#ifdef MOZ_WAYLAND
if (newSurface) {
// We have a new EGL surface, which on wayland needs to be configured for
// non-blocking buffer swaps. We need MakeCurrent() to set our current EGL
// context before we call eglSwapInterval, which is why we do it here rather
// than where the surface was created.
const auto* egl = gl::GLLibraryEGL::Get();
// Make eglSwapBuffers() non-blocking on wayland.
egl->fSwapInterval(gl::EGL_DISPLAY(), 0);
}
#endif
#ifdef MOZ_WIDGET_ANDROID
java::GeckoSurfaceTexture::DestroyUnused((int64_t)gl());
#endif