#include "ui/ozone/platform/wayland/host/wayland_surface.h"
#include <alpha-compositing-unstable-v1-client-protocol.h>
#include <chrome-color-management-client-protocol.h>
#include <content-type-v1-client-protocol.h>
#include <fractional-scale-v1-client-protocol.h>
#include <linux-explicit-synchronization-unstable-v1-client-protocol.h>
#include <overlay-prioritizer-client-protocol.h>
#include <surface-augmenter-client-protocol.h>
#include <viewporter-client-protocol.h>
#include <memory>
#include <utility>
#include "base/check_op.h"
#include "base/files/scoped_file.h"
#include "base/logging.h"
#include "base/not_fatal_until.h"
#include "base/ranges/algorithm.h"
#include "base/trace_event/trace_event.h"
#include "ui/gfx/color_space.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/size_f.h"
#include "ui/gfx/geometry/transform.h"
#include "ui/gfx/gpu_fence.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/overlay_priority_hint.h"
#include "ui/ozone/platform/wayland/common/wayland_util.h"
#include "ui/ozone/platform/wayland/host/fractional_scale_manager.h"
#include "ui/ozone/platform/wayland/host/overlay_prioritizer.h"
#include "ui/ozone/platform/wayland/host/surface_augmenter.h"
#include "ui/ozone/platform/wayland/host/wayland_buffer_handle.h"
#include "ui/ozone/platform/wayland/host/wayland_buffer_manager_host.h"
#include "ui/ozone/platform/wayland/host/wayland_connection.h"
#include "ui/ozone/platform/wayland/host/wayland_output.h"
#include "ui/ozone/platform/wayland/host/wayland_output_manager.h"
#include "ui/ozone/platform/wayland/host/wayland_subsurface.h"
#include "ui/ozone/platform/wayland/host/wayland_window.h"
#include "ui/ozone/platform/wayland/host/wayland_zaura_shell.h"
#include "ui/ozone/platform/wayland/host/wayland_zaura_surface.h"
#include "ui/ozone/platform/wayland/host/wayland_zcr_color_management_output.h"
#include "ui/ozone/platform/wayland/host/wayland_zcr_color_management_surface.h"
#include "ui/ozone/platform/wayland/host/wayland_zcr_color_manager.h"
namespace ui {
namespace {
uint32_t TranslatePriority(gfx::OverlayPriorityHint priority_hint) { … }
const wl_fixed_t kMinusOne = …;
}
WaylandSurface::ExplicitReleaseInfo::ExplicitReleaseInfo(
wl::Object<zwp_linux_buffer_release_v1>&& linux_buffer_release,
wl_buffer* buffer,
ExplicitReleaseCallback explicit_release_callback)
: … { … }
WaylandSurface::ExplicitReleaseInfo::~ExplicitReleaseInfo() = default;
WaylandSurface::ExplicitReleaseInfo::ExplicitReleaseInfo(
ExplicitReleaseInfo&&) = default;
WaylandSurface::ExplicitReleaseInfo&
WaylandSurface::ExplicitReleaseInfo::operator=(ExplicitReleaseInfo&&) = default;
WaylandSurface::WaylandSurface(WaylandConnection* connection,
WaylandWindow* root_window)
: … { … }
WaylandSurface::~WaylandSurface() { … }
WaylandZAuraSurface* WaylandSurface::CreateZAuraSurface() { … }
void WaylandSurface::ResetZAuraSurface() { … }
void WaylandSurface::RequestExplicitRelease(ExplicitReleaseCallback callback) { … }
gfx::AcceleratedWidget WaylandSurface::get_widget() const { … }
bool WaylandSurface::Initialize() { … }
void WaylandSurface::UnsetRootWindow() { … }
void WaylandSurface::SetRootWindow(WaylandWindow* window) { … }
void WaylandSurface::set_acquire_fence(gfx::GpuFenceHandle acquire_fence) { … }
bool WaylandSurface::AttachBuffer(WaylandBufferHandle* buffer_handle) { … }
void WaylandSurface::UpdateBufferDamageRegion(const gfx::Rect& damage_px) { … }
void WaylandSurface::Commit(bool flush) { … }
void WaylandSurface::set_surface_buffer_scale(float scale) { … }
void WaylandSurface::set_opaque_region(
std::optional<std::vector<gfx::Rect>> region_px) { … }
void WaylandSurface::set_input_region(
std::optional<std::vector<gfx::Rect>> region_px) { … }
float WaylandSurface::GetWaylandScale(const State& state) { … }
bool WaylandSurface::IsViewportScaled(const State& state) { … }
wl::Object<wl_region> WaylandSurface::CreateAndAddRegion(
const std::vector<gfx::Rect>& region_px,
float buffer_scale) { … }
zwp_linux_surface_synchronization_v1* WaylandSurface::GetOrCreateSurfaceSync() { … }
wl::Object<wl_subsurface> WaylandSurface::CreateSubsurface(
WaylandSurface* parent) { … }
bool WaylandSurface::ApplyPendingState() { … }
void WaylandSurface::ForceImmediateStateApplication() { … }
void WaylandSurface::EnableTrustedDamageIfPossible() { … }
void WaylandSurface::ExplicitRelease(
zwp_linux_buffer_release_v1* linux_buffer_release,
base::ScopedFD fence) { … }
WaylandSurface::State::State() = default;
WaylandSurface::State::~State() = default;
WaylandSurface::State& WaylandSurface::State::operator=(
const WaylandSurface::State& other) { … }
void WaylandSurface::OnEnter(void* data,
wl_surface* surface,
wl_output* output) { … }
void WaylandSurface::OnLeave(void* data,
wl_surface* surface,
wl_output* output) { … }
void WaylandSurface::OnPreferredScale(void* data,
wp_fractional_scale_v1* fractional_scale,
uint32_t scale) { … }
void WaylandSurface::RemoveEnteredOutput(uint32_t output_id) { … }
void WaylandSurface::set_color_space(gfx::ColorSpace color_space) { … }
void WaylandSurface::OnFencedRelease(
void* data,
zwp_linux_buffer_release_v1* buffer_release,
int32_t fence) { … }
void WaylandSurface::OnImmediateRelease(
void* data,
zwp_linux_buffer_release_v1* buffer_release) { … }
}