#include "ui/ozone/platform/wayland/host/wayland_buffer_manager_host.h"
#include <sys/ioctl.h>
#include <sys/utsname.h>
#include <unistd.h>
#include <presentation-time-client-protocol.h>
#include <memory>
#include <utility>
#include "base/functional/bind.h"
#include "base/i18n/number_formatting.h"
#include "base/logging.h"
#include "base/posix/eintr_wrapper.h"
#include "base/strings/strcat.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/current_thread.h"
#include "base/trace_event/trace_event.h"
#include "base/version.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/gpu_fence_handle.h"
#include "ui/gfx/linux/dmabuf_uapi.h"
#include "ui/gfx/linux/drm_util_linux.h"
#include "ui/ozone/platform/wayland/common/wayland_overlay_config.h"
#include "ui/ozone/platform/wayland/host/surface_augmenter.h"
#include "ui/ozone/platform/wayland/host/wayland_buffer_backing.h"
#include "ui/ozone/platform/wayland/host/wayland_buffer_backing_dmabuf.h"
#include "ui/ozone/platform/wayland/host/wayland_buffer_backing_shm.h"
#include "ui/ozone/platform/wayland/host/wayland_buffer_backing_single_pixel.h"
#include "ui/ozone/platform/wayland/host/wayland_buffer_backing_solid_color.h"
#include "ui/ozone/platform/wayland/host/wayland_buffer_factory.h"
#include "ui/ozone/platform/wayland/host/wayland_buffer_handle.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_zaura_shell.h"
namespace ui {
namespace {
std::string NumberToString(uint32_t number) { … }
struct KernelVersion { … };
KernelVersion KernelVersionNumbers() { … }
bool CheckImportExportFence() { … }
}
WaylandBufferManagerHost::WaylandBufferManagerHost(
WaylandConnection* connection)
: … { … }
WaylandBufferManagerHost::~WaylandBufferManagerHost() = default;
void WaylandBufferManagerHost::SetTerminateGpuCallback(
base::OnceCallback<void(std::string)> terminate_callback) { … }
mojo::PendingRemote<ozone::mojom::WaylandBufferManagerHost>
WaylandBufferManagerHost::BindInterface() { … }
void WaylandBufferManagerHost::OnChannelDestroyed() { … }
void WaylandBufferManagerHost::OnCommitOverlayError(
const std::string& message) { … }
base::Version WaylandBufferManagerHost::GetServerVersion() const { … }
wl::BufferFormatsWithModifiersMap
WaylandBufferManagerHost::GetSupportedBufferFormats() const { … }
bool WaylandBufferManagerHost::SupportsDmabuf() const { … }
bool WaylandBufferManagerHost::SupportsAcquireFence() const { … }
bool WaylandBufferManagerHost::SupportsViewporter() const { … }
bool WaylandBufferManagerHost::SupportsNonBackedSolidColorBuffers() const { … }
bool WaylandBufferManagerHost::SupportsOverlays() const { … }
bool WaylandBufferManagerHost::SupportsSinglePixelBuffer() const { … }
uint32_t WaylandBufferManagerHost::GetSurfaceAugmentorVersion() const { … }
void WaylandBufferManagerHost::SetWaylandBufferManagerGpu(
mojo::PendingAssociatedRemote<ozone::mojom::WaylandBufferManagerGpu>
buffer_manager_gpu_associated) { … }
void WaylandBufferManagerHost::CreateDmabufBasedBuffer(
mojo::PlatformHandle dmabuf_fd,
const gfx::Size& size,
const std::vector<uint32_t>& strides,
const std::vector<uint32_t>& offsets,
const std::vector<uint64_t>& modifiers,
uint32_t format,
uint32_t planes_count,
uint32_t buffer_id) { … }
void WaylandBufferManagerHost::CreateShmBasedBuffer(mojo::PlatformHandle shm_fd,
uint64_t length,
const gfx::Size& size,
uint32_t buffer_id) { … }
void WaylandBufferManagerHost::CreateSolidColorBuffer(const gfx::Size& size,
const SkColor4f& color,
uint32_t buffer_id) { … }
void WaylandBufferManagerHost::CreateSinglePixelBuffer(const SkColor4f& color,
uint32_t buffer_id) { … }
WaylandBufferHandle* WaylandBufferManagerHost::EnsureBufferHandle(
WaylandSurface* requestor,
uint32_t buffer_id) { … }
WaylandBufferHandle* WaylandBufferManagerHost::GetBufferHandle(
WaylandSurface* requestor,
uint32_t buffer_id) { … }
uint32_t WaylandBufferManagerHost::GetBufferFormat(WaylandSurface* requestor,
uint32_t buffer_id) { … }
void WaylandBufferManagerHost::CommitOverlays(
gfx::AcceleratedWidget widget,
uint32_t frame_id,
const gfx::FrameData& data,
std::vector<wl::WaylandOverlayConfig> overlays) { … }
void WaylandBufferManagerHost::DestroyBuffer(uint32_t buffer_id) { … }
bool WaylandBufferManagerHost::ValidateDataFromGpu(
const base::ScopedFD& fd,
const gfx::Size& size,
const std::vector<uint32_t>& strides,
const std::vector<uint32_t>& offsets,
const std::vector<uint64_t>& modifiers,
uint32_t format,
uint32_t planes_count,
uint32_t buffer_id) { … }
bool WaylandBufferManagerHost::ValidateBufferIdFromGpu(uint32_t buffer_id) { … }
bool WaylandBufferManagerHost::ValidateDataFromGpu(const base::ScopedFD& fd,
size_t length,
const gfx::Size& size,
uint32_t buffer_id) { … }
bool WaylandBufferManagerHost::ValidateDataFromGpu(const gfx::Size& size,
uint32_t buffer_id) { … }
bool WaylandBufferManagerHost::ValidateBufferExistence(uint32_t buffer_id) { … }
void WaylandBufferManagerHost::OnSubmission(
gfx::AcceleratedWidget widget,
uint32_t frame_id,
const gfx::SwapResult& swap_result,
gfx::GpuFenceHandle release_fence,
const std::vector<wl::WaylandPresentationInfo>& presentation_infos) { … }
void WaylandBufferManagerHost::OnPresentation(
gfx::AcceleratedWidget widget,
const std::vector<wl::WaylandPresentationInfo>& presentation_infos) { … }
void WaylandBufferManagerHost::InsertAcquireFence(uint32_t buffer_id,
int sync_fd) { … }
base::ScopedFD WaylandBufferManagerHost::ExtractReleaseFence(
uint32_t buffer_id) { … }
bool WaylandBufferManagerHost::SupportsImplicitSyncInterop() { … }
void WaylandBufferManagerHost::TerminateGpuProcess() { … }
}