Commit 11326522 authored by stransky's avatar stransky
Browse files

Bug 1828071 [Linux] Use static preferences in nsDMABufDevice r=emilio

There's no need to create nsDMABufDevice just to get/set dmabuf config.

Differential Revision: https://phabricator.services.mozilla.com/D175469
parent 5c4d553c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -100,7 +100,7 @@ UniquePtr<SurfaceFactory> SurfaceFactory::Create(
    case layers::TextureType::DMABUF:
#ifdef MOZ_WAYLAND
      if (gl.GetContextType() == GLContextType::EGL &&
          widget::GetDMABufDevice()->IsDMABufWebGLEnabled()) {
          widget::nsDMABufDevice::IsDMABufWebGLEnabled()) {
        return SurfaceFactory_DMABUF::Create(gl);
      }
#endif
+2 −2
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ Maybe<layers::SurfaceDescriptor> SharedSurface_DMABUF::ToSurfaceDescriptor() {

/*static*/
UniquePtr<SurfaceFactory_DMABUF> SurfaceFactory_DMABUF::Create(GLContext& gl) {
  if (!widget::GetDMABufDevice()->IsDMABufWebGLEnabled()) {
  if (!widget::nsDMABufDevice::IsDMABufWebGLEnabled()) {
    return nullptr;
  }

@@ -100,7 +100,7 @@ UniquePtr<SurfaceFactory_DMABUF> SurfaceFactory_DMABUF::Create(GLContext& gl) {

  LOGDMABUF(
      ("SurfaceFactory_DMABUF::Create() failed, fallback to SW buffers.\n"));
  widget::GetDMABufDevice()->DisableDMABufWebGL();
  widget::nsDMABufDevice::DisableDMABufWebGL();
  return nullptr;
}

+1 −1
Original line number Diff line number Diff line
@@ -113,7 +113,7 @@ TextureType TexTypeForWebgl(KnowsCompositor* const knowsCompositor) {
#ifdef MOZ_WAYLAND
  if (kIsWayland) {
    if (!knowsCompositor->UsingSoftwareWebRender() &&
        widget::GetDMABufDevice()->IsDMABufWebGLEnabled()) {
        widget::nsDMABufDevice::IsDMABufWebGLEnabled()) {
      return TextureType::DMABUF;
    }
  }
+1 −1
Original line number Diff line number Diff line
@@ -275,7 +275,7 @@ static TextureType GetTextureType(gfx::SurfaceFormat aFormat,
#ifdef MOZ_WAYLAND
  if ((layersBackend == LayersBackend::LAYERS_WR &&
       !aKnowsCompositor->UsingSoftwareWebRender()) &&
      widget::GetDMABufDevice()->IsDMABufTexturesEnabled() &&
      widget::nsDMABufDevice::IsDMABufTexturesEnabled() &&
      aFormat != SurfaceFormat::A8) {
    return TextureType::DMABUF;
  }
+7 −8
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ using namespace mozilla::gfx;
namespace mozilla {
namespace widget {

bool nsDMABufDevice::sUseWebGLDmabufBackend = true;

#define GBMLIB_NAME "libgbm.so.1"
#define DRMLIB_NAME "libdrm.so.2"

@@ -138,10 +140,7 @@ bool nsDMABufDevice::IsEnabled(nsACString& aFailureId) {
}

nsDMABufDevice::nsDMABufDevice()
    : mUseWebGLDmabufBackend(true),
      mDRMFd(-1),
      mGbmDevice(nullptr),
      mInitialized(false) {
    : mDRMFd(-1), mGbmDevice(nullptr), mInitialized(false) {
  Configure();
}

@@ -217,15 +216,15 @@ bool nsDMABufDevice::IsDMABufTexturesEnabled() { return false; }
bool nsDMABufDevice::IsDMABufWebGLEnabled() {
  LOGDMABUF(
      ("nsDMABufDevice::IsDMABufWebGLEnabled: UseDMABuf %d "
       "mUseWebGLDmabufBackend %d "
       "sUseWebGLDmabufBackend %d "
       "widget_dmabuf_webgl_enabled %d\n",
       gfx::gfxVars::UseDMABuf(), mUseWebGLDmabufBackend,
       gfx::gfxVars::UseDMABuf(), sUseWebGLDmabufBackend,
       StaticPrefs::widget_dmabuf_webgl_enabled()));
  return gfx::gfxVars::UseDMABuf() && mUseWebGLDmabufBackend &&
  return gfx::gfxVars::UseDMABuf() && sUseWebGLDmabufBackend &&
         StaticPrefs::widget_dmabuf_webgl_enabled();
}

void nsDMABufDevice::DisableDMABufWebGL() { mUseWebGLDmabufBackend = false; }
void nsDMABufDevice::DisableDMABufWebGL() { sUseWebGLDmabufBackend = false; }

// TODO: Make private or make sure it's configured
nsDMABufDevice* GetDMABufDevice() {
Loading