From 81c5f1f2b3d44ae0032c73a5a9ae7df34c3a4d17 Mon Sep 17 00:00:00 2001 From: sotaro Date: Wed, 6 Mar 2019 19:00:38 +0000 Subject: [PATCH] Bug 1532942 - Use EGLConfig as argument of CreateEGLSurfaceForCompositorWidget() r=jgilbert EGLConfig could be get from GLContextEGL. It is better to use it than re-creating EGLConfig. Differential Revision: https://phabricator.services.mozilla.com/D22274 --HG-- extra : moz-landing-system : lando --- gfx/gl/GLContextEGL.h | 4 ++-- gfx/gl/GLContextProviderEGL.cpp | 14 +++----------- gfx/webrender_bindings/RenderCompositorEGL.cpp | 8 +++----- gfx/webrender_bindings/RenderCompositorEGL.h | 2 +- 4 files changed, 9 insertions(+), 19 deletions(-) diff --git a/gfx/gl/GLContextEGL.h b/gfx/gl/GLContextEGL.h index 92c4ca5cf6b0..3825ec6cd586 100644 --- a/gfx/gl/GLContextEGL.h +++ b/gfx/gl/GLContextEGL.h @@ -91,9 +91,9 @@ class GLContextEGL : public GLContext { CreateContextFlags flags, const gfx::IntSize& size, const SurfaceCaps& minCaps, nsACString* const out_FailureId); -#if defined(MOZ_WAYLAND) +#if defined(MOZ_WAYLAND) || defined(MOZ_WIDGET_ANDROID) static EGLSurface CreateEGLSurfaceForCompositorWidget( - widget::CompositorWidget* aCompositorWidget, bool aForceAccelerated); + widget::CompositorWidget* aCompositorWidget, const EGLConfig aConfig); #endif protected: friend class GLContextProviderEGL; diff --git a/gfx/gl/GLContextProviderEGL.cpp b/gfx/gl/GLContextProviderEGL.cpp index 4a85290f00e9..02e8bfc0ce78 100644 --- a/gfx/gl/GLContextProviderEGL.cpp +++ b/gfx/gl/GLContextProviderEGL.cpp @@ -296,10 +296,10 @@ already_AddRefed GLContextEGLFactory::Create( return gl.forget(); } -#if defined(MOZ_WAYLAND) +#if defined(MOZ_WAYLAND) || defined(MOZ_WIDGET_ANDROID) /* static */ EGLSurface GLContextEGL::CreateEGLSurfaceForCompositorWidget( - widget::CompositorWidget* aCompositorWidget, bool aForceAccelerated) { + widget::CompositorWidget* aCompositorWidget, const EGLConfig aConfig) { nsCString discardFailureId; if (!GLLibraryEGL::EnsureInitialized(false, &discardFailureId)) { gfxCriticalNote << "Failed to load EGL library 6!"; @@ -313,16 +313,8 @@ EGLSurface GLContextEGL::CreateEGLSurfaceForCompositorWidget( gfxCriticalNote << "window is null"; return EGL_NO_SURFACE; } - const bool useWebRender = - aCompositorWidget->GetCompositorOptions().UseWebRender(); - EGLConfig config; - if (!CreateConfig(&config, useWebRender)) { - gfxCriticalNote << "Failed to create EGLConfig!"; - return EGL_NO_SURFACE; - } - - return mozilla::gl::CreateSurfaceFromNativeWindow(window, config); + return mozilla::gl::CreateSurfaceFromNativeWindow(window, aConfig); } #endif diff --git a/gfx/webrender_bindings/RenderCompositorEGL.cpp b/gfx/webrender_bindings/RenderCompositorEGL.cpp index 442356ddeba2..f273c8aa89be 100644 --- a/gfx/webrender_bindings/RenderCompositorEGL.cpp +++ b/gfx/webrender_bindings/RenderCompositorEGL.cpp @@ -57,12 +57,10 @@ RenderCompositorEGL::CreateGLContext(RefPtr aWidget) { return gl.forget(); } -/* static */ -EGLSurface RenderCompositorEGL::CreateEGLSurface( - widget::CompositorWidget* aWidget) { +EGLSurface RenderCompositorEGL::CreateEGLSurface() { EGLSurface surface = EGL_NO_SURFACE; surface = gl::GLContextEGL::CreateEGLSurfaceForCompositorWidget( - aWidget, /* aForceAccelerated */ true); + mWidget, gl::GLContextEGL::Cast(gl())->mConfig); if (surface == EGL_NO_SURFACE) { gfxCriticalNote << "Failed to create EGLSurface"; } @@ -84,7 +82,7 @@ bool RenderCompositorEGL::BeginFrame() { mWidget->AsX11()->WaylandRequestsUpdatingEGLSurface()) { // Destroy EGLSurface if it exists. DestroyEGLSurface(); - mEGLSurface = CreateEGLSurface(mWidget); + mEGLSurface = CreateEGLSurface(); gl::GLContextEGL::Cast(gl())->SetEGLSurfaceOverride(mEGLSurface); } diff --git a/gfx/webrender_bindings/RenderCompositorEGL.h b/gfx/webrender_bindings/RenderCompositorEGL.h index 38b528f341e2..bf054fe119d3 100644 --- a/gfx/webrender_bindings/RenderCompositorEGL.h +++ b/gfx/webrender_bindings/RenderCompositorEGL.h @@ -40,7 +40,7 @@ class RenderCompositorEGL : public RenderCompositor { protected: static already_AddRefed CreateGLContext( RefPtr aWidget); - static EGLSurface CreateEGLSurface(widget::CompositorWidget* aWidget); + EGLSurface CreateEGLSurface(); void DestroyEGLSurface();