Bug 1460255 - Implement GLContextProviderWayland, r=lsalzman

GLContextProviderWayland provides both GLX and EGL GL backends on Wayland enabled builds
according to an active Gtk+ backend (X11/Wayland).

MozReview-Commit-ID: TTBDwWMBAP

--HG--
extra : rebase_source : 26e0455ae3775bdcea83deffbb8ad43aacdb3e42
This commit is contained in:
Martin Stransky 2018-05-15 16:15:35 +02:00
Родитель 35166c8f08
Коммит 704838e243
2 изменённых файлов: 105 добавлений и 1 удалений

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

@ -0,0 +1,99 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifdef MOZ_WIDGET_GTK
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#endif
#include "GLContextProvider.h"
namespace mozilla {
namespace gl {
using namespace mozilla::gfx;
using namespace mozilla::widget;
static class GLContextProviderGLX sGLContextProviderGLX;
static class GLContextProviderEGL sGLContextProviderEGL;
already_AddRefed<GLContext>
GLContextProviderWayland::CreateWrappingExisting(void* aContext, void* aSurface)
{
if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
return sGLContextProviderGLX.CreateWrappingExisting(aContext, aSurface);
} else {
return sGLContextProviderEGL.CreateWrappingExisting(aContext, aSurface);
}
}
already_AddRefed<GLContext>
GLContextProviderWayland::CreateForCompositorWidget(CompositorWidget* aCompositorWidget, bool aForceAccelerated)
{
if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
return sGLContextProviderGLX.CreateForCompositorWidget(aCompositorWidget, aForceAccelerated);
} else {
return sGLContextProviderEGL.CreateForCompositorWidget(aCompositorWidget, aForceAccelerated);
}
}
already_AddRefed<GLContext>
GLContextProviderWayland::CreateForWindow(nsIWidget* aWidget,
bool aWebRender,
bool aForceAccelerated)
{
if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
return sGLContextProviderGLX.CreateForWindow(aWidget, aWebRender, aForceAccelerated);
} else {
return sGLContextProviderEGL.CreateForWindow(aWidget, aWebRender, aForceAccelerated);
}
}
/*static*/ already_AddRefed<GLContext>
GLContextProviderWayland::CreateHeadless(CreateContextFlags flags,
nsACString* const out_failureId)
{
if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
return sGLContextProviderGLX.CreateHeadless(flags, out_failureId);
} else {
return sGLContextProviderEGL.CreateHeadless(flags, out_failureId);
}
}
/*static*/ already_AddRefed<GLContext>
GLContextProviderWayland::CreateOffscreen(const IntSize& size,
const SurfaceCaps& minCaps,
CreateContextFlags flags,
nsACString* const out_failureId)
{
if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
return sGLContextProviderGLX.CreateOffscreen(size, minCaps, flags, out_failureId);
} else {
return sGLContextProviderEGL.CreateOffscreen(size, minCaps, flags, out_failureId);
}
}
/*static*/ GLContext*
GLContextProviderWayland::GetGlobalContext()
{
if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
return sGLContextProviderGLX.GetGlobalContext();
} else {
return sGLContextProviderEGL.GetGlobalContext();
}
}
/*static*/ void
GLContextProviderWayland::Shutdown()
{
if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
sGLContextProviderGLX.Shutdown();
} else {
sGLContextProviderEGL.Shutdown();
}
}
} /* namespace gl */
} /* namespace mozilla */

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

@ -13,7 +13,7 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'uikit':
gl_provider = 'EAGL'
elif 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']:
if CONFIG['MOZ_EGL_XRENDER_COMPOSITE'] or CONFIG['MOZ_WAYLAND']:
if CONFIG['MOZ_EGL_XRENDER_COMPOSITE']:
gl_provider = 'EGL'
else:
gl_provider = 'GLX'
@ -119,6 +119,11 @@ elif gl_provider == 'GLX':
'SharedSurfaceGLX.h'
]
if CONFIG['MOZ_WAYLAND']:
SOURCES += [
'GLContextProviderWayland.cpp',
]
UNIFIED_SOURCES += [
'AndroidSurfaceTexture.cpp',
'DecomposeIntoNoRepeatTriangles.cpp',