Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Unified Diff: ui/gl/gl_surface_x11.cc

Issue 1723303002: Implement GLX for Ozone X11. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move refactor to new CL. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/gl/gl_surface_x11.cc
diff --git a/ui/gl/gl_surface_x11.cc b/ui/gl/gl_surface_x11.cc
index c6a0653395d2422eb0c26f9e53e8f77db76bfaa5..2b4a47f38e9522b92bf2d2d5fb8f9d3a92811f07 100644
--- a/ui/gl/gl_surface_x11.cc
+++ b/ui/gl/gl_surface_x11.cc
@@ -5,6 +5,7 @@
#include "ui/gl/gl_surface.h"
#include <stdint.h>
+#include <X11/Xlib.h>
#include <memory>
@@ -12,6 +13,8 @@
#include "base/macros.h"
#include "base/message_loop/message_loop.h"
#include "base/trace_event/trace_event.h"
+#include "ui/events/platform/platform_event_dispatcher.h"
+#include "ui/events/platform/platform_event_source.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gl/gl_bindings.h"
@@ -243,6 +246,64 @@ NativeViewGLSurfaceOSMesa::~NativeViewGLSurfaceOSMesa() {
Destroy();
}
+// Native X11 specific implementation of GLX surface. Registers as a
+// PlatformEventDispatcher to handle XEvents.
+class GL_EXPORT NativeViewGLSurfaceGLXX11 : public NativeViewGLSurfaceGLX,
+ public ui::PlatformEventDispatcher {
+ public:
+ explicit NativeViewGLSurfaceGLXX11(gfx::AcceleratedWidget window);
+
+ // PlatformEventDispatcher implementation:
+ bool CanDispatchEvent(const ui::PlatformEvent& event) override;
+ uint32_t DispatchEvent(const ui::PlatformEvent& event) override;
+
+ protected:
+ ~NativeViewGLSurfaceGLXX11() override;
+
+ // NativeViewGLSurfaceGLX implementation:
+ void RegisterEvents() override;
+ void UnregisterEvents() override;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceGLXX11);
+};
+
+NativeViewGLSurfaceGLXX11::NativeViewGLSurfaceGLXX11(
+ gfx::AcceleratedWidget window)
+ : NativeViewGLSurfaceGLX(window) {}
+
+bool NativeViewGLSurfaceGLXX11::CanDispatchEvent(
+ const ui::PlatformEvent& event) {
+ return CanHandleEvent(event);
+}
+
+uint32_t NativeViewGLSurfaceGLXX11::DispatchEvent(
+ const ui::PlatformEvent& event) {
+ ForwardExposeEvent(event);
+ return ui::POST_DISPATCH_STOP_PROPAGATION;
+}
+
+NativeViewGLSurfaceGLXX11::~NativeViewGLSurfaceGLXX11() {
+ Destroy();
+}
+
+void NativeViewGLSurfaceGLXX11::RegisterEvents() {
+ ui::PlatformEventSource* event_source =
+ ui::PlatformEventSource::GetInstance();
+ // Can be nullptr in tests, when we don't care about Exposes.
+ if (event_source) {
+ XSelectInput(gfx::GetXDisplay(), window(), ExposureMask);
+ event_source->AddPlatformEventDispatcher(this);
+ }
+}
+
+void NativeViewGLSurfaceGLXX11::UnregisterEvents() {
+ ui::PlatformEventSource* event_source =
+ ui::PlatformEventSource::GetInstance();
+ if (event_source)
+ event_source->RemovePlatformEventDispatcher(this);
+}
+
} // namespace
bool GLSurface::InitializeOneOffInternal() {
@@ -285,7 +346,7 @@ scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface(
return surface;
}
case kGLImplementationDesktopGL: {
- scoped_refptr<GLSurface> surface(new NativeViewGLSurfaceGLX(window));
+ scoped_refptr<GLSurface> surface(new NativeViewGLSurfaceGLXX11(window));
if (!surface->Initialize())
return NULL;

Powered by Google App Engine
This is Rietveld 408576698