зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1532929 - Use SharedGL on android r=nical
RenderCompositorEGL is also used on wayland, but SharedGL is not enabled on wayalnd. Since SharedGL caused flickering, when multiple windows were opened on wayland. Differential Revision: https://phabricator.services.mozilla.com/D23786 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
5d06386c32
Коммит
4649e87987
|
@ -16,7 +16,7 @@
|
|||
# include "mozilla/webrender/RenderCompositorANGLE.h"
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WAYLAND
|
||||
#if defined(MOZ_WAYLAND) || defined(MOZ_WIDGET_ANDROID)
|
||||
# include "mozilla/webrender/RenderCompositorEGL.h"
|
||||
#endif
|
||||
|
||||
|
@ -32,7 +32,7 @@ UniquePtr<RenderCompositor> RenderCompositor::Create(
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WAYLAND
|
||||
#if defined(MOZ_WAYLAND) || defined(MOZ_WIDGET_ANDROID)
|
||||
UniquePtr<RenderCompositor> eglCompositor =
|
||||
RenderCompositorEGL::Create(aWidget);
|
||||
if (eglCompositor) {
|
||||
|
|
|
@ -10,11 +10,14 @@
|
|||
#include "GLContextEGL.h"
|
||||
#include "GLContextProvider.h"
|
||||
#include "GLLibraryEGL.h"
|
||||
#include "mozilla/webrender/RenderThread.h"
|
||||
#include "mozilla/widget/CompositorWidget.h"
|
||||
#include "mozilla/widget/GtkCompositorWidget.h"
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <gdk/gdkx.h>
|
||||
#ifdef MOZ_WAYLAND
|
||||
# include "mozilla/widget/GtkCompositorWidget.h"
|
||||
# include <gdk/gdk.h>
|
||||
# include <gdk/gdkx.h>
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
namespace wr {
|
||||
|
@ -22,18 +25,28 @@ namespace wr {
|
|||
/* static */
|
||||
UniquePtr<RenderCompositor> RenderCompositorEGL::Create(
|
||||
RefPtr<widget::CompositorWidget> aWidget) {
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
if (!RenderThread::Get()->SharedGL()) {
|
||||
gfxCriticalNote << "Failed to get shared GL context";
|
||||
return nullptr;
|
||||
}
|
||||
return MakeUnique<RenderCompositorEGL>(aWidget);
|
||||
#elif defined(MOZ_WAYLAND)
|
||||
// Disabled SharedGL() usage on wayland. Its usage caused flicker when
|
||||
// multiple windows were opened. See Bug 1535893.
|
||||
if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<gl::GLContext> gl;
|
||||
gl = CreateGLContext();
|
||||
if (!gl) {
|
||||
return nullptr;
|
||||
}
|
||||
return MakeUnique<RenderCompositorEGL>(gl, aWidget);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef MOZ_WAYLAND
|
||||
/* static */ already_AddRefed<gl::GLContext>
|
||||
RenderCompositorEGL::CreateGLContext() {
|
||||
// Create GLContext with dummy EGLSurface.
|
||||
|
@ -48,6 +61,7 @@ RenderCompositorEGL::CreateGLContext() {
|
|||
|
||||
return gl.forget();
|
||||
}
|
||||
#endif
|
||||
|
||||
EGLSurface RenderCompositorEGL::CreateEGLSurface() {
|
||||
EGLSurface surface = EGL_NO_SURFACE;
|
||||
|
@ -59,6 +73,11 @@ EGLSurface RenderCompositorEGL::CreateEGLSurface() {
|
|||
return surface;
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
RenderCompositorEGL::RenderCompositorEGL(
|
||||
RefPtr<widget::CompositorWidget> aWidget)
|
||||
: RenderCompositor(std::move(aWidget)), mEGLSurface(EGL_NO_SURFACE) {}
|
||||
#elif defined(MOZ_WAYLAND)
|
||||
RenderCompositorEGL::RenderCompositorEGL(
|
||||
RefPtr<gl::GLContext> aGL, RefPtr<widget::CompositorWidget> aWidget)
|
||||
: RenderCompositor(std::move(aWidget)),
|
||||
|
@ -66,10 +85,12 @@ RenderCompositorEGL::RenderCompositorEGL(
|
|||
mEGLSurface(EGL_NO_SURFACE) {
|
||||
MOZ_ASSERT(mGL);
|
||||
}
|
||||
#endif
|
||||
|
||||
RenderCompositorEGL::~RenderCompositorEGL() { DestroyEGLSurface(); }
|
||||
|
||||
bool RenderCompositorEGL::BeginFrame() {
|
||||
#ifdef MOZ_WAYLAND
|
||||
if (mWidget->AsX11() &&
|
||||
mWidget->AsX11()->WaylandRequestsUpdatingEGLSurface()) {
|
||||
// Destroy EGLSurface if it exists.
|
||||
|
@ -77,8 +98,8 @@ bool RenderCompositorEGL::BeginFrame() {
|
|||
mEGLSurface = CreateEGLSurface();
|
||||
gl::GLContextEGL::Cast(gl())->SetEGLSurfaceOverride(mEGLSurface);
|
||||
}
|
||||
|
||||
if (!mGL->MakeCurrent()) {
|
||||
#endif
|
||||
if (!gl()->MakeCurrent()) {
|
||||
gfxCriticalNote << "Failed to make render context current, can't draw.";
|
||||
return false;
|
||||
}
|
||||
|
@ -88,15 +109,36 @@ bool RenderCompositorEGL::BeginFrame() {
|
|||
|
||||
void RenderCompositorEGL::EndFrame() {
|
||||
if (mEGLSurface != EGL_NO_SURFACE) {
|
||||
mGL->SwapBuffers();
|
||||
gl()->SwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
void RenderCompositorEGL::WaitForGPU() {}
|
||||
|
||||
void RenderCompositorEGL::Pause() {}
|
||||
void RenderCompositorEGL::Pause() {
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
DestroyEGLSurface();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool RenderCompositorEGL::Resume() { return true; }
|
||||
bool RenderCompositorEGL::Resume() {
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
// Destroy EGLSurface if it exists.
|
||||
DestroyEGLSurface();
|
||||
mEGLSurface = CreateEGLSurface();
|
||||
gl::GLContextEGL::Cast(gl())->SetEGLSurfaceOverride(mEGLSurface);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
gl::GLContext* RenderCompositorEGL::gl() const {
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
return RenderThread::Get()->SharedGL();
|
||||
#elif defined(MOZ_WAYLAND)
|
||||
MOZ_ASSERT(mGL);
|
||||
return mGL;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool RenderCompositorEGL::MakeCurrent() {
|
||||
gl::GLContextEGL::Cast(gl())->SetEGLSurfaceOverride(mEGLSurface);
|
||||
|
|
|
@ -19,8 +19,12 @@ class RenderCompositorEGL : public RenderCompositor {
|
|||
static UniquePtr<RenderCompositor> Create(
|
||||
RefPtr<widget::CompositorWidget> aWidget);
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
explicit RenderCompositorEGL(RefPtr<widget::CompositorWidget> aWidget);
|
||||
#elif defined(MOZ_WAYLAND)
|
||||
RenderCompositorEGL(RefPtr<gl::GLContext> aGL,
|
||||
RefPtr<widget::CompositorWidget> aWidget);
|
||||
#endif
|
||||
virtual ~RenderCompositorEGL();
|
||||
|
||||
bool BeginFrame() override;
|
||||
|
@ -29,7 +33,7 @@ class RenderCompositorEGL : public RenderCompositor {
|
|||
void Pause() override;
|
||||
bool Resume() override;
|
||||
|
||||
gl::GLContext* gl() const override { return mGL; }
|
||||
gl::GLContext* gl() const override;
|
||||
|
||||
bool MakeCurrent() override;
|
||||
|
||||
|
@ -38,12 +42,16 @@ class RenderCompositorEGL : public RenderCompositor {
|
|||
LayoutDeviceIntSize GetBufferSize() override;
|
||||
|
||||
protected:
|
||||
#ifdef MOZ_WAYLAND
|
||||
static already_AddRefed<gl::GLContext> CreateGLContext();
|
||||
#endif
|
||||
EGLSurface CreateEGLSurface();
|
||||
|
||||
void DestroyEGLSurface();
|
||||
|
||||
#ifdef MOZ_WAYLAND
|
||||
const RefPtr<gl::GLContext> mGL;
|
||||
#endif
|
||||
EGLSurface mEGLSurface;
|
||||
};
|
||||
|
||||
|
|
|
@ -26,6 +26,10 @@
|
|||
# include "mozilla/widget/WinCompositorWindowThread.h"
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
# include "GLLibraryEGL.h"
|
||||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
static already_AddRefed<gl::GLContext> CreateGLContext();
|
||||
|
@ -802,12 +806,37 @@ static already_AddRefed<gl::GLContext> CreateGLContextANGLE() {
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
static already_AddRefed<gl::GLContext> CreateGLContextEGL() {
|
||||
nsCString discardFailureId;
|
||||
if (!gl::GLLibraryEGL::EnsureInitialized(/* forceAccel */ true,
|
||||
&discardFailureId)) {
|
||||
gfxCriticalNote << "Failed to load EGL library: " << discardFailureId.get();
|
||||
return nullptr;
|
||||
}
|
||||
// Create GLContext with dummy EGLSurface.
|
||||
RefPtr<gl::GLContext> gl =
|
||||
gl::GLContextProviderEGL::CreateForCompositorWidget(
|
||||
nullptr, /* aWebRender */ true, /* aForceAccelerated */ true);
|
||||
if (!gl || !gl->MakeCurrent()) {
|
||||
gfxCriticalNote << "Failed GL context creation for WebRender: "
|
||||
<< gfx::hexa(gl.get());
|
||||
return nullptr;
|
||||
}
|
||||
return gl.forget();
|
||||
}
|
||||
#endif
|
||||
|
||||
static already_AddRefed<gl::GLContext> CreateGLContext() {
|
||||
#ifdef XP_WIN
|
||||
if (gfx::gfxVars::UseWebRenderANGLE()) {
|
||||
return CreateGLContextANGLE();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
return CreateGLContextEGL();
|
||||
#endif
|
||||
// We currently only support a shared GLContext
|
||||
// with ANGLE.
|
||||
return nullptr;
|
||||
|
|
|
@ -48,9 +48,11 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
|
|||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
|
||||
EXPORTS.mozilla.webrender += [
|
||||
'RenderAndroidSurfaceTextureHostOGL.h',
|
||||
'RenderCompositorEGL.h',
|
||||
]
|
||||
UNIFIED_SOURCES += [
|
||||
'RenderAndroidSurfaceTextureHostOGL.cpp',
|
||||
'RenderCompositorEGL.cpp',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_ENABLE_D3D10_LAYER']:
|
||||
|
|
Загрузка…
Ссылка в новой задаче