Bug 1464037 - Replace GL_PROVIDER_GLX by MOZ_X11 to build X11 dependent code, r=lsalzman

In order to have useful Wayland builds we need ability to switch
between GL backends run-time - to use EGL backend for Wayland and GLX backend for X11.

GL_PROVIDER_GLX is used exclusively for GLX GL backend, so let's replace GL_PROVIDER_GLX
build-time check by more general MOZ_X11 check which determines X11 dependent code
and it's valid for both X11 and Wayland builds.

MozReview-Commit-ID: HYobrHveoaP

--HG--
extra : rebase_source : 2d359355ee747f5898d27d8a28d66114f4135f5b
This commit is contained in:
Martin Stransky 2018-05-24 14:06:31 +02:00
parent c868a9a37d
commit b887819c71
10 changed files with 11 additions and 49 deletions

View File

@ -29,7 +29,7 @@
#include "SharedSurfaceIO.h" #include "SharedSurfaceIO.h"
#endif #endif
#ifdef GL_PROVIDER_GLX #ifdef MOZ_X11
#include "GLXLibrary.h" #include "GLXLibrary.h"
#include "SharedSurfaceGLX.h" #include "SharedSurfaceGLX.h"
#endif #endif
@ -83,7 +83,7 @@ GLScreenBuffer::CreateFactory(GLContext* gl,
if (useGl) { if (useGl) {
#if defined(XP_MACOSX) #if defined(XP_MACOSX)
factory = SurfaceFactory_IOSurface::Create(gl, caps, ipcChannel, flags); factory = SurfaceFactory_IOSurface::Create(gl, caps, ipcChannel, flags);
#elif defined(GL_PROVIDER_GLX) #elif defined(MOZ_X11)
if (sGLXLibrary.UseTextureFromPixmap()) if (sGLXLibrary.UseTextureFromPixmap())
factory = SurfaceFactory_GLXDrawable::Create(gl, caps, ipcChannel, flags); factory = SurfaceFactory_GLXDrawable::Create(gl, caps, ipcChannel, flags);
#elif defined(MOZ_WIDGET_UIKIT) #elif defined(MOZ_WIDGET_UIKIT)
@ -119,7 +119,7 @@ GLScreenBuffer::CreateFactory(GLContext* gl,
#endif #endif
} }
#ifdef GL_PROVIDER_GLX #ifdef MOZ_X11
if (!factory && sGLXLibrary.UseTextureFromPixmap()) { if (!factory && sGLXLibrary.UseTextureFromPixmap()) {
factory = SurfaceFactory_GLXDrawable::Create(gl, caps, ipcChannel, flags); factory = SurfaceFactory_GLXDrawable::Create(gl, caps, ipcChannel, flags);
} }

View File

@ -45,10 +45,8 @@
#endif #endif
#ifdef MOZ_X11 #ifdef MOZ_X11
#include "mozilla/layers/TextureClientX11.h" #include "mozilla/layers/TextureClientX11.h"
#ifdef GL_PROVIDER_GLX
#include "GLXLibrary.h" #include "GLXLibrary.h"
#endif #endif
#endif
#ifdef XP_MACOSX #ifdef XP_MACOSX
#include "mozilla/layers/MacIOSurfaceTextureClientOGL.h" #include "mozilla/layers/MacIOSurfaceTextureClientOGL.h"
@ -1127,7 +1125,6 @@ TextureClient::CreateForDrawing(TextureForwarder* aAllocator,
{ {
data = X11TextureData::Create(aSize, aFormat, aTextureFlags, aAllocator); data = X11TextureData::Create(aSize, aFormat, aTextureFlags, aAllocator);
} }
#ifdef GL_PROVIDER_GLX
if (!data && aLayersBackend == LayersBackend::LAYERS_OPENGL && if (!data && aLayersBackend == LayersBackend::LAYERS_OPENGL &&
type == gfxSurfaceType::Xlib && type == gfxSurfaceType::Xlib &&
aFormat != SurfaceFormat::A8 && aFormat != SurfaceFormat::A8 &&
@ -1136,7 +1133,6 @@ TextureClient::CreateForDrawing(TextureForwarder* aAllocator,
data = X11TextureData::Create(aSize, aFormat, aTextureFlags, aAllocator); data = X11TextureData::Create(aSize, aFormat, aTextureFlags, aAllocator);
} }
#endif #endif
#endif
#ifdef XP_MACOSX #ifdef XP_MACOSX
if (!data && gfxPrefs::UseIOSurfaceTextures()) { if (!data && gfxPrefs::UseIOSurfaceTextures()) {

View File

@ -7,10 +7,8 @@
#include "X11TextureHost.h" #include "X11TextureHost.h"
#include "mozilla/layers/BasicCompositor.h" #include "mozilla/layers/BasicCompositor.h"
#include "mozilla/layers/X11TextureSourceBasic.h" #include "mozilla/layers/X11TextureSourceBasic.h"
#ifdef GL_PROVIDER_GLX
#include "mozilla/layers/CompositorOGL.h" #include "mozilla/layers/CompositorOGL.h"
#include "mozilla/layers/X11TextureSourceOGL.h" #include "mozilla/layers/X11TextureSourceOGL.h"
#endif
#include "gfxXlibSurface.h" #include "gfxXlibSurface.h"
#include "gfx2DGlue.h" #include "gfx2DGlue.h"
@ -43,12 +41,10 @@ X11TextureHost::Lock()
mTextureSource = mTextureSource =
new X11TextureSourceBasic(mCompositor->AsBasicCompositor(), mSurface); new X11TextureSourceBasic(mCompositor->AsBasicCompositor(), mSurface);
break; break;
#ifdef GL_PROVIDER_GLX
case LayersBackend::LAYERS_OPENGL: case LayersBackend::LAYERS_OPENGL:
mTextureSource = mTextureSource =
new X11TextureSourceOGL(mCompositor->AsCompositorOGL(), mSurface); new X11TextureSourceOGL(mCompositor->AsCompositorOGL(), mSurface);
break; break;
#endif
default: default:
return false; return false;
} }
@ -78,11 +74,9 @@ X11TextureHost::GetFormat() const
return SurfaceFormat::UNKNOWN; return SurfaceFormat::UNKNOWN;
} }
gfxContentType type = mSurface->GetContentType(); gfxContentType type = mSurface->GetContentType();
#ifdef GL_PROVIDER_GLX
if (mCompositor->GetBackendType() == LayersBackend::LAYERS_OPENGL) { if (mCompositor->GetBackendType() == LayersBackend::LAYERS_OPENGL) {
return X11TextureSourceOGL::ContentTypeToSurfaceFormat(type); return X11TextureSourceOGL::ContentTypeToSurfaceFormat(type);
} }
#endif
return X11TextureSourceBasic::ContentTypeToSurfaceFormat(type); return X11TextureSourceBasic::ContentTypeToSurfaceFormat(type);
} }

View File

@ -74,11 +74,9 @@ SurfaceDescriptorX11::SurfaceDescriptorX11(gfxXlibSurface* aSurf,
mFormat = cairo_xlib_surface_get_visual(aSurf->CairoSurface())->visualid; mFormat = cairo_xlib_surface_get_visual(aSurf->CairoSurface())->visualid;
} }
#ifdef GL_PROVIDER_GLX
if (aForwardGLX) { if (aForwardGLX) {
mGLXPixmap = aSurf->GetGLXPixmap(); mGLXPixmap = aSurf->GetGLXPixmap();
} }
#endif
} }
SurfaceDescriptorX11::SurfaceDescriptorX11(Drawable aDrawable, XID aFormatID, SurfaceDescriptorX11::SurfaceDescriptorX11(Drawable aDrawable, XID aFormatID,
@ -109,10 +107,8 @@ SurfaceDescriptorX11::OpenForeign() const
surf = new gfxXlibSurface(display, mId, visual, mSize); surf = new gfxXlibSurface(display, mId, visual, mSize);
} }
#ifdef GL_PROVIDER_GLX
if (mGLXPixmap) if (mGLXPixmap)
surf->BindGLXPixmap(mGLXPixmap); surf->BindGLXPixmap(mGLXPixmap);
#endif
return surf->CairoStatus() ? nullptr : surf.forget(); return surf->CairoStatus() ? nullptr : surf.forget();
} }

View File

@ -4,8 +4,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifdef GL_PROVIDER_GLX
#include "X11TextureSourceOGL.h" #include "X11TextureSourceOGL.h"
#include "gfxXlibSurface.h" #include "gfxXlibSurface.h"
#include "gfx2DGlue.h" #include "gfx2DGlue.h"
@ -103,4 +101,3 @@ X11TextureSourceOGL::ContentTypeToSurfaceFormat(gfxContentType aType)
} }
} }
#endif

View File

@ -7,7 +7,7 @@
#ifndef MOZILLA_GFX_X11TEXTURESOURCEOGL__H #ifndef MOZILLA_GFX_X11TEXTURESOURCEOGL__H
#define MOZILLA_GFX_X11TEXTURESOURCEOGL__H #define MOZILLA_GFX_X11TEXTURESOURCEOGL__H
#ifdef GL_PROVIDER_GLX #ifdef MOZ_X11
#include "mozilla/layers/CompositorOGL.h" #include "mozilla/layers/CompositorOGL.h"
#include "mozilla/layers/TextureHostOGL.h" #include "mozilla/layers/TextureHostOGL.h"

View File

@ -42,11 +42,9 @@
#include "mozilla/Preferences.h" #include "mozilla/Preferences.h"
#include "mozilla/X11Util.h" #include "mozilla/X11Util.h"
#ifdef GL_PROVIDER_GLX
#include "GLContextProvider.h" #include "GLContextProvider.h"
#include "GLContextGLX.h" #include "GLContextGLX.h"
#include "GLXLibrary.h" #include "GLXLibrary.h"
#endif
/* Undefine the Status from Xlib since it will conflict with system headers on OSX */ /* Undefine the Status from Xlib since it will conflict with system headers on OSX */
#if defined(__APPLE__) && defined(Status) #if defined(__APPLE__) && defined(Status)
@ -508,7 +506,7 @@ gfxPlatformGtk::CheckVariationFontSupport()
return major * 1000000 + minor * 1000 + patch >= 2007001; return major * 1000000 + minor * 1000 + patch >= 2007001;
} }
#ifdef GL_PROVIDER_GLX #ifdef MOZ_X11
class GLXVsyncSource final : public VsyncSource class GLXVsyncSource final : public VsyncSource
{ {

View File

@ -97,7 +97,7 @@ public:
bool AccelerateLayersByDefault() override; bool AccelerateLayersByDefault() override;
#ifdef GL_PROVIDER_GLX #ifdef MOZ_X11
already_AddRefed<mozilla::gfx::VsyncSource> CreateHardwareVsyncSource() override; already_AddRefed<mozilla::gfx::VsyncSource> CreateHardwareVsyncSource() override;
#endif #endif

View File

@ -25,9 +25,7 @@ using namespace mozilla::gfx;
gfxXlibSurface::gfxXlibSurface(Display *dpy, Drawable drawable, Visual *visual) gfxXlibSurface::gfxXlibSurface(Display *dpy, Drawable drawable, Visual *visual)
: mPixmapTaken(false), mDisplay(dpy), mDrawable(drawable) : mPixmapTaken(false), mDisplay(dpy), mDrawable(drawable)
#if defined(GL_PROVIDER_GLX)
, mGLXPixmap(X11None) , mGLXPixmap(X11None)
#endif
{ {
const gfx::IntSize size = DoSizeQuery(); const gfx::IntSize size = DoSizeQuery();
cairo_surface_t *surf = cairo_xlib_surface_create(dpy, drawable, visual, size.width, size.height); cairo_surface_t *surf = cairo_xlib_surface_create(dpy, drawable, visual, size.width, size.height);
@ -36,9 +34,7 @@ gfxXlibSurface::gfxXlibSurface(Display *dpy, Drawable drawable, Visual *visual)
gfxXlibSurface::gfxXlibSurface(Display *dpy, Drawable drawable, Visual *visual, const gfx::IntSize& size) gfxXlibSurface::gfxXlibSurface(Display *dpy, Drawable drawable, Visual *visual, const gfx::IntSize& size)
: mPixmapTaken(false), mDisplay(dpy), mDrawable(drawable) : mPixmapTaken(false), mDisplay(dpy), mDrawable(drawable)
#if defined(GL_PROVIDER_GLX)
, mGLXPixmap(X11None) , mGLXPixmap(X11None)
#endif
{ {
NS_ASSERTION(Factory::CheckSurfaceSize(size, XLIB_IMAGE_SIDE_SIZE_LIMIT), NS_ASSERTION(Factory::CheckSurfaceSize(size, XLIB_IMAGE_SIDE_SIZE_LIMIT),
"Bad size"); "Bad size");
@ -49,11 +45,10 @@ gfxXlibSurface::gfxXlibSurface(Display *dpy, Drawable drawable, Visual *visual,
gfxXlibSurface::gfxXlibSurface(Screen *screen, Drawable drawable, XRenderPictFormat *format, gfxXlibSurface::gfxXlibSurface(Screen *screen, Drawable drawable, XRenderPictFormat *format,
const gfx::IntSize& size) const gfx::IntSize& size)
: mPixmapTaken(false), mDisplay(DisplayOfScreen(screen)), : mPixmapTaken(false)
mDrawable(drawable) , mDisplay(DisplayOfScreen(screen))
#if defined(GL_PROVIDER_GLX) , mDrawable(drawable)
, mGLXPixmap(X11None) , mGLXPixmap(X11None)
#endif
{ {
NS_ASSERTION(Factory::CheckSurfaceSize(size, XLIB_IMAGE_SIDE_SIZE_LIMIT), NS_ASSERTION(Factory::CheckSurfaceSize(size, XLIB_IMAGE_SIDE_SIZE_LIMIT),
"Bad Size"); "Bad Size");
@ -67,9 +62,7 @@ gfxXlibSurface::gfxXlibSurface(Screen *screen, Drawable drawable, XRenderPictFor
gfxXlibSurface::gfxXlibSurface(cairo_surface_t *csurf) gfxXlibSurface::gfxXlibSurface(cairo_surface_t *csurf)
: mPixmapTaken(false) : mPixmapTaken(false)
#if defined(GL_PROVIDER_GLX) , mGLXPixmap(X11None)
, mGLXPixmap(X11None)
#endif
{ {
MOZ_ASSERT(cairo_surface_status(csurf) == 0, MOZ_ASSERT(cairo_surface_status(csurf) == 0,
"Not expecting an error surface"); "Not expecting an error surface");
@ -84,11 +77,9 @@ gfxXlibSurface::~gfxXlibSurface()
{ {
// gfxASurface's destructor calls RecordMemoryFreed(). // gfxASurface's destructor calls RecordMemoryFreed().
if (mPixmapTaken) { if (mPixmapTaken) {
#if defined(GL_PROVIDER_GLX)
if (mGLXPixmap) { if (mGLXPixmap) {
gl::sGLXLibrary.DestroyPixmap(mDisplay, mGLXPixmap); gl::sGLXLibrary.DestroyPixmap(mDisplay, mGLXPixmap);
} }
#endif
XFreePixmap (mDisplay, mDrawable); XFreePixmap (mDisplay, mDrawable);
} }
} }
@ -272,12 +263,10 @@ gfxXlibSurface::CreateSimilarSurface(gfxContentType aContent,
void void
gfxXlibSurface::Finish() gfxXlibSurface::Finish()
{ {
#if defined(GL_PROVIDER_GLX)
if (mPixmapTaken && mGLXPixmap) { if (mPixmapTaken && mGLXPixmap) {
gl::sGLXLibrary.DestroyPixmap(mDisplay, mGLXPixmap); gl::sGLXLibrary.DestroyPixmap(mDisplay, mGLXPixmap);
mGLXPixmap = X11None; mGLXPixmap = X11None;
} }
#endif
gfxASurface::Finish(); gfxASurface::Finish();
} }
@ -587,7 +576,6 @@ gfxXlibSurface::XRenderFormat()
return cairo_xlib_surface_get_xrender_format(CairoSurface()); return cairo_xlib_surface_get_xrender_format(CairoSurface());
} }
#if defined(GL_PROVIDER_GLX)
GLXPixmap GLXPixmap
gfxXlibSurface::GetGLXPixmap() gfxXlibSurface::GetGLXPixmap()
{ {
@ -612,4 +600,3 @@ gfxXlibSurface::BindGLXPixmap(GLXPixmap aPixmap)
mGLXPixmap = aPixmap; mGLXPixmap = aPixmap;
} }
#endif

View File

@ -12,9 +12,7 @@
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include "X11UndefineNone.h" #include "X11UndefineNone.h"
#if defined(GL_PROVIDER_GLX)
#include "GLXLibrary.h" #include "GLXLibrary.h"
#endif
#include "nsSize.h" #include "nsSize.h"
@ -86,12 +84,10 @@ public:
// Find a visual and colormap pair suitable for rendering to this surface. // Find a visual and colormap pair suitable for rendering to this surface.
bool GetColormapAndVisual(Colormap* colormap, Visual **visual); bool GetColormapAndVisual(Colormap* colormap, Visual **visual);
#if defined(GL_PROVIDER_GLX)
GLXPixmap GetGLXPixmap(); GLXPixmap GetGLXPixmap();
// Binds a GLXPixmap backed by this context's surface. // Binds a GLXPixmap backed by this context's surface.
// Primarily for use in sharing surfaces. // Primarily for use in sharing surfaces.
void BindGLXPixmap(GLXPixmap aPixmap); void BindGLXPixmap(GLXPixmap aPixmap);
#endif
// Return true if cairo will take its slow path when this surface is used // Return true if cairo will take its slow path when this surface is used
// in a pattern with EXTEND_PAD. As a workaround for XRender's RepeatPad // in a pattern with EXTEND_PAD. As a workaround for XRender's RepeatPad
@ -114,9 +110,7 @@ protected:
const mozilla::gfx::IntSize DoSizeQuery(); const mozilla::gfx::IntSize DoSizeQuery();
#if defined(GL_PROVIDER_GLX)
GLXPixmap mGLXPixmap; GLXPixmap mGLXPixmap;
#endif
}; };
#endif /* GFX_XLIBSURFACE_H */ #endif /* GFX_XLIBSURFACE_H */