#include "ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.h"
#include <surface-augmenter-client-protocol.h>
#include <utility>
#include "base/functional/bind.h"
#include "base/process/process.h"
#include "base/task/current_thread.h"
#include "base/task/single_thread_task_runner.h"
#include "base/version.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/rrect_f.h"
#include "ui/gfx/linux/drm_util_linux.h"
#include "ui/gfx/overlay_priority_hint.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_surface_egl.h"
#include "ui/ozone/platform/wayland/common/wayland_overlay_config.h"
#include "ui/ozone/platform/wayland/gpu/wayland_surface_gpu.h"
#include "ui/ozone/public/overlay_plane.h"
#if defined(WAYLAND_GBM)
#include "ui/gfx/linux/gbm_wrapper.h"
#include "ui/ozone/platform/wayland/gpu/drm_render_node_handle.h"
#endif
namespace ui {
WaylandBufferManagerGpu::WaylandBufferManagerGpu()
: … { … }
WaylandBufferManagerGpu::WaylandBufferManagerGpu(
const base::FilePath& drm_node_path) { … }
WaylandBufferManagerGpu::~WaylandBufferManagerGpu() = default;
void WaylandBufferManagerGpu::Initialize(
mojo::PendingRemote<ozone::mojom::WaylandBufferManagerHost> remote_host,
const base::flat_map<::gfx::BufferFormat, std::vector<uint64_t>>&
buffer_formats_with_modifiers,
bool supports_dma_buf,
bool supports_viewporter,
bool supports_acquire_fence,
bool supports_overlays,
uint32_t supported_surface_augmentor_version,
bool supports_single_pixel_buffer,
const base::Version& server_version) { … }
void WaylandBufferManagerGpu::OnSubmission(
gfx::AcceleratedWidget widget,
uint32_t frame_id,
gfx::SwapResult swap_result,
gfx::GpuFenceHandle release_fence,
const std::vector<wl::WaylandPresentationInfo>& presentation_infos) { … }
void WaylandBufferManagerGpu::OnPresentation(
gfx::AcceleratedWidget widget,
const std::vector<wl::WaylandPresentationInfo>& presentation_infos) { … }
void WaylandBufferManagerGpu::RegisterSurface(gfx::AcceleratedWidget widget,
WaylandSurfaceGpu* surface) { … }
void WaylandBufferManagerGpu::UnregisterSurface(gfx::AcceleratedWidget widget) { … }
WaylandSurfaceGpu* WaylandBufferManagerGpu::GetSurface(
gfx::AcceleratedWidget widget) { … }
void WaylandBufferManagerGpu::CreateDmabufBasedBuffer(
base::ScopedFD dmabuf_fd,
gfx::Size size,
const std::vector<uint32_t>& strides,
const std::vector<uint32_t>& offsets,
const std::vector<uint64_t>& modifiers,
uint32_t current_format,
uint32_t planes_count,
uint32_t buffer_id) { … }
void WaylandBufferManagerGpu::CreateShmBasedBuffer(base::ScopedFD shm_fd,
size_t length,
gfx::Size size,
uint32_t buffer_id) { … }
void WaylandBufferManagerGpu::CreateSolidColorBuffer(SkColor4f color,
const gfx::Size& size,
uint32_t buf_id) { … }
void WaylandBufferManagerGpu::CreateSinglePixelBuffer(SkColor4f color,
uint32_t buf_id) { … }
void WaylandBufferManagerGpu::CommitBuffer(gfx::AcceleratedWidget widget,
uint32_t frame_id,
uint32_t buffer_id,
gfx::FrameData data,
const gfx::Rect& bounds_rect,
bool enable_blend,
const gfx::RoundedCornersF& corners,
float surface_scale_factor,
const gfx::Rect& damage_region) { … }
void WaylandBufferManagerGpu::CommitOverlays(
gfx::AcceleratedWidget widget,
uint32_t frame_id,
gfx::FrameData data,
std::vector<wl::WaylandOverlayConfig> overlays) { … }
void WaylandBufferManagerGpu::DestroyBuffer(uint32_t buffer_id) { … }
#if defined(WAYLAND_GBM)
GbmDevice* WaylandBufferManagerGpu::GetGbmDevice() { … }
#endif
void WaylandBufferManagerGpu::AddBindingWaylandBufferManagerGpu(
mojo::PendingReceiver<ozone::mojom::WaylandBufferManagerGpu> receiver) { … }
const std::vector<uint64_t>
WaylandBufferManagerGpu::GetModifiersForBufferFormat(
gfx::BufferFormat buffer_format) const { … }
uint32_t WaylandBufferManagerGpu::AllocateBufferID() { … }
bool WaylandBufferManagerGpu::SupportsFormat(
gfx::BufferFormat buffer_format) const { … }
void WaylandBufferManagerGpu::BindHostInterface(
mojo::PendingRemote<ozone::mojom::WaylandBufferManagerHost> remote_host) { … }
void WaylandBufferManagerGpu::SaveTaskRunnerForWidgetOnIOThread(
gfx::AcceleratedWidget widget,
scoped_refptr<base::SingleThreadTaskRunner> origin_runner) { … }
void WaylandBufferManagerGpu::ForgetTaskRunnerForWidgetOnIOThread(
gfx::AcceleratedWidget widget) { … }
void WaylandBufferManagerGpu::HandleSubmissionOnOriginThread(
gfx::AcceleratedWidget widget,
uint32_t frame_id,
gfx::SwapResult swap_result,
gfx::GpuFenceHandle release_fence,
const std::vector<wl::WaylandPresentationInfo>& presentation_infos) { … }
void WaylandBufferManagerGpu::HandlePresentationOnOriginThread(
gfx::AcceleratedWidget widget,
const std::vector<wl::WaylandPresentationInfo>& presentation_infos) { … }
#if defined(WAYLAND_GBM)
void WaylandBufferManagerGpu::OpenAndStoreDrmRenderNodeFd(
const base::FilePath& drm_node_path) { … }
#endif
void WaylandBufferManagerGpu::OnHostDisconnected() { … }
void WaylandBufferManagerGpu::RunOrQueueTask(base::OnceClosure task) { … }
void WaylandBufferManagerGpu::ProcessPendingTasks() { … }
void WaylandBufferManagerGpu::CreateDmabufBasedBufferTask(
base::ScopedFD dmabuf_fd,
gfx::Size size,
const std::vector<uint32_t>& strides,
const std::vector<uint32_t>& offsets,
const std::vector<uint64_t>& modifiers,
uint32_t current_format,
uint32_t planes_count,
uint32_t buffer_id) { … }
void WaylandBufferManagerGpu::CreateShmBasedBufferTask(base::ScopedFD shm_fd,
size_t length,
gfx::Size size,
uint32_t buffer_id) { … }
void WaylandBufferManagerGpu::CreateSolidColorBufferTask(SkColor4f color,
const gfx::Size& size,
uint32_t buf_id) { … }
void WaylandBufferManagerGpu::CreateSinglePixelBufferTask(SkColor4f color,
uint32_t buf_id) { … }
void WaylandBufferManagerGpu::CommitOverlaysTask(
gfx::AcceleratedWidget widget,
uint32_t frame_id,
gfx::FrameData data,
std::vector<wl::WaylandOverlayConfig> overlays) { … }
void WaylandBufferManagerGpu::DestroyBufferTask(uint32_t buffer_id) { … }
}