| Index: ui/gl/gl_surface_ozone.cc
|
| diff --git a/ui/gl/gl_surface_ozone.cc b/ui/gl/gl_surface_ozone.cc
|
| index d4d2fe1ca4beb3f11397b95fa53b1ad2971c441b..8b7148d1d3ccfaf2cec368f26f3093838fd1a897 100644
|
| --- a/ui/gl/gl_surface_ozone.cc
|
| +++ b/ui/gl/gl_surface_ozone.cc
|
| @@ -32,6 +32,13 @@
|
| #include "ui/ozone/public/surface_factory_ozone.h"
|
| #include "ui/ozone/public/surface_ozone_egl.h"
|
|
|
| +#if defined(USE_GLX)
|
| +#include <X11/Xlib.h>
|
| +
|
| +#include "ui/events/platform/x11/x11_event_source_libevent.h"
|
| +#include "ui/gl/gl_surface_glx.h"
|
| +#endif
|
| +
|
| using gl::GLImage;
|
|
|
| namespace gfx {
|
| @@ -653,6 +660,64 @@ bool GLSurfaceOzoneSurfacelessSurfaceImpl::CreatePixmaps() {
|
| return true;
|
| }
|
|
|
| +#if defined(USE_GLX)
|
| +
|
| +// Ozone specific implementation of GLX surface. Registers as XEventDispatcher
|
| +// to handle XEvents.
|
| +class GL_EXPORT NativeViewGLSurfaceGLXOzone : public NativeViewGLSurfaceGLX,
|
| + public ui::XEventDispatcher {
|
| + public:
|
| + explicit NativeViewGLSurfaceGLXOzone(gfx::AcceleratedWidget window);
|
| +
|
| + // XEventDispatcher implementation:
|
| + bool DispatchXEvent(XEvent* xevent) override;
|
| +
|
| + protected:
|
| + ~NativeViewGLSurfaceGLXOzone() override;
|
| +
|
| + // NativeViewGLSurfaceGLX implementation:
|
| + void RegisterEvents() override;
|
| + void UnregisterEvents() override;
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceGLXOzone);
|
| +};
|
| +
|
| +NativeViewGLSurfaceGLXOzone::NativeViewGLSurfaceGLXOzone(
|
| + gfx::AcceleratedWidget window)
|
| + : NativeViewGLSurfaceGLX(window) {}
|
| +
|
| +bool NativeViewGLSurfaceGLXOzone::DispatchXEvent(XEvent* event) {
|
| + if (!CanHandleEvent(event))
|
| + return false;
|
| +
|
| + ForwardExposeEvent(event);
|
| + return true;
|
| +}
|
| +
|
| +NativeViewGLSurfaceGLXOzone::~NativeViewGLSurfaceGLXOzone() {
|
| + Destroy();
|
| +}
|
| +
|
| +void NativeViewGLSurfaceGLXOzone::RegisterEvents() {
|
| + ui::X11EventSourceLibevent* event_source =
|
| + ui::X11EventSourceLibevent::GetInstance();
|
| + // Can be nullptr in tests, when we don't care about Exposes.
|
| + if (event_source) {
|
| + XSelectInput(gfx::GetXDisplay(), window(), ExposureMask);
|
| + event_source->AddXEventDispatcher(this);
|
| + }
|
| +}
|
| +
|
| +void NativeViewGLSurfaceGLXOzone::UnregisterEvents() {
|
| + ui::X11EventSourceLibevent* event_source =
|
| + ui::X11EventSourceLibevent::GetInstance();
|
| + if (event_source)
|
| + event_source->RemoveXEventDispatcher(this);
|
| +}
|
| +
|
| +#endif // defined(USE_GLX)
|
| +
|
| scoped_refptr<GLSurface> CreateViewGLSurfaceOzone(
|
| gfx::AcceleratedWidget window) {
|
| std::unique_ptr<ui::SurfaceOzoneEGL> surface_ozone =
|
| @@ -688,6 +753,15 @@ scoped_refptr<GLSurface> CreateViewGLSurfaceOzoneSurfacelessSurfaceImpl(
|
| // static
|
| bool GLSurface::InitializeOneOffInternal() {
|
| switch (GetGLImplementation()) {
|
| +#if defined(USE_GLX)
|
| + case kGLImplementationDesktopGL:
|
| + if (!GLSurfaceGLX::InitializeOneOff()) {
|
| + LOG(ERROR) << "GLSurfaceGLX::InitializeOneOff failed.";
|
| + return false;
|
| + }
|
| +
|
| + return true;
|
| +#endif
|
| case kGLImplementationEGLGLES2:
|
| if (!GLSurfaceEGL::InitializeOneOff()) {
|
| LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed.";
|
| @@ -727,6 +801,14 @@ scoped_refptr<GLSurface> GLSurface::CreateSurfacelessViewGLSurface(
|
| // static
|
| scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface(
|
| gfx::AcceleratedWidget window) {
|
| +#if defined(USE_GLX)
|
| + if (GetGLImplementation() == kGLImplementationDesktopGL) {
|
| + scoped_refptr<GLSurface> surface(new NativeViewGLSurfaceGLXOzone(window));
|
| + if (!surface->Initialize())
|
| + return nullptr;
|
| + return surface;
|
| + }
|
| +#endif
|
| if (GetGLImplementation() == kGLImplementationOSMesaGL) {
|
| scoped_refptr<GLSurface> surface(new GLSurfaceOSMesaHeadless());
|
| if (!surface->Initialize())
|
| @@ -753,6 +835,16 @@ scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface(
|
| scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface(
|
| const gfx::Size& size) {
|
| switch (GetGLImplementation()) {
|
| +#if defined(USE_GLX)
|
| + case kGLImplementationDesktopGL: {
|
| + scoped_refptr<GLSurface> surface(
|
| + new UnmappedNativeViewGLSurfaceGLX(size));
|
| + if (!surface->Initialize())
|
| + return nullptr;
|
| +
|
| + return surface;
|
| + }
|
| +#endif
|
| case kGLImplementationOSMesaGL: {
|
| scoped_refptr<GLSurface> surface(
|
| new GLSurfaceOSMesa(SURFACE_OSMESA_BGRA, size));
|
|
|