Bug 1646007 [Wayland] Check Wayland dmabuf backend and fallback to a default one, r=jgilbert

Differential Revision: https://phabricator.services.mozilla.com/D79979
This commit is contained in:
Martin Stransky 2020-06-25 05:57:40 +00:00
Родитель 18f4cd508d
Коммит 4a8f96bbdc
7 изменённых файлов: 36 добавлений и 12 удалений

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

@ -108,13 +108,12 @@ UniquePtr<SurfaceFactory> SurfaceFactory::Create(
case layers::TextureType::DMABUF:
#ifdef MOZ_WAYLAND
if (gl.GetContextType() != GLContextType::EGL) return nullptr;
if (!gfxPlatformGtk::GetPlatform()->UseWaylandDMABufWebGL())
return nullptr;
return MakeUnique<SurfaceFactory_DMABUF>(gl);
#else
return nullptr;
if (gl.GetContextType() == GLContextType::EGL &&
gfxPlatformGtk::GetPlatform()->UseWaylandDMABufWebGL()) {
return SurfaceFactory_DMABUF::Create(gl);
}
#endif
return nullptr;
case layers::TextureType::AndroidNativeWindow:
#ifdef MOZ_WIDGET_ANDROID

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

@ -5,6 +5,7 @@
#include "SharedSurfaceDMABUF.h"
#include "gfxPlatformGtk.h"
#include "GLContextEGL.h"
#include "MozFramebuffer.h"
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor, etc
@ -51,6 +52,21 @@ Maybe<layers::SurfaceDescriptor> SharedSurface_DMABUF::ToSurfaceDescriptor() {
return Some(desc);
}
/*static*/
UniquePtr<SurfaceFactory_DMABUF> SurfaceFactory_DMABUF::Create(GLContext& gl) {
if (!gfxPlatformGtk::GetPlatform()->UseWaylandDMABufWebGL()) {
return nullptr;
}
auto dmabufFactory = MakeUnique<SurfaceFactory_DMABUF>(gl);
if (dmabufFactory->CanCreateSurface()) {
return dmabufFactory;
}
gfxPlatformGtk::GetPlatform()->DisableWaylandDMABufWebGL();
return nullptr;
}
SurfaceFactory_DMABUF::SurfaceFactory_DMABUF(GLContext& gl)
: SurfaceFactory({&gl, SharedSurfaceType::EGLSurfaceDMABUF,
layers::TextureType::DMABUF, true}) {}

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

@ -47,6 +47,8 @@ class SharedSurface_DMABUF final : public SharedSurface {
class SurfaceFactory_DMABUF : public SurfaceFactory {
public:
static UniquePtr<SurfaceFactory_DMABUF> Create(GLContext& gl);
explicit SurfaceFactory_DMABUF(GLContext&);
public:
@ -54,6 +56,11 @@ class SurfaceFactory_DMABUF : public SurfaceFactory {
const SharedSurfaceDesc& desc) override {
return SharedSurface_DMABUF::Create(desc);
}
bool CanCreateSurface() {
UniquePtr<SharedSurface> test = CreateShared(gfx::IntSize(1, 1));
return test != nullptr;
}
};
} // namespace gl

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

@ -112,7 +112,7 @@ TextureType TexTypeForWebgl(KnowsCompositor* const knowsCompositor) {
}
if (kIsWayland) {
if (gfxPlatform::GetPlatform()->IsWaylandDisplay()) {
return TextureType::WaylandDMABUF;
return TextureType::DMABUF;
}
}
if (kIsX11) {

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

@ -122,6 +122,9 @@ gfxPlatformGtk::~gfxPlatformGtk() {
Factory::ReleaseFTLibrary(gPlatformFTLibrary);
gPlatformFTLibrary = nullptr;
mUseWebGLDmabufBackend =
IsWaylandDisplay() && GetDMABufDevice()->IsDMABufWebGLEnabled();
}
void gfxPlatformGtk::FlushContentDrawing() {
@ -735,9 +738,6 @@ bool gfxPlatformGtk::UseWaylandDMABufVideoTextures() {
(GetDMABufDevice()->IsDMABufVideoTexturesEnabled() ||
GetDMABufDevice()->IsDMABufVAAPIEnabled());
}
bool gfxPlatformGtk::UseWaylandDMABufWebGL() {
return IsWaylandDisplay() && GetDMABufDevice()->IsDMABufWebGLEnabled();
}
bool gfxPlatformGtk::UseWaylandHardwareVideoDecoding() {
return IsWaylandDisplay() && GetDMABufDevice()->IsDMABufVAAPIEnabled() &&
gfxPlatform::CanUseHardwareVideoDecoding();

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

@ -89,7 +89,8 @@ class gfxPlatformGtk final : public gfxPlatform {
#ifdef MOZ_WAYLAND
bool UseWaylandDMABufTextures();
bool UseWaylandDMABufVideoTextures();
bool UseWaylandDMABufWebGL() override;
bool UseWaylandDMABufWebGL() override { return mUseWebGLDmabufBackend; }
void DisableWaylandDMABufWebGL() { mUseWebGLDmabufBackend = false; }
bool UseWaylandHardwareVideoDecoding();
#endif
@ -111,6 +112,7 @@ class gfxPlatformGtk final : public gfxPlatform {
#ifdef MOZ_X11
Display* mCompositorDisplay;
#endif
bool mUseWebGLDmabufBackend;
};
#endif /* GFX_PLATFORM_GTK_H */

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

@ -9589,7 +9589,7 @@
# Use DMABuf backend for WebGL on Wayland.
- name: widget.wayland-dmabuf-webgl.enabled
type: RelaxedAtomicBool
value: false
value: true
mirror: always
# Use VA-API for video playback on Wayland.