gl_surface_egl_x11.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef UI_GL_GL_SURFACE_EGL_X11_H_
  5. #define UI_GL_GL_SURFACE_EGL_X11_H_
  6. #include <stdint.h>
  7. #include "ui/gfx/x/connection.h"
  8. #include "ui/gfx/x/event.h"
  9. #include "ui/gl/gl_export.h"
  10. #include "ui/gl/gl_surface_egl.h"
  11. namespace gl {
  12. // Encapsulates an EGL surface bound to a view using the X Window System.
  13. class GL_EXPORT NativeViewGLSurfaceEGLX11 : public NativeViewGLSurfaceEGL,
  14. public x11::EventObserver {
  15. public:
  16. NativeViewGLSurfaceEGLX11(GLDisplayEGL* display, x11::Window window);
  17. NativeViewGLSurfaceEGLX11(const NativeViewGLSurfaceEGLX11& other) = delete;
  18. NativeViewGLSurfaceEGLX11& operator=(const NativeViewGLSurfaceEGLX11& rhs) =
  19. delete;
  20. // NativeViewGLSurfaceEGL overrides.
  21. bool Initialize(GLSurfaceFormat format) override;
  22. void Destroy() override;
  23. gfx::SwapResult SwapBuffers(PresentationCallback callback) override;
  24. EGLint GetNativeVisualID() const override;
  25. protected:
  26. ~NativeViewGLSurfaceEGLX11() override;
  27. x11::Connection* GetXNativeConnection() const;
  28. private:
  29. // NativeViewGLSurfaceEGL overrides:
  30. std::unique_ptr<gfx::VSyncProvider> CreateVsyncProviderInternal() override;
  31. // x11::EventObserver:
  32. void OnEvent(const x11::Event& xev) override;
  33. std::vector<x11::Window> children_;
  34. // Indicates if the dispatcher has been set.
  35. bool dispatcher_set_ = false;
  36. bool has_swapped_buffers_ = false;
  37. };
  38. } // namespace gl
  39. #endif // UI_GL_GL_SURFACE_EGL_X11_H_