#include "ui/ozone/platform/wayland/gpu/wayland_surface_factory.h"
#include <memory>
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "ui/gfx/linux/client_native_pixmap_dmabuf.h"
#include "ui/gfx/linux/native_pixmap_dmabuf.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_surface_egl.h"
#include "ui/gl/presenter.h"
#include "ui/ozone/common/egl_util.h"
#include "ui/ozone/common/gl_ozone_egl.h"
#include "ui/ozone/common/native_pixmap_egl_binding.h"
#include "ui/ozone/platform/wayland/common/wayland_object.h"
#include "ui/ozone/platform/wayland/gpu/gl_surface_egl_readback_wayland.h"
#include "ui/ozone/platform/wayland/gpu/gl_surface_wayland.h"
#include "ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.h"
#include "ui/ozone/platform/wayland/gpu/wayland_canvas_surface.h"
#include "ui/ozone/platform/wayland/host/wayland_connection.h"
#include "ui/ozone/platform/wayland/host/wayland_window.h"
#include "ui/ozone/platform/wayland/host/wayland_window_manager.h"
#if defined(WAYLAND_GBM)
#include "ui/gfx/buffer_format_util.h"
#include "ui/gfx/linux/drm_util_linux.h"
#include "ui/gfx/linux/gbm_device.h"
#include "ui/ozone/platform/wayland/gpu/gbm_pixmap_wayland.h"
#include "ui/ozone/platform/wayland/gpu/gbm_surfaceless_wayland.h"
#include "ui/ozone/public/ozone_platform.h"
#endif
#if BUILDFLAG(ENABLE_VULKAN)
#include "ui/ozone/platform/wayland/gpu/vulkan_implementation_wayland.h"
#endif
namespace ui {
namespace {
class GLOzoneEGLWayland : public GLOzoneEGL { … };
bool GLOzoneEGLWayland::CanImportNativePixmap(gfx::BufferFormat format) { … }
std::unique_ptr<NativePixmapGLBinding> GLOzoneEGLWayland::ImportNativePixmap(
scoped_refptr<gfx::NativePixmap> pixmap,
gfx::BufferFormat plane_format,
gfx::BufferPlane plane,
gfx::Size plane_size,
const gfx::ColorSpace& color_space,
GLenum target,
GLuint texture_id) { … }
scoped_refptr<gl::GLSurface> GLOzoneEGLWayland::CreateViewGLSurface(
gl::GLDisplay* display,
gfx::AcceleratedWidget widget) { … }
scoped_refptr<gl::Presenter> GLOzoneEGLWayland::CreateSurfacelessViewGLSurface(
gl::GLDisplay* display,
gfx::AcceleratedWidget window) { … }
scoped_refptr<gl::GLSurface> GLOzoneEGLWayland::CreateOffscreenGLSurface(
gl::GLDisplay* display,
const gfx::Size& size) { … }
gl::EGLDisplayPlatform GLOzoneEGLWayland::GetNativeDisplay() { … }
bool GLOzoneEGLWayland::LoadGLES2Bindings(
const gl::GLImplementationParts& impl) { … }
}
WaylandSurfaceFactory::WaylandSurfaceFactory(
WaylandConnection* connection,
WaylandBufferManagerGpu* buffer_manager)
: … { … }
WaylandSurfaceFactory::~WaylandSurfaceFactory() = default;
std::unique_ptr<SurfaceOzoneCanvas>
WaylandSurfaceFactory::CreateCanvasForWidget(gfx::AcceleratedWidget widget) { … }
std::vector<gl::GLImplementationParts>
WaylandSurfaceFactory::GetAllowedGLImplementations() { … }
GLOzone* WaylandSurfaceFactory::GetGLOzone(
const gl::GLImplementationParts& implementation) { … }
#if BUILDFLAG(ENABLE_VULKAN)
std::unique_ptr<gpu::VulkanImplementation>
WaylandSurfaceFactory::CreateVulkanImplementation(bool use_swiftshader,
bool allow_protected_memory) { … }
#endif
scoped_refptr<gfx::NativePixmap> WaylandSurfaceFactory::CreateNativePixmap(
gfx::AcceleratedWidget widget,
gpu::VulkanDeviceQueue* device_queue,
gfx::Size size,
gfx::BufferFormat format,
gfx::BufferUsage usage,
std::optional<gfx::Size> framebuffer_size) { … }
void WaylandSurfaceFactory::CreateNativePixmapAsync(
gfx::AcceleratedWidget widget,
gpu::VulkanDeviceQueue* device_queue,
gfx::Size size,
gfx::BufferFormat format,
gfx::BufferUsage usage,
NativePixmapCallback callback) { … }
scoped_refptr<gfx::NativePixmap>
WaylandSurfaceFactory::CreateNativePixmapFromHandle(
gfx::AcceleratedWidget widget,
gfx::Size size,
gfx::BufferFormat format,
gfx::NativePixmapHandle handle) { … }
bool WaylandSurfaceFactory::SupportsNativePixmaps() const { … }
std::optional<gfx::BufferFormat>
WaylandSurfaceFactory::GetPreferredFormatForSolidColor() const { … }
bool WaylandSurfaceFactory::SupportsDrmModifiersFilter() const { … }
void WaylandSurfaceFactory::SetDrmModifiersFilter(
std::unique_ptr<DrmModifiersFilter> filter) { … }
std::vector<gfx::BufferFormat>
WaylandSurfaceFactory::GetSupportedFormatsForTexturing() const { … }
}