Bug 1532942 - Use EGLConfig as argument of CreateEGLSurfaceForCompositorWidget() r=jgilbert
authorsotaro <sotaro.ikeda.g@gmail.com>
Wed, 06 Mar 2019 19:00:38 +0000
changeset 520596 35bcd02a8ef497616c7b89d8c25d35eb33290b01
parent 520595 04e9867c3f738e2daf7df1fbe7743bef58f1a08c
child 520597 257a060b7d65d506689fe558dd716ee1bd2e7e82
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs1532942
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
gfx/gl/GLContextEGL.h
gfx/gl/GLContextProviderEGL.cpp
gfx/webrender_bindings/RenderCompositorEGL.cpp
gfx/webrender_bindings/RenderCompositorEGL.h
--- a/gfx/gl/GLContextEGL.h
+++ b/gfx/gl/GLContextEGL.h
@@ -86,19 +86,19 @@ class GLContextEGL : public GLContext {
   void BindOffscreenFramebuffer();
 
   void Destroy();
 
   static already_AddRefed<GLContextEGL> CreateEGLPBufferOffscreenContext(
       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;
   friend class GLContextEGLFactory;
 
   virtual void OnMarkDestroyed() override;
 
  public:
--- a/gfx/gl/GLContextProviderEGL.cpp
+++ b/gfx/gl/GLContextProviderEGL.cpp
@@ -291,43 +291,35 @@ already_AddRefed<GLContext> GLContextEGL
   gl->SetIsDoubleBuffered(doubleBuffered);
   if (aWebRender && egl->IsANGLE()) {
     MOZ_ASSERT(doubleBuffered);
     egl->fSwapInterval(EGL_DISPLAY(), 0);
   }
   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!";
     return EGL_NO_SURFACE;
   }
 
   MOZ_ASSERT(aCompositorWidget);
   EGLNativeWindowType window =
       GET_NATIVE_WINDOW_FROM_COMPOSITOR_WIDGET(aCompositorWidget);
   if (!window) {
     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
 
 GLContextEGL::GLContextEGL(CreateContextFlags flags, const SurfaceCaps& caps,
                            bool isOffscreen, EGLConfig config,
                            EGLSurface surface, EGLContext context)
     : GLContext(flags, caps, nullptr, isOffscreen, false),
       mConfig(config),
--- a/gfx/webrender_bindings/RenderCompositorEGL.cpp
+++ b/gfx/webrender_bindings/RenderCompositorEGL.cpp
@@ -52,22 +52,20 @@ RenderCompositorEGL::CreateGLContext(Ref
     gfxCriticalNote << "Failed GL context creation for WebRender: "
                     << gfx::hexa(gl.get());
     return nullptr;
   }
 
   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";
   }
   return surface;
 }
 
 RenderCompositorEGL::RenderCompositorEGL(
     RefPtr<gl::GLContext> aGL, RefPtr<widget::CompositorWidget> aWidget)
@@ -79,17 +77,17 @@ RenderCompositorEGL::RenderCompositorEGL
 
 RenderCompositorEGL::~RenderCompositorEGL() { DestroyEGLSurface(); }
 
 bool RenderCompositorEGL::BeginFrame() {
   if (mWidget->AsX11() &&
       mWidget->AsX11()->WaylandRequestsUpdatingEGLSurface()) {
     // Destroy EGLSurface if it exists.
     DestroyEGLSurface();
-    mEGLSurface = CreateEGLSurface(mWidget);
+    mEGLSurface = CreateEGLSurface();
     gl::GLContextEGL::Cast(gl())->SetEGLSurfaceOverride(mEGLSurface);
   }
 
   if (!mGL->MakeCurrent()) {
     gfxCriticalNote << "Failed to make render context current, can't draw.";
     return false;
   }
 
--- a/gfx/webrender_bindings/RenderCompositorEGL.h
+++ b/gfx/webrender_bindings/RenderCompositorEGL.h
@@ -35,17 +35,17 @@ class RenderCompositorEGL : public Rende
 
   bool UseANGLE() const override { return false; }
 
   LayoutDeviceIntSize GetBufferSize() override;
 
  protected:
   static already_AddRefed<gl::GLContext> CreateGLContext(
       RefPtr<widget::CompositorWidget> aWidget);
-  static EGLSurface CreateEGLSurface(widget::CompositorWidget* aWidget);
+  EGLSurface CreateEGLSurface();
 
   void DestroyEGLSurface();
 
   const RefPtr<gl::GLContext> mGL;
   EGLSurface mEGLSurface;
 };
 
 }  // namespace wr